Skip to content

Fix index-sha256 bit rot #2390

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jun 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/reference/library.md
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,8 @@ needed for `importAndFilterProject`.
|----------------------|------|---------------------|
| `name` | String | Optional name for better error messages. |
| `src` | Path | Location of the cabal project files. |
| `compiler-nix-name` | String | The name of the ghc compiler to use eg. "ghc884" |
| `index-state` | Timestamp | Optional hackage index-state, eg. "2019-10-10T00:00:00Z". |
| `compiler-nix-name` | String | The name of the ghc compiler to use eg. "ghc9122" |
| `index-state` | Timestamp | Optional hackage index-state, eg. "2025-01-10T00:00:00Z". |
| `index-sha256` | Sha256 | Optional hash of the truncated hackage index-state. |
| `plan-sha256` | Sha256 | Optional hash of the plan-to-nix output (makes the plan-to-nix step a fixed output derivation). |
| `cabalProject` | String | Optional cabal project file contents (defaults to readFile "${src}/cabal.project"). |
Expand Down
4 changes: 3 additions & 1 deletion lib/call-cabal-project-to-nix.nix
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,9 @@ let
# Setting the desired `index-state` here in case it is not
# in the cabal.project file. This will further restrict the
# packages used by the solver (cached-index-state >= index-state-max).
pkgs.lib.optionalString (index-state != null) "--index-state=${index-state}"
# Cabal treats `--index-state` > the last known package as an error,
# so we only include this if it is < cached-index-state.
pkgs.lib.optionalString (index-state != null && index-state < cached-index-state) "--index-state=${index-state}"
} \
-w ${
# We are using `-w` rather than `--with-ghc` here to override
Expand Down
4 changes: 2 additions & 2 deletions mk-local-hackage-repo/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
pkgs:
{ name, index }:

pkgs.buildPackages.runCommand "hackage-repo-${name}" { preferLocalBuild = true; } ''
pkgs.pkgsBuildBuild.runCommand "hackage-repo-${name}" { preferLocalBuild = true; } ''
mkdir -p $out
export expires="4000-01-01T00:00:00Z"

Expand All @@ -29,7 +29,7 @@ ${
# of the index derivation (when the `extra-hackages` feature is used the index
# may not have an outputHash).
pkgs.lib.optionalString (index ? outputHash) ''
if [[ "${index.outputHash}" != "$index_sha256" ]]; then
if [[ "$(${pkgs.pkgsBuildBuild.nix}/bin/nix-hash --type sha256 --to-base16 ${index.outputHash})" != "$index_sha256" ]]; then
echo "ERROR See https://github.com/input-output-hk/haskell.nix/issues/884"
exit 1
fi
Expand Down
Loading