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
This commit is contained in:
Moritz 'e1mo' Fromm 2023-01-06 00:14:43 +01:00
parent cff8fd9c6c
commit ee41b6b457
No known key found for this signature in database
GPG key ID: 1D5D79A439E787F1
3 changed files with 50 additions and 22 deletions

View file

@ -73,28 +73,16 @@ let
${if isString pc then pc else pc_gen pc} ${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 = '' pkg = hostName: cfg: cfg.package.combine {
mkdir -p $out inherit (cfg) plugins templates;
cp -r * $out/
# symlink the dokuwiki config pname = p: "${p.pname}-${hostName}";
ln -sf ${dokuwikiLocalConfig hostName cfg} $out/share/dokuwiki/conf/local.php
# symlink plugins config basePackage = cfg.package;
ln -sf ${dokuwikiPluginsLocalConfig hostName cfg} $out/share/dokuwiki/conf/plugins.local.php localConfig = dokuwikiLocalConfig hostName cfg;
pluginsConfig = dokuwikiPluginsLocalConfig hostName cfg;
# symlink acl (if needed) aclConfig = if cfg.aclUse && cfg.acl != null then dokuwikiAclAuthConfig hostName cfg else null;
${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}
'';
}; };
aclOpts = { ... }: { aclOpts = { ... }: {

View file

@ -142,6 +142,14 @@ in {
"curl -sSfL 'http://site2.local/doku.php?id=plugin-list' | (! grep 'plugin:tag')", "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 # Just to ensure both Webserver configurations are consistent in allowing that
with subtest("Rewriting"): with subtest("Rewriting"):
machine.succeed( machine.succeed(

View file

@ -1,4 +1,10 @@
{ lib, stdenv, fetchFromGitHub, writeText, nixosTests }: { lib
, stdenv
, fetchFromGitHub
, writeText
, nixosTests
, dokuwiki
}:
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
pname = "dokuwiki"; pname = "dokuwiki";
@ -38,15 +44,41 @@ stdenv.mkDerivation rec {
''; '';
installPhase = '' installPhase = ''
runHook preInstall
mkdir -p $out/share/dokuwiki mkdir -p $out/share/dokuwiki
cp -r * $out/share/dokuwiki cp -r * $out/share/dokuwiki
cp ${preload} $out/share/dokuwiki/inc/preload.php cp ${preload} $out/share/dokuwiki/inc/preload.php
cp ${phpLocalConfig} $out/share/dokuwiki/conf/local.php cp ${phpLocalConfig} $out/share/dokuwiki/conf/local.php
cp ${phpPluginsLocalConfig} $out/share/dokuwiki/conf/plugins.local.php cp ${phpPluginsLocalConfig} $out/share/dokuwiki/conf/plugins.local.php
runHook postInstall
''; '';
passthru.tests = { passthru = {
inherit (nixosTests) dokuwiki; 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; { meta = with lib; {