nixpkgs/pkgs/servers/web-apps/moodle/default.nix

64 lines
1.7 KiB
Nix
Raw Normal View History

2020-06-18 11:34:31 +01:00
{ lib, stdenv, fetchurl, writeText, plugins ? [ ] }:
2019-06-19 11:23:43 +01:00
let
2021-08-18 18:12:43 +01:00
version = "3.11.2";
2020-11-02 12:28:06 +00:00
stableVersion = lib.concatStrings (lib.take 2 (lib.splitVersion version));
2019-06-19 11:23:43 +01:00
2020-06-18 11:34:31 +01:00
in stdenv.mkDerivation rec {
2019-06-19 11:23:43 +01:00
pname = "moodle";
inherit version;
src = fetchurl {
2020-06-18 11:34:31 +01:00
url =
"https://download.moodle.org/stable${stableVersion}/${pname}-${version}.tgz";
2021-08-18 18:12:43 +01:00
sha256 = "sha256-owe/8CVz7+uBrHJQDN4csWVcdk49AvT1ip88lAe/tKg=";
2019-06-19 11:23:43 +01:00
};
phpConfig = writeText "config.php" ''
2020-06-18 11:34:31 +01:00
<?php
return require(getenv('MOODLE_CONFIG'));
?>
2019-06-19 11:23:43 +01:00
'';
installPhase = ''
runHook preInstall
mkdir -p $out/share/moodle
cp -r . $out/share/moodle
cp ${phpConfig} $out/share/moodle/config.php
2020-06-18 11:34:31 +01: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)}
2019-06-19 11:23:43 +01:00
runHook postInstall
'';
meta = with lib; {
2020-06-18 11:34:31 +01:00
description =
"Free and open-source learning management system (LMS) written in PHP";
2019-06-19 11:23:43 +01:00
license = licenses.gpl3Plus;
homepage = "https://moodle.org/";
2020-09-26 07:52:11 +01:00
maintainers = with maintainers; [ freezeboy ];
2019-06-19 11:23:43 +01:00
platforms = platforms.all;
};
}