]> git.immae.eu Git - perso/Immae/Config/Nix.git/blobdiff - pkgs/webapps/yourls/default.nix
Move yourls to pkgs
[perso/Immae/Config/Nix.git] / pkgs / webapps / yourls / default.nix
diff --git a/pkgs/webapps/yourls/default.nix b/pkgs/webapps/yourls/default.nix
new file mode 100644 (file)
index 0000000..cc880cd
--- /dev/null
@@ -0,0 +1,24 @@
+{ yourls_config ? "/etc/yourls/config.php", mylibs, stdenv }:
+let
+  withPlugins = plugins: package.overrideAttrs(old: {
+    name = "${old.name}-with-plugins";
+    installPhase = old.installPhase +
+      builtins.concatStringsSep "\n" (
+        map (value: "ln -s ${value} $out/user/plugins/${value.pluginName}") plugins
+      );
+    passthru.plugins = plugins;
+    passthru.withPlugins = morePlugins: old.withPlugins (morePlugins ++ plugins);
+  });
+  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 = {
+      plugins = [];
+      inherit withPlugins;
+    };
+  });
+in package