]> git.immae.eu Git - perso/Immae/Config/Nix.git/blob - pkgs/webapps/dokuwiki/default.nix
Switch to colemna
[perso/Immae/Config/Nix.git] / pkgs / webapps / dokuwiki / default.nix
1 { varDir ? "/var/lib/dokuwiki", preload ? "", lib, callPackage, stdenv, mylibs, writeText }:
2 let
3 preloadFile = plugins: let preloads = [preload]
4 ++ builtins.concatMap (p: lib.optional (lib.hasAttr "preload" p) (p.preload p)) plugins;
5 in writeText "preload.php" (''
6 <?php
7 '' + builtins.concatStringsSep "\n" preloads
8 );
9 pluginNames = [ "farmer" "todo" ];
10 allPlugins = lib.attrsets.genAttrs pluginNames
11 (name: callPackage (./plugins + "/${name}.nix") {});
12 toPassthru = pkg: plugins: {
13 inherit plugins varDir allPlugins;
14 withPlugins = withPlugins pkg;
15 };
16 withPlugins = pkg: toPlugins:
17 let
18 plugins = toPlugins allPlugins;
19 toInstallPlugin = n:
20 "ln -sf ${n} $out/lib/plugins/${n.pluginName}";
21 newDokuwiki = pkg.overrideAttrs(old: {
22 installPhase = old.installPhase + "\n" + builtins.concatStringsSep "\n" (map toInstallPlugin plugins);
23 installPreloadPhase = ''
24 cp ${preloadFile (pkg.plugins ++ plugins)} $out/inc/preload.php
25 '';
26 passthru = toPassthru newDokuwiki (pkg.plugins ++ plugins);
27 });
28 in newDokuwiki;
29 package = stdenv.mkDerivation (mylibs.fetchedGithub ./dokuwiki.json // rec {
30 phases = "unpackPhase buildPhase installPhase installPreloadPhase fixupPhase";
31 buildPhase = ''
32 mv conf conf.dist
33 mv data data.dist
34 '';
35 installPhase = ''
36 cp -a . $out
37 ln -sf ${varDir}/{conf,data} $out/
38 ln -sf ${varDir}/conf/.htaccess $out/
39 '';
40 installPreloadPhase = ''
41 cp ${preloadFile []} $out/inc/preload.php
42 '';
43 passthru = toPassthru package [];
44 });
45 in package