diff options
author | Moritz 'e1mo' Fromm <git@e1mo.de> | 2023-01-06 00:14:43 +0100 |
---|---|---|
committer | Moritz 'e1mo' Fromm <git@e1mo.de> | 2023-01-06 23:52:49 +0100 |
commit | ee41b6b45713ccd327eedc3e50d5d58580571638 (patch) | |
tree | 1ea6a8831cd4394d0c933901444ef2a39e4a40d9 | |
parent | cff8fd9c6cfefadd5ceea6717c03c66fdee235f8 (diff) | |
download | nixpkgs-ee41b6b45713ccd327eedc3e50d5d58580571638.tar nixpkgs-ee41b6b45713ccd327eedc3e50d5d58580571638.tar.gz nixpkgs-ee41b6b45713ccd327eedc3e50d5d58580571638.tar.bz2 nixpkgs-ee41b6b45713ccd327eedc3e50d5d58580571638.tar.lz nixpkgs-ee41b6b45713ccd327eedc3e50d5d58580571638.tar.xz nixpkgs-ee41b6b45713ccd327eedc3e50d5d58580571638.tar.zst nixpkgs-ee41b6b45713ccd327eedc3e50d5d58580571638.zip |
dokuwiki: Combine mechanism for plugins and templates
Copy templates and plugins into Dokuwiki instead of linking to address template compatibility. As noted by @sinavir[^1], (some) templates would fail due to relative PHP imports. [^1]: https://github.com/NixOS/nixpkgs/pull/208299#issuecomment-1370413116
-rw-r--r-- | nixos/modules/services/web-apps/dokuwiki.nix | 26 | ||||
-rw-r--r-- | nixos/tests/dokuwiki.nix | 8 | ||||
-rw-r--r-- | pkgs/servers/web-apps/dokuwiki/default.nix | 38 |
3 files changed, 50 insertions, 22 deletions
diff --git a/nixos/modules/services/web-apps/dokuwiki.nix b/nixos/modules/services/web-apps/dokuwiki.nix index d90dd8ace41..08eb8bdfba9 100644 --- a/nixos/modules/services/web-apps/dokuwiki.nix +++ b/nixos/modules/services/web-apps/dokuwiki.nix @@ -73,28 +73,16 @@ let ${if isString pc then pc else pc_gen pc} ''; - pkg = hostName: cfg: pkgs.stdenv.mkDerivation rec { - pname = "dokuwiki-${hostName}"; - version = src.version; - src = cfg.package; - installPhase = '' - mkdir -p $out - cp -r * $out/ + pkg = hostName: cfg: cfg.package.combine { + inherit (cfg) plugins templates; - # symlink the dokuwiki config - ln -sf ${dokuwikiLocalConfig hostName cfg} $out/share/dokuwiki/conf/local.php + pname = p: "${p.pname}-${hostName}"; - # symlink plugins config - ln -sf ${dokuwikiPluginsLocalConfig hostName cfg} $out/share/dokuwiki/conf/plugins.local.php - - # symlink acl (if needed) - ${optionalString (cfg.mergedConfig.useacl && cfg.acl != null) "ln -sf ${dokuwikiAclAuthConfig hostName cfg} $out/share/dokuwiki/acl.auth.php"} - - # symlink additional plugin(s) and templates(s) - ${concatMapStringsSep "\n" (template: "ln -sf ${template} $out/share/dokuwiki/lib/tpl/${template.name}") cfg.templates} - ${concatMapStringsSep "\n" (plugin: "ln -sf ${plugin} $out/share/dokuwiki/lib/plugins/${plugin.name}") cfg.plugins} - ''; + basePackage = cfg.package; + localConfig = dokuwikiLocalConfig hostName cfg; + pluginsConfig = dokuwikiPluginsLocalConfig hostName cfg; + aclConfig = if cfg.aclUse && cfg.acl != null then dokuwikiAclAuthConfig hostName cfg else null; }; aclOpts = { ... }: { diff --git a/nixos/tests/dokuwiki.nix b/nixos/tests/dokuwiki.nix index 034d6f94af2..c22e751c8c8 100644 --- a/nixos/tests/dokuwiki.nix +++ b/nixos/tests/dokuwiki.nix @@ -142,6 +142,14 @@ in { "curl -sSfL 'http://site2.local/doku.php?id=plugin-list' | (! grep 'plugin:tag')", ) + # Test if theme is applied and working correctly (no weired relative PHP import errors) + machine.succeed( + "curl -sSfL 'http://site1.local/doku.php' | grep 'bootstrap3/images/logo.png'", + "curl -sSfL 'http://site1.local/lib/exe/css.php' | grep 'bootstrap3'", + "curl -sSfL 'http://site1.local/lib/tpl/bootstrap3/css.php'", + ) + + # Just to ensure both Webserver configurations are consistent in allowing that with subtest("Rewriting"): machine.succeed( diff --git a/pkgs/servers/web-apps/dokuwiki/default.nix b/pkgs/servers/web-apps/dokuwiki/default.nix index e77defae33a..b3a485113fa 100644 --- a/pkgs/servers/web-apps/dokuwiki/default.nix +++ b/pkgs/servers/web-apps/dokuwiki/default.nix @@ -1,4 +1,10 @@ -{ lib, stdenv, fetchFromGitHub, writeText, nixosTests }: +{ lib +, stdenv +, fetchFromGitHub +, writeText +, nixosTests +, dokuwiki +}: stdenv.mkDerivation rec { pname = "dokuwiki"; @@ -38,15 +44,41 @@ stdenv.mkDerivation rec { ''; installPhase = '' + runHook preInstall + mkdir -p $out/share/dokuwiki cp -r * $out/share/dokuwiki cp ${preload} $out/share/dokuwiki/inc/preload.php cp ${phpLocalConfig} $out/share/dokuwiki/conf/local.php cp ${phpPluginsLocalConfig} $out/share/dokuwiki/conf/plugins.local.php + + runHook postInstall ''; - passthru.tests = { - inherit (nixosTests) dokuwiki; + passthru = { + combine = { basePackage ? dokuwiki + , plugins ? [] + , templates ? [] + , localConfig ? null + , pluginsConfig ? null + , aclConfig ? null + , pname ? (p: "${p.pname}-combined") + }: let + isNotEmpty = x: lib.optionalString (! builtins.elem x [ null "" ]); + in basePackage.overrideAttrs (prev: { + pname = if builtins.isFunction pname then pname prev else pname; + + postInstall = prev.postInstall or "" + '' + ${lib.concatMapStringsSep "\n" (tpl: "cp -r ${toString tpl} $out/share/dokuwiki/lib/tpl/${tpl.name}") templates} + ${lib.concatMapStringsSep "\n" (plugin: "cp -r ${toString plugin} $out/share/dokuwiki/lib/plugins/${plugin.name}") plugins} + ${isNotEmpty localConfig "ln -sf ${localConfig} $out/share/dokuwiki/conf/local.php" } + ${isNotEmpty pluginsConfig "ln -sf ${pluginsConfig} $out/share/dokuwiki/conf/plugins.local.php" } + ${isNotEmpty aclConfig "ln -sf ${aclConfig} $out/share/dokuwiki/acl.auth.php" } + ''; + }); + tests = { + inherit (nixosTests) dokuwiki; + }; }; meta = with lib; { |