]> git.immae.eu Git - perso/Immae/Config/Nix.git/blobdiff - pkgs/webapps/mantisbt_2/default.nix
Use new withPlugin system
[perso/Immae/Config/Nix.git] / pkgs / webapps / mantisbt_2 / default.nix
index bb2aad354c19dde76517301bef72e473c4417d3a..5aa04d1b4574165bd07be60139a0d00dad2a67c3 100644 (file)
@@ -1,20 +1,25 @@
-{ mantis_config ? "/etc/mantisbt/config_inc.php", stdenv, fetchurl }:
+{ mantis_config ? "/etc/mantisbt/config_inc.php", stdenv, fetchurl, lib, callPackage}:
 let
-  withPlugins = plugins: package.overrideAttrs(old: {
-    name = "${old.name}-with-plugins";
-    installPhase = old.installPhase + (
-      builtins.concatStringsSep "\n" (
-        map (value: if builtins.hasAttr "selector" value then
-            "ln -sf ${value}/${value.selector} $out/plugins/"
-          else
-            "ln -sf ${value} $out/plugins/${value.pluginName}"
-        ) plugins
-      ));
-    passthru = old.passthru // {
-      inherit plugins;
-      withPlugins = morePlugins: old.withPlugins (morePlugins ++ plugins);
-    };
-  });
+  pluginNames = [ "slack" "source-integration" ];
+  allPlugins = lib.attrsets.genAttrs pluginNames
+    (name: callPackage (./plugins + "/${name}") {});
+  toPassthru = pkg: plugins: {
+    inherit plugins allPlugins;
+    withPlugins = withPlugins pkg;
+  };
+  withPlugins = pkg: toPlugins:
+    let
+      plugins = toPlugins allPlugins;
+      toInstallPlugin = n:
+        if builtins.hasAttr "selector" n then
+          "ln -sf ${n}/${n.selector} $out/plugins/"
+        else
+          "ln -sf ${n} $out/plugins/${n.pluginName}";
+      newMantisbt = pkg.overrideAttrs(old: {
+        installPhase = old.installPhase + "\n" + builtins.concatStringsSep "\n" (map toInstallPlugin plugins);
+        passthru = toPassthru newMantisbt (pkg.plugins ++ plugins);
+      });
+    in newMantisbt;
   package = stdenv.mkDerivation rec {
     name = "mantisbt-${version}";
     version = "2.21.0";
@@ -33,9 +38,6 @@ let
     ln -s ${mantis_config} $out/config/config_inc.php
     '';
 
-    passthru = {
-      plugins = [];
-      inherit withPlugins;
-    };
+    passthru = toPassthru package [];
   };
 in package