git.iko.soy/typeable/nixpkgs
on master help sign in
callCabal2nix: Don't rebuild unchanged cabal file

It can be quite annoying that callCabal2nix will build a new derivation if anything in the source has changed, even if the cabal file hasn't.

commit24b47526ce38e3ccb073c776b32c0ea220f3c0f2 authorWill Fancher <elvishjerricco@gmail.com> dateMon 13 Mar 2017, 22:17 (10 years ago) parent64218d6
1 file changed+8−1
pkgs/development/haskell-modules/default.nix+8−1
pkgs/development/haskell-modules/default.nix+8−1
@@ -84,7 +84,14 @@ let
8484 callHackage = name: version: self.callPackage (hackage2nix name version);
8585
8686 # Creates a Haskell package from a source package by calling cabal2nix on the source.
87− callCabal2nix = name: src: self.callPackage (haskellSrc2nix { inherit src name; });
87+ callCabal2nix = name: src: args:
88+ let
89+ # Filter out files other than the cabal file. This ensures
90+ # that we don't create new derivations even when the cabal
91+ # file hasn't changed.
92+ justCabal = builtins.filterSource (path: type: pkgs.lib.hasSuffix ".cabal" path) src;
93+ drv = self.callPackage (haskellSrc2nix { inherit name; src = justCabal; }) args;
94+ in overrideCabal drv (drv': { inherit src; }); # Restore the desired src.
8895
8996 ghcWithPackages = selectFrom: withPackages (selectFrom self);
9097