nixos/moodle: add plugins

This commit is contained in:
Finn Behrens 2020-06-18 12:34:31 +02:00
parent 951e2175c3
commit 7561a3dc4a
No known key found for this signature in database
GPG Key ID: 8609A7B519E5E342
3 changed files with 66 additions and 9 deletions

View File

@ -1,23 +1,23 @@
{ stdenv, fetchurl, writeText }:
{ lib, stdenv, fetchurl, writeText, plugins ? [ ] }:
let
version = "3.9.1";
stableVersion = builtins.substring 0 2 (builtins.replaceStrings ["."] [""] version);
in
stdenv.mkDerivation rec {
in stdenv.mkDerivation rec {
pname = "moodle";
inherit version;
src = fetchurl {
url = "https://download.moodle.org/stable${stableVersion}/${pname}-${version}.tgz";
sha256 = "1ysnrk013gmc21ml3jwijvl16rx3p478a4vriy6h8hfli48460p9";
url =
"https://download.moodle.org/stable${stableVersion}/${pname}-${version}.tgz";
sha256 = "dffe8c1ac68938f50a987b46b0bfc74f01235d0198ac96fb4fc4f1df5bd7f4ea";
};
phpConfig = writeText "config.php" ''
<?php
return require(getenv('MOODLE_CONFIG'));
?>
<?php
return require(getenv('MOODLE_CONFIG'));
?>
'';
installPhase = ''
@ -27,11 +27,34 @@ stdenv.mkDerivation rec {
cp -r . $out/share/moodle
cp ${phpConfig} $out/share/moodle/config.php
${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)}
runHook postInstall
'';
meta = with stdenv.lib; {
description = "Free and open-source learning management system (LMS) written in PHP";
description =
"Free and open-source learning management system (LMS) written in PHP";
license = licenses.gpl3Plus;
homepage = "https://moodle.org/";
maintainers = with maintainers; [ aanderse ];

View File

@ -0,0 +1,32 @@
{ stdenv, unzip, ... }:
let
buildMoodlePlugin = a@{
name,
src,
pluginType,
configuraPhase ? ":",
buildPhase ? ":",
buildInputs ? [ ],
...
}:
stdenv.mkDerivation (a // {
name = name;
inherit pluginType;
inherit configuraPhase buildPhase;
buildInputs = [ unzip ] ++ buildInputs;
installPhase = ''
runHook preInstall
mkdir -p "$out"
mv * $out/
runHook postInstall
'';
});
in {
inherit buildMoodlePlugin;
}

View File

@ -16074,6 +16074,8 @@ in
moodle = callPackage ../servers/web-apps/moodle { };
moodle-utils = callPackage ../servers/web-apps/moodle/moodle-utils.nix { };
morty = callPackage ../servers/web-apps/morty { };
mullvad-vpn = callPackage ../applications/networking/mullvad-vpn { };