summaryrefslogtreecommitdiffstats
path: root/pkgs
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/haskell/default.nix19
1 files changed, 18 insertions, 1 deletions
diff --git a/pkgs/haskell/default.nix b/pkgs/haskell/default.nix
index 68b79b8c..73c917e4 100644
--- a/pkgs/haskell/default.nix
+++ b/pkgs/haskell/default.nix
@@ -21,6 +21,23 @@ self: super: let
inherit name src;
removeNames = [ ".git" ".graveyard" "dist-newstyle" ];
};
+
+ # An automatic package, from the checkout's cabal.nix if it has one,
+ # else from cabal2nix run during evaluation. cabal.nix starts with
+ # the sha256 of the .cabal file it was made from, and fails evaluation
+ # when that changed.
+ automaticPackage = hself: pname: dir: let
+ src = cleanHaskellSource pname dir;
+ stored = dir + "/cabal.nix";
+ header = "# cabal-sha256: ${builtins.hashFile "sha256" (dir + "/${pname}.cabal")}";
+ regenerate = ''{ printf '%s\n' '${header}'; cabal2nix .; } > cabal.nix'';
+ in
+ if !builtins.pathExists stored then
+ hself.callCabal2nix pname src {}
+ else if builtins.head (lib.splitString "\n" (builtins.readFile stored)) != header then
+ throw "pkgs/haskell: ${toString stored} is stale against ${pname}.cabal; in ${toString dir}, run: ${regenerate}"
+ else
+ self.haskell.lib.overrideSrc (hself.callPackage stored {}) { inherit src; };
in {
# nixpkgs applies packageOverrides to every Haskell package set, including
# haskellPackages.
@@ -29,6 +46,6 @@ in {
(hself: hsuper:
mylib.mapNixDir (path: hself.callPackage path {}) [ ./. ]
//
- lib.mapAttrs (pname: src: hself.callCabal2nix pname (cleanHaskellSource pname src) {}) automaticPackages);
+ lib.mapAttrs (automaticPackage hself) automaticPackages);
};
}