Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: bae6984c2178
Choose a base ref
...
head repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: b6eca9a2afa1
Choose a head ref
  • 3 commits
  • 4 files changed
  • 2 contributors

Commits on Jul 16, 2020

  1. nixos/moodle: add plugins

    kloenk committed Jul 16, 2020
    Copy the full SHA
    7561a3d View commit details
  2. moodle: update to 3.9.1

    use phpEnv to provide xmlrpc
    kloenk committed Jul 16, 2020
    Copy the full SHA
    832d228 View commit details

Commits on Jul 17, 2020

  1. Merge pull request #93104 from Kloenk/moodle-plugins

    nixos/moodle: add plugins
    Lassulus authored Jul 17, 2020
    Copy the full SHA
    b6eca9a View commit details
Showing with 75 additions and 14 deletions.
  1. +9 −5 nixos/modules/services/web-apps/moodle.nix
  2. +32 −9 pkgs/servers/web-apps/moodle/default.nix
  3. +32 −0 pkgs/servers/web-apps/moodle/moodle-utils.nix
  4. +2 −0 pkgs/top-level/all-packages.nix
14 changes: 9 additions & 5 deletions nixos/modules/services/web-apps/moodle.nix
Original file line number Diff line number Diff line change
@@ -40,7 +40,7 @@ let
$CFG->disableupdateautodeploy = true;
$CFG->pathtogs = '${pkgs.ghostscript}/bin/gs';
$CFG->pathtophp = '${pkgs.php}/bin/php';
$CFG->pathtophp = '${phpExt}/bin/php';
$CFG->pathtodu = '${pkgs.coreutils}/bin/du';
$CFG->aspellpath = '${pkgs.aspell}/bin/aspell';
$CFG->pathtodot = '${pkgs.graphviz}/bin/dot';
@@ -55,6 +55,9 @@ let

mysqlLocal = cfg.database.createLocally && cfg.database.type == "mysql";
pgsqlLocal = cfg.database.createLocally && cfg.database.type == "pgsql";

phpExt = pkgs.php.withExtensions
({ enabled, all }: with all; [ iconv mbstring curl openssl tokenizer xmlrpc soap ctype zip gd simplexml dom intl json sqlite3 pgsql pdo_sqlite pdo_pgsql pdo_odbc pdo_mysql pdo mysqli session zlib xmlreader fileinfo ]);
in
{
# interface
@@ -222,6 +225,7 @@ in

services.phpfpm.pools.moodle = {
inherit user group;
phpPackage = phpExt;
phpEnv.MOODLE_CONFIG = "${moodleConfig}";
phpOptions = ''
zend_extension = opcache.so
@@ -263,13 +267,13 @@ in
after = optional mysqlLocal "mysql.service" ++ optional pgsqlLocal "postgresql.service";
environment.MOODLE_CONFIG = moodleConfig;
script = ''
${pkgs.php}/bin/php ${cfg.package}/share/moodle/admin/cli/check_database_schema.php && rc=$? || rc=$?
${phpExt}/bin/php ${cfg.package}/share/moodle/admin/cli/check_database_schema.php && rc=$? || rc=$?
[ "$rc" == 1 ] && ${pkgs.php}/bin/php ${cfg.package}/share/moodle/admin/cli/upgrade.php \
[ "$rc" == 1 ] && ${phpExt}/bin/php ${cfg.package}/share/moodle/admin/cli/upgrade.php \
--non-interactive \
--allow-unstable
[ "$rc" == 2 ] && ${pkgs.php}/bin/php ${cfg.package}/share/moodle/admin/cli/install_database.php \
[ "$rc" == 2 ] && ${phpExt}/bin/php ${cfg.package}/share/moodle/admin/cli/install_database.php \
--agree-license \
--adminpass=${cfg.initialPassword}
@@ -289,7 +293,7 @@ in
serviceConfig = {
User = user;
Group = group;
ExecStart = "${pkgs.php}/bin/php ${cfg.package}/share/moodle/admin/cli/cron.php";
ExecStart = "${phpExt}/bin/php ${cfg.package}/share/moodle/admin/cli/cron.php";
};
};

41 changes: 32 additions & 9 deletions pkgs/servers/web-apps/moodle/default.nix
Original file line number Diff line number Diff line change
@@ -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 = "sha256-6QJDEInUQQSNj3kThQ65o2cT6JaRy0FrEKy+EcDMVvs=";
};

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 ];
32 changes: 32 additions & 0 deletions pkgs/servers/web-apps/moodle/moodle-utils.nix
Original file line number Diff line number Diff line change
@@ -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;
}
2 changes: 2 additions & 0 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
@@ -16060,6 +16060,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 { };