about summary refs log tree commit diff
path: root/pkgs/development/haskell-modules
diff options
context:
space:
mode:
authorShea Levy <shea@shealevy.com>2018-01-10 12:46:45 -0500
committerShea Levy <shea@shealevy.com>2018-01-10 12:46:45 -0500
commitfb2b6ac373a5faf560f1a5daf085df35ced5205e (patch)
tree9f7f613f4b47c2d341fe4bf7a493010760410082 /pkgs/development/haskell-modules
parent80cb0c39de929f7e8e65d587cb22af777db98bea (diff)
downloadnixlib-fb2b6ac373a5faf560f1a5daf085df35ced5205e.tar
nixlib-fb2b6ac373a5faf560f1a5daf085df35ced5205e.tar.gz
nixlib-fb2b6ac373a5faf560f1a5daf085df35ced5205e.tar.bz2
nixlib-fb2b6ac373a5faf560f1a5daf085df35ced5205e.tar.lz
nixlib-fb2b6ac373a5faf560f1a5daf085df35ced5205e.tar.xz
nixlib-fb2b6ac373a5faf560f1a5daf085df35ced5205e.tar.zst
nixlib-fb2b6ac373a5faf560f1a5daf085df35ced5205e.zip
callCabal2nix: Use cleanSourceWith for composable filtering
Diffstat (limited to 'pkgs/development/haskell-modules')
-rw-r--r--pkgs/development/haskell-modules/make-package-set.nix28
1 files changed, 10 insertions, 18 deletions
diff --git a/pkgs/development/haskell-modules/make-package-set.nix b/pkgs/development/haskell-modules/make-package-set.nix
index f85259e699bc..5a2f7fb89f0d 100644
--- a/pkgs/development/haskell-modules/make-package-set.nix
+++ b/pkgs/development/haskell-modules/make-package-set.nix
@@ -142,24 +142,16 @@ in package-set { inherit pkgs stdenv callPackage; } self // {
     callHackage = name: version: self.callPackage (self.hackage2nix name version);
 
     # Creates a Haskell package from a source package by calling cabal2nix on the source.
-    callCabal2nix = name: src: args: if builtins.typeOf src != "path"
-      then self.callPackage (haskellSrc2nix { inherit name src; }) args
-      else
-        # When `src` is a Nix path literal, only use `cabal2nix` on
-        # the cabal file, so that the "import-from-derivation" is only
-        # recomputed when the cabal file changes, and so your source
-        # code isn't duplicated into the nix store on every change.
-        # This can only be done when `src` is a Nix path literal
-        # because that is the only kind of source that
-        # `builtins.filterSource` works on. But this filtering isn't
-        # usually important on other kinds of sources, like
-        # `fetchFromGitHub`.
-        overrideCabal (self.callPackage (haskellSrc2nix {
-          inherit name;
-          src = builtins.filterSource (path: type:
-            pkgs.lib.hasSuffix "${name}.cabal" path || pkgs.lib.hasSuffix "package.yaml" path
-          ) src;
-        }) args) (_: { inherit src; });
+    callCabal2nix = name: src: args:
+      overrideCabal (self.callPackage (haskellSrc2nix {
+        inherit name;
+        src = pkgs.lib.cleanSourceWith
+          { inherit src;
+            filter = path: type:
+              pkgs.lib.hasSuffix "${name}.cabal" path ||
+              pkgs.lib.hasSuffix "package.yaml" path;
+          };
+      }) args) (_: { inherit src; });
 
     # : Map Name (Either Path VersionNumber) -> HaskellPackageOverrideSet
     # Given a set whose values are either paths or version strings, produces