Skip to content

Commit fe9b826

Browse files
committed
Make sure the hackageTarball's store path doesn't change
previously the fetchurl would produce a different store path each and every time as hackage's index is a moving target. With this impurity setup, we can ignore this.
1 parent 1b1a3c9 commit fe9b826

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

default.nix

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,21 @@ let
127127
# Make this handy overridable fetch function available.
128128
inherit fetchExternal;
129129

130+
# Produce a fixed output derivation from a moving target (hackage index tarball)
130131
hackageTarball = { index-state, sha256 }:
131-
let index = builtins.fetchurl https://hackage.haskell.org/01-index.tar.gz;
132-
in pkgs.runCommand "01-index.tar.gz-at-${builtins.replaceStrings [":"] [""] index-state}" { outputHashAlgo = "sha256"; outputHash = sha256; }
132+
pkgs.runCommand "01-index.tar.gz-at-${builtins.replaceStrings [":"] [""] index-state}" {
133+
nativeBuildInputs = [ pkgs.curl ];
134+
outputHashAlgo = "sha256";
135+
outputHash = sha256;
136+
# We'll use fetchurl's result in an env var ...
137+
HACKAGE_INDEX = builtins.fetchurl "https://hackage.haskell.org/01-index.tar.gz";
138+
# ... and mark that impure. That way we can
139+
# ensure the sore path stays the same and doesn't
140+
# depend on the fetchurl result path.
141+
impureEnvVars = [ "HACKAGE_INDEX" ];
142+
}
133143
''
134-
${self.nix-tools}/bin/truncate-index -o $out -i ${index} -s ${index-state}
144+
${self.nix-tools}/bin/truncate-index -o $out -i $HACKAGE_INDEX -s ${index-state}
135145
'';
136146

137147
mkLocalHackageRepo = import ./mk-local-hackage-repo { inherit (self) hackageTarball; inherit pkgs; };

0 commit comments

Comments
 (0)