1 { lib, stdenv, fetchurl, writeText, plugins ? [ ], nixosTests }:
6 versionParts = lib.take 2 (lib.splitVersion version);
7 # 4.2 -> 402, 3.11 -> 311
8 stableVersion = lib.removePrefix "0" (lib.concatMapStrings
9 (p: if (lib.toInt p) < 10 then (lib.concatStrings ["0" p]) else p)
12 in stdenv.mkDerivation rec {
17 url = "https://download.moodle.org/download.php/direct/stable${stableVersion}/${pname}-${version}.tgz";
18 hash = "sha256-+pzDrSMm+V4pEze13mJ/eyhaxcvnmG/eno0csCRTisU=";
21 phpConfig = writeText "config.php" ''
23 return require(getenv('MOODLE_CONFIG'));
30 mkdir -p $out/share/moodle
31 cp -r . $out/share/moodle
32 cp ${phpConfig} $out/share/moodle/config.php
34 ${lib.concatStringsSep "\n" (map (p:
36 dir = if p.pluginType == "mod" then
38 else if p.pluginType == "theme" then
40 else if p.pluginType == "block" then
42 else if p.pluginType == "question" then
44 else if p.pluginType == "course" then
46 else if p.pluginType == "report" then
49 throw "unknown moodle plugin type";
50 # we have to copy it, because the plugins have refrences to .. inside
52 mkdir -p $out/share/moodle/${dir}/${p.name}
53 cp -r ${p}/* $out/share/moodle/${dir}/${p.name}/
60 inherit (nixosTests) moodle;
65 "Free and open-source learning management system (LMS) written in PHP";
66 license = licenses.gpl3Plus;
67 homepage = "https://moodle.org/";
68 maintainers = with maintainers; [ freezeboy ];
69 platforms = platforms.all;