From 155dfe385eca240c31fd4deaa9e92fd77aa31225 Mon Sep 17 00:00:00 2001 From: Will Fancher Date: Sun, 25 Mar 2018 03:12:28 -0400 Subject: [PATCH] callHackage: Keep deriver, like callCabal2nix --- .../haskell-modules/make-package-set.nix | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/pkgs/development/haskell-modules/make-package-set.nix b/pkgs/development/haskell-modules/make-package-set.nix index 9912d1bcde28..bde4f85f6784 100644 --- a/pkgs/development/haskell-modules/make-package-set.nix +++ b/pkgs/development/haskell-modules/make-package-set.nix @@ -136,13 +136,26 @@ let src = "${component}/${name}.cabal"; }; + # Adds a nix file as an input to the haskell derivation it + # produces. This is useful for callHackage / callCabal2nix to + # prevent the generated default.nix from being garbage collected + # (requiring it to be frequently rebuilt), which can be an + # annoyance. + callPackageKeepDeriver = src: args: + overrideCabal (self.callPackage src args) (orig: { + preConfigure = '' + # Generated from ${src} + ${orig.preConfigure or ""} + ''; + }); + in package-set { inherit pkgs stdenv callPackage; } self // { inherit mkDerivation callPackage haskellSrc2nix hackage2nix; inherit (haskellLib) packageSourceOverrides; - callHackage = name: version: self.callPackage (self.hackage2nix name version); + callHackage = name: version: callPackageKeepDeriver (self.hackage2nix name version); # Creates a Haskell package from a source package by calling cabal2nix on the source. callCabal2nix = name: src: args: let @@ -155,10 +168,8 @@ in package-set { inherit pkgs stdenv callPackage; } self // { then pkgs.lib.cleanSourceWith { inherit src filter; } else src; }; - in overrideCabal (self.callPackage expr args) (orig: { + in overrideCabal (callPackageKeepDeriver expr args) (orig: { inherit src; - preConfigure = - "# Generated from ${expr}\n${orig.preConfigure or ""}"; }); # : { root : Path