aboutsummaryrefslogblamecommitdiff
path: root/pkgs/webapps/dokuwiki/default.nix
blob: 874f0d87696f69b2ba6d4a21006414dedf2eead1 (plain) (tree)
1
2
3
4
5
6
7
8
                                                                                            






                                                                                              



















                                                                                                              













                                                                                  
                                     

          
{ varDir ? "/var/lib/dokuwiki", preload ? "", lib, callPackage, 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
    );
  pluginNames = [ "farmer" "todo" ];
  allPlugins = lib.attrsets.genAttrs pluginNames
    (name: callPackage (./plugins + "/${name}.nix") {});
  toPassthru = pkg: plugins: {
    inherit plugins varDir allPlugins;
    withPlugins = withPlugins pkg;
  };
  withPlugins = pkg: toPlugins:
    let
      plugins = toPlugins allPlugins;
      toInstallPlugin = n:
        "ln -sf ${n} $out/lib/plugins/${n.pluginName}";
      newDokuwiki = pkg.overrideAttrs(old: {
        installPhase = old.installPhase + "\n" + builtins.concatStringsSep "\n" (map toInstallPlugin plugins);
        installPreloadPhase = ''
          cp ${preloadFile (pkg.plugins ++ plugins)} $out/inc/preload.php
        '';
        passthru = toPassthru newDokuwiki (pkg.plugins ++ plugins);
      });
    in newDokuwiki;
  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 = toPassthru package [];
  });
in package