Skip to content

Commit 2dcfa16

Browse files
committed
Fix index-sha256 bit rot
If an new package is deployed to `hackage.haskell.org`, to use it before it is captured by the `hackage.nix` update add the following to the project arguments: ```nix index-state="2025-06-16T00:00:00Z"; # Use current time here # This hash in not valid, the error message will give the correct hash index-sha256="sha256-NS28jJYko/tNUKVhncntu/mV8tsQmTA52T000000000="; ``` This change PR fixes some "bit rot" issues: * A warning about `--index-state` argument being out of range is now an error. * The sha256 might now be in base16 or base32.
1 parent cd9ddc0 commit 2dcfa16

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

lib/call-cabal-project-to-nix.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,7 @@ let
678678
# Setting the desired `index-state` here in case it is not
679679
# in the cabal.project file. This will further restrict the
680680
# packages used by the solver (cached-index-state >= index-state-max).
681-
pkgs.lib.optionalString (index-state != null) "--index-state=${index-state}"
681+
pkgs.lib.optionalString (index-state != null && index-state < cached-index-state) "--index-state=${index-state}"
682682
} \
683683
-w ${
684684
# We are using `-w` rather than `--with-ghc` here to override

mk-local-hackage-repo/default.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
pkgs:
1818
{ name, index }:
1919

20-
pkgs.buildPackages.runCommand "hackage-repo-${name}" { preferLocalBuild = true; } ''
20+
pkgs.pkgsBuildBuild.runCommand "hackage-repo-${name}" { preferLocalBuild = true; } ''
2121
mkdir -p $out
2222
export expires="4000-01-01T00:00:00Z"
2323
@@ -29,7 +29,7 @@ ${
2929
# of the index derivation (when the `extra-hackages` feature is used the index
3030
# may not have an outputHash).
3131
pkgs.lib.optionalString (index ? outputHash) ''
32-
if [[ "${index.outputHash}" != "$index_sha256" ]]; then
32+
if [[ "$(${pkgs.pkgsBuildBuild.nix}/bin/nix-hash --type sha256 --to-base16 ${index.outputHash})" != "$index_sha256" ]]; then
3333
echo "ERROR See https://github.com/input-output-hk/haskell.nix/issues/884"
3434
exit 1
3535
fi

0 commit comments

Comments
 (0)