git.iko.soy/typeable/nixpkgs
on master help sign in
nixos/moodle: add plugins
commit7561a3dc4aad5f5811f585f75bb565153cf2f2d9 authorFinn Behrens <me@kloenk.de> dateThu 18 Jun 2020, 12:34 (6 years ago) parent951e217
3 files changed+66−9
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
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 = "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 ];
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
@@ -16074,6 +16074,8 @@ in
1607416074
1607516075 moodle = callPackage ../servers/web-apps/moodle { };
1607616076
16077+ moodle-utils = callPackage ../servers/web-apps/moodle/moodle-utils.nix { };
16078+
1607716079 morty = callPackage ../servers/web-apps/morty { };
1607816080
1607916081 mullvad-vpn = callPackage ../applications/networking/mullvad-vpn { };