@@ -1,23 +1,23 @@
1−{ stdenv, fetchurl, writeText }:
1+{ lib, stdenv, fetchurl, writeText, plugins ? [ ] }:
22
33let
44 version = "3.9.1";
55 stableVersion = builtins.substring 0 2 (builtins.replaceStrings ["."] [""] version);
6−in
76
8−stdenv.mkDerivation rec {
7+in stdenv.mkDerivation rec {
98 pname = "moodle";
109 inherit version;
1110
1211 src = fetchurl {
13− url = "https://download.moodle.org/stable${stableVersion}/${pname}-${version}.tgz";
14− sha256 = "1ysnrk013gmc21ml3jwijvl16rx3p478a4vriy6h8hfli48460p9";
12+ url =
13+ "https://download.moodle.org/stable${stableVersion}/${pname}-${version}.tgz";
14+ sha256 = "dffe8c1ac68938f50a987b46b0bfc74f01235d0198ac96fb4fc4f1df5bd7f4ea";
1515 };
1616
1717 phpConfig = writeText "config.php" ''
18− <?php
19− return require(getenv('MOODLE_CONFIG'));
20− ?>
18+ <?php
19+ return require(getenv('MOODLE_CONFIG'));
20+ ?>
2121 '';
2222
2323 installPhase = ''
@@ -27,11 +27,34 @@ stdenv.mkDerivation rec {
2727 cp -r . $out/share/moodle
2828 cp ${phpConfig} $out/share/moodle/config.php
2929
30+ ${lib.concatStringsSep "\n" (map (p:
31+ let
32+ dir = if p.pluginType == "mod" then
33+ "mod"
34+ else if p.pluginType == "theme" then
35+ "theme"
36+ else if p.pluginType == "block" then
37+ "blocks"
38+ else if p.pluginType == "question" then
39+ "question/type"
40+ else if p.pluginType == "course" then
41+ "course/format"
42+ else if p.pluginType == "report" then
43+ "admin/report"
44+ else
45+ throw "unknown moodle plugin type";
46+ # we have to copy it, because the plugins have refrences to .. inside
47+ in ''
48+ mkdir -p $out/share/moodle/${dir}/${p.name}
49+ cp -r ${p}/* $out/share/moodle/${dir}/${p.name}/
50+ '') plugins)}
51+
3052 runHook postInstall
3153 '';
3254
3355 meta = with stdenv.lib; {
34− description = "Free and open-source learning management system (LMS) written in PHP";
56+ description =
57+ "Free and open-source learning management system (LMS) written in PHP";
3558 license = licenses.gpl3Plus;
3659 homepage = "https://moodle.org/";
3760 maintainers = with maintainers; [ aanderse ];