2022-11-27 09:42:12 +00:00
|
|
|
{ lib, stdenv, fetchurl, writeText, plugins ? [ ], nixosTests }:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
let
|
2024-02-29 20:09:43 +00:00
|
|
|
version = "4.3.3";
|
2022-09-09 14:08:57 +00:00
|
|
|
|
|
|
|
versionParts = lib.take 2 (lib.splitVersion version);
|
|
|
|
# 4.2 -> 402, 3.11 -> 311
|
|
|
|
stableVersion = lib.removePrefix "0" (lib.concatMapStrings
|
|
|
|
(p: if (lib.toInt p) < 10 then (lib.concatStrings ["0" p]) else p)
|
|
|
|
versionParts);
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2020-07-18 16:06:22 +00:00
|
|
|
in stdenv.mkDerivation rec {
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "moodle";
|
|
|
|
inherit version;
|
|
|
|
|
|
|
|
src = fetchurl {
|
2023-10-09 19:29:22 +00:00
|
|
|
url = "https://download.moodle.org/download.php/direct/stable${stableVersion}/${pname}-${version}.tgz";
|
2024-02-29 20:09:43 +00:00
|
|
|
hash = "sha256-yFrD277bO25O5GeXVG4VhKO/oH9dsgqoTsrlMZoXHbI=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
phpConfig = writeText "config.php" ''
|
2020-07-18 16:06:22 +00:00
|
|
|
<?php
|
|
|
|
return require(getenv('MOODLE_CONFIG'));
|
|
|
|
?>
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
|
|
|
|
|
|
|
mkdir -p $out/share/moodle
|
|
|
|
cp -r . $out/share/moodle
|
|
|
|
cp ${phpConfig} $out/share/moodle/config.php
|
|
|
|
|
2020-07-18 16:06:22 +00:00
|
|
|
${lib.concatStringsSep "\n" (map (p:
|
|
|
|
let
|
|
|
|
dir = if p.pluginType == "mod" then
|
|
|
|
"mod"
|
|
|
|
else if p.pluginType == "theme" then
|
|
|
|
"theme"
|
|
|
|
else if p.pluginType == "block" then
|
|
|
|
"blocks"
|
|
|
|
else if p.pluginType == "question" then
|
|
|
|
"question/type"
|
|
|
|
else if p.pluginType == "course" then
|
|
|
|
"course/format"
|
|
|
|
else if p.pluginType == "report" then
|
|
|
|
"admin/report"
|
|
|
|
else
|
|
|
|
throw "unknown moodle plugin type";
|
|
|
|
# we have to copy it, because the plugins have refrences to .. inside
|
|
|
|
in ''
|
|
|
|
mkdir -p $out/share/moodle/${dir}/${p.name}
|
|
|
|
cp -r ${p}/* $out/share/moodle/${dir}/${p.name}/
|
|
|
|
'') plugins)}
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
|
2022-11-27 09:42:12 +00:00
|
|
|
passthru.tests = {
|
|
|
|
inherit (nixosTests) moodle;
|
|
|
|
};
|
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
meta = with lib; {
|
2020-07-18 16:06:22 +00:00
|
|
|
description =
|
|
|
|
"Free and open-source learning management system (LMS) written in PHP";
|
2020-04-24 23:36:52 +00:00
|
|
|
license = licenses.gpl3Plus;
|
|
|
|
homepage = "https://moodle.org/";
|
2020-10-07 09:15:18 +00:00
|
|
|
maintainers = with maintainers; [ freezeboy ];
|
2020-04-24 23:36:52 +00:00
|
|
|
platforms = platforms.all;
|
|
|
|
};
|
|
|
|
}
|