aboutsummaryrefslogtreecommitdiff
path: root/pkgs/webapps/yourls/default.nix
blob: d940c54d1b505ebeeadb0b876c71b726775dda9d (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
{ yourls_config ? "/etc/yourls/config.php", mylibs, callPackage, lib, stdenv }:
let
  pluginNames = [ "ldap" ];
  allPlugins = lib.attrsets.genAttrs pluginNames
    (name: callPackage (./plugins + "/${name}") { inherit mylibs; });
  toPassthru = pkg: plugins: {
    inherit plugins allPlugins;
    withPlugins = withPlugins pkg;
  };
  withPlugins = pkg: toPlugins:
    let
      plugins = toPlugins allPlugins;
      toInstallPlugin = n: "ln -s ${n} $out/user/plugins/${n.pluginName}";
      newYourls = pkg.overrideAttrs(old: {
        installPhase = old.installPhase + "\n" + builtins.concatStringsSep "\n" (map toInstallPlugin plugins);
        passthru = toPassthru newYourls (pkg.plugins ++ plugins);
      });
    in newYourls;
  package = stdenv.mkDerivation (mylibs.fetchedGithub ./yourls.json // rec {
    installPhase = ''
      mkdir -p $out
      cp -a */ *.php $out/
      cp sample-robots.txt $out/robots.txt
      ln -sf ${yourls_config} $out/includes/config.php
    '';
    passthru = toPassthru package [];
  });
in package