aboutsummaryrefslogtreecommitdiff
path: root/pkgs/webapps/dokuwiki/default.nix
blob: 9df88c6b24ca29fa3614b37385d87c114bae1a24 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
{ varDir ? "/var/lib/dokuwiki", preload ? "", lib, stdenv, mylibs, writeText }:
let
  preloadFile = plugins: let preloads = [preload]
      ++ builtins.concatMap (p: lib.optional (lib.hasAttr "preload" p) (p.preload p)) plugins;
    in writeText "preload.php" (''
      <?php
      '' + builtins.concatStringsSep "\n" preloads
    );
  withPlugins = plugins: package.overrideAttrs(old: {
    name = "${old.name}-with-plugins";
    installPhase = old.installPhase + (
      builtins.concatStringsSep "\n" (
        map (value: "ln -sf ${value} $out/lib/plugins/${value.pluginName}") plugins
        )
      );
    installPreloadPhase = ''
      cp ${preloadFile plugins} $out/inc/preload.php
      '';
    passthru = old.passthru // {
      inherit plugins;
      withPlugins = morePlugins: old.withPlugins (morePlugins ++ plugins);
    };
  });
  package = stdenv.mkDerivation (mylibs.fetchedGithub ./dokuwiki.json // rec {
    phases = "unpackPhase buildPhase installPhase installPreloadPhase fixupPhase";
    buildPhase = ''
      mv conf conf.dist
      mv data data.dist
    '';
    installPhase = ''
      cp -a . $out
      ln -sf ${varDir}/{conf,data} $out/
      ln -sf ${varDir}/conf/.htaccess $out/
    '';
    installPreloadPhase = ''
      cp ${preloadFile []} $out/inc/preload.php
      '';
    passthru = {
      plugins = [];
      inherit withPlugins varDir;
    };
  });
in package