]> git.immae.eu Git - perso/Immae/Config/Nix.git/blobdiff - pkgs/webapps/ttrss/default.nix
Use new withPlugin system
[perso/Immae/Config/Nix.git] / pkgs / webapps / ttrss / default.nix
index 0ce2f94fd5c78ce400b502402e38feb6592065b3..38200a1b3365f0e49843b0c13c8137397f4f24ee 100644 (file)
@@ -1,30 +1,33 @@
 { ttrss_config ? "/etc/ttrss/config.php"
 , varDir ? "/var/lib/ttrss"
-, stdenv, mylibs }:
+, stdenv, mylibs, lib, callPackage }:
 let
-  withPlugins = plugins: package.overrideAttrs(old: rec {
-    name = "${old.name}-with-plugins";
-    installPhase = old.installPhase +
-      builtins.concatStringsSep "\n" (
-        map (value: "ln -s ${value} $out/plugins/${value.pluginName}") plugins
-      );
-    passthru = old.passthru // {
-      inherit plugins;
-      withPlugins = morePlugins: old.withPlugins (morePlugins ++ plugins);
-    };
-  });
+  pluginNames = [ "auth_ldap" "af_feedmod" "feediron" "ff_instagram" "tumblr_gdpr_ua" ];
+  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:
+        "ln -sf ${n} $out/plugins/${n.pluginName}";
+      newTtrss = pkg.overrideAttrs(old: {
+        installPhase = old.installPhase + "\n" + builtins.concatStringsSep "\n" (map toInstallPlugin plugins);
+        passthru = toPassthru newTtrss (pkg.plugins ++ plugins);
+      });
+    in newTtrss;
   package = stdenv.mkDerivation (mylibs.fetchedGit ./tt-rss.json // rec {
     buildPhase = ''
       rm -rf lock feed-icons cache
       ln -sf ${varDir}/{lock,feed-icons,cache} .
-      '';
-      installPhase = ''
-        cp -a . $out
-        ln -s ${ttrss_config} $out/config.php
-      '';
-    passthru = {
-      plugins = [];
-      inherit withPlugins;
-    };
+    '';
+    installPhase = ''
+      cp -a . $out
+      ln -s ${ttrss_config} $out/config.php
+    '';
+    passthru = toPassthru package [];
   });
 in package