hackens-org-configurations/shared/dokuwiki.nix

95 lines
2.7 KiB
Nix
Raw Normal View History

2023-01-12 18:11:50 +01:00
{ lib
, stdenv
, fetchFromGitHub
, writeText
, nixosTests
, dokuwiki
}:
stdenv.mkDerivation rec {
pname = "dokuwiki";
version = "2022-07-31a";
src = fetchFromGitHub {
owner = "splitbrain";
repo = pname;
rev = "release_stable_${version}";
sha256 = "sha256-gtWEtc3kbMokKycTx71XXblkDF39i926uN2kU3oOeVw=";
};
preload = writeText "preload.php" ''
2023-02-24 14:43:35 +01:00
<?php
2023-01-12 18:11:50 +01:00
2023-02-24 14:43:35 +01:00
$config_cascade = array(
'acl' => array(
'default' => getenv('DOKUWIKI_ACL_AUTH_CONFIG'),
),
'plainauth.users' => array(
'default' => getenv('DOKUWIKI_USERS_AUTH_CONFIG'),
'protected' => "" // not used by default
),
);
2023-01-12 18:11:50 +01:00
'';
phpLocalConfig = writeText "local.php" ''
2023-02-24 14:43:35 +01:00
<?php
return require(getenv('DOKUWIKI_LOCAL_CONFIG'));
?>
2023-01-12 18:11:50 +01:00
'';
phpPluginsLocalConfig = writeText "plugins.local.php" ''
2023-02-24 14:43:35 +01:00
<?php
return require(getenv('DOKUWIKI_PLUGINS_LOCAL_CONFIG'));
?>
2023-01-12 18:11:50 +01:00
'';
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 = {
2023-02-24 14:43:35 +01:00
combine =
{ basePackage ? dokuwiki
, plugins ? [ ]
, templates ? [ ]
2023-01-12 18:11:50 +01:00
, localConfig ? null
, pluginsConfig ? null
, aclConfig ? null
, pname ? (p: "${p.pname}-combined")
2023-02-24 14:43:35 +01:00
}:
let
isNotEmpty = x: lib.optionalString (! builtins.elem x [ null "" ]);
in
basePackage.overrideAttrs (prev: {
pname = if builtins.isFunction pname then pname prev else pname;
2023-01-12 18:11:50 +01:00
2023-02-24 14:43:35 +01:00
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" }
'';
});
2023-01-12 18:11:50 +01:00
tests = {
inherit (nixosTests) dokuwiki;
};
};
meta = with lib; {
description = "Simple to use and highly versatile Open Source wiki software that doesn't require a database";
license = licenses.gpl2;
homepage = "https://www.dokuwiki.org";
platforms = platforms.all;
maintainers = with maintainers; [ _1000101 ];
};
}