git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #93104 from Kloenk/moodle-plugins

nixos/moodle: add plugins

commitb6eca9a2afa143bcbee3b4ae1bdc13993bc71784 authorLassulus <github@lassul.us> dateFri 17 Jul 2020, 17:47 (6 years ago) parentbae6984832d228
4 files changed+75−14
nixos/modules/services/web-apps/moodle.nix+9−5 pkgs/servers/web-apps/moodle/default.nix+32−9 pkgs/servers/web-apps/moodle/moodle-utils.nix+32 pkgs/top-level/all-packages.nix+2
nixos/modules/services/web-apps/moodle.nix+9−5
@@ -40,7 +40,7 @@ let
4040 $CFG->disableupdateautodeploy = true;
4141
4242 $CFG->pathtogs = '${pkgs.ghostscript}/bin/gs';
43− $CFG->pathtophp = '${pkgs.php}/bin/php';
43+ $CFG->pathtophp = '${phpExt}/bin/php';
4444 $CFG->pathtodu = '${pkgs.coreutils}/bin/du';
4545 $CFG->aspellpath = '${pkgs.aspell}/bin/aspell';
4646 $CFG->pathtodot = '${pkgs.graphviz}/bin/dot';
@@ -55,6 +55,9 @@ let
5555
5656 mysqlLocal = cfg.database.createLocally && cfg.database.type == "mysql";
5757 pgsqlLocal = cfg.database.createLocally && cfg.database.type == "pgsql";
58+
59+ phpExt = pkgs.php.withExtensions
60+ ({ enabled, all }: with all; [ iconv mbstring curl openssl tokenizer xmlrpc soap ctype zip gd simplexml dom intl json sqlite3 pgsql pdo_sqlite pdo_pgsql pdo_odbc pdo_mysql pdo mysqli session zlib xmlreader fileinfo ]);
5861in
5962{
6063 # interface
@@ -222,6 +225,7 @@ in
222225
223226 services.phpfpm.pools.moodle = {
224227 inherit user group;
228+ phpPackage = phpExt;
225229 phpEnv.MOODLE_CONFIG = "${moodleConfig}";
226230 phpOptions = ''
227231 zend_extension = opcache.so
@@ -263,13 +267,13 @@ in
263267 after = optional mysqlLocal "mysql.service" ++ optional pgsqlLocal "postgresql.service";
264268 environment.MOODLE_CONFIG = moodleConfig;
265269 script = ''
266− ${pkgs.php}/bin/php ${cfg.package}/share/moodle/admin/cli/check_database_schema.php && rc=$? || rc=$?
270+ ${phpExt}/bin/php ${cfg.package}/share/moodle/admin/cli/check_database_schema.php && rc=$? || rc=$?
267271
268− [ "$rc" == 1 ] && ${pkgs.php}/bin/php ${cfg.package}/share/moodle/admin/cli/upgrade.php \
272+ [ "$rc" == 1 ] && ${phpExt}/bin/php ${cfg.package}/share/moodle/admin/cli/upgrade.php \
269273 --non-interactive \
270274 --allow-unstable
271275
272− [ "$rc" == 2 ] && ${pkgs.php}/bin/php ${cfg.package}/share/moodle/admin/cli/install_database.php \
276+ [ "$rc" == 2 ] && ${phpExt}/bin/php ${cfg.package}/share/moodle/admin/cli/install_database.php \
273277 --agree-license \
274278 --adminpass=${cfg.initialPassword}
275279
@@ -289,7 +293,7 @@ in
289293 serviceConfig = {
290294 User = user;
291295 Group = group;
292− ExecStart = "${pkgs.php}/bin/php ${cfg.package}/share/moodle/admin/cli/cron.php";
296+ ExecStart = "${phpExt}/bin/php ${cfg.package}/share/moodle/admin/cli/cron.php";
293297 };
294298 };
295299
pkgs/servers/web-apps/moodle/default.nix+32−9
@@ -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 = "sha256-6QJDEInUQQSNj3kThQ65o2cT6JaRy0FrEKy+EcDMVvs=";
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 ];
pkgs/servers/web-apps/moodle/moodle-utils.nixnew file+32
@@ -0,0 +1,32 @@
1+{ stdenv, unzip, ... }:
2+
3+let
4+ buildMoodlePlugin = a@{
5+ name,
6+ src,
7+ pluginType,
8+ configuraPhase ? ":",
9+ buildPhase ? ":",
10+ buildInputs ? [ ],
11+ ...
12+ }:
13+ stdenv.mkDerivation (a // {
14+ name = name;
15+
16+ inherit pluginType;
17+ inherit configuraPhase buildPhase;
18+
19+ buildInputs = [ unzip ] ++ buildInputs;
20+
21+ installPhase = ''
22+ runHook preInstall
23+
24+ mkdir -p "$out"
25+ mv * $out/
26+
27+ runHook postInstall
28+ '';
29+ });
30+in {
31+ inherit buildMoodlePlugin;
32+}
pkgs/top-level/all-packages.nix+2
@@ -16060,6 +16060,8 @@ in
1606016060
1606116061 moodle = callPackage ../servers/web-apps/moodle { };
1606216062
16063+ moodle-utils = callPackage ../servers/web-apps/moodle/moodle-utils.nix { };
16064+
1606316065 morty = callPackage ../servers/web-apps/morty { };
1606416066
1606516067 mullvad-vpn = callPackage ../applications/networking/mullvad-vpn { };