]> git.immae.eu Git - perso/Immae/Config/Nix.git/blobdiff - pkgs/webapps/mediagoblin/default.nix
Use new withPlugin system
[perso/Immae/Config/Nix.git] / pkgs / webapps / mediagoblin / default.nix
index c20bcb4230e2a188c33f009a050b2869f8079907..d348ce1fd3f9bf8849506052efc73e910b9a6e37 100644 (file)
@@ -1,4 +1,4 @@
-{ makeWrapper, stdenv, writeScript, fetchurl, buildBowerComponents, mylibs, which, python36, gst_all_1, automake, autoconf, nodejs, nodePackages }:
+{ makeWrapper, stdenv, writeScript, fetchurl, buildBowerComponents, mylibs, which, python36, gst_all_1, automake, autoconf, nodejs, nodePackages, lib, callPackage }:
 let
   overridePython = let
     packageOverrides = self: super: {
@@ -113,18 +113,22 @@ let
     generated = ./bower-packages.nix;
     src = (mylibs.fetchedGit ./mediagoblin.json).src;
   };
-  withPlugins = plugins: package.overrideAttrs(old: {
-    name = "${old.name}-with-plugins";
-    postBuild = old.postBuild + (
-      builtins.concatStringsSep "\n" (
-        map (value: "ln -s ${value} mediagoblin/plugins/${value.pluginName}") plugins
-        )
-      );
-    passthru = old.passthru // {
-      inherit plugins;
-      withPlugins = morePlugins: old.withPlugins (morePlugins ++ plugins);
-    };
-  });
+  pluginNames = [ "basicsearch" ];
+  allPlugins = lib.attrsets.genAttrs pluginNames
+    (name: callPackage (./plugins + "/${name}") {});
+  toPassthru = pkg: {
+    inherit allPlugins;
+    withPlugins = withPlugins pkg;
+  };
+  withPlugins = pkg: toPlugins:
+    let
+      plugins = toPlugins allPlugins;
+      toBuildPlugin = n: "ln -s ${n} mediagoblin/plugins/${n.pluginName}";
+      newMediagoblin = pkg.overrideAttrs(old: {
+        postBuild = old.postBuild + "\n" + builtins.concatStringsSep "\n" (map toBuildPlugin plugins);
+        passthru = toPassthru newMediagoblin;
+      });
+    in newMediagoblin;
   package = stdenv.mkDerivation (mylibs.fetchedGit ./mediagoblin.json // rec {
     preConfigure = ''
       # ./bootstrap.sh
@@ -173,9 +177,6 @@ let
       '';
     buildInputs = [ makeWrapper automake autoconf which nodePackages.bower nodejs python ];
     propagatedBuildInputs = with gst_all_1; [ python gst-libav gst-plugins-good gst-plugins-bad gst-plugins-ugly gstreamer ];
-    passthru = {
-      plugins = [];
-      inherit withPlugins;
-    };
+    passthru = toPassthru package;
   });
 in package