diff --git a/docs/reference/library.md b/docs/reference/library.md index 4137cc0d45..c6014831cd 100644 --- a/docs/reference/library.md +++ b/docs/reference/library.md @@ -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"). | diff --git a/lib/call-cabal-project-to-nix.nix b/lib/call-cabal-project-to-nix.nix index 952ebb1e09..42679dffc5 100644 --- a/lib/call-cabal-project-to-nix.nix +++ b/lib/call-cabal-project-to-nix.nix @@ -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 diff --git a/mk-local-hackage-repo/default.nix b/mk-local-hackage-repo/default.nix index 66647dddea..e0e1d4e039 100644 --- a/mk-local-hackage-repo/default.nix +++ b/mk-local-hackage-repo/default.nix @@ -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" @@ -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