on iko/ghcjs-patch-master help sign in
Only pass `--index-state` to `cabal` when asked (#1384)

Currently we pass the `--index-state` argument to `cabal` for configuration of a project even if it was found in the `cabal.project` file. This must have seemed harmless enough when we set it up that way, but it causes problems if there are `repository` blocks in the `cabal.project` file. So for instance if we have a `cabal.project` with: ``` index-state: 2022-01-22T00:00:00Z index-state: ghcjs-overlay HEAD repository ghcjs-overlay url: https://raw.githubusercontent.com/input-output-hk/hackage-overlay-ghcjs/8756b0891a0a550cc8b00dacd24227aee483c0ca secure: True root-keys: key-threshold: 0 ``` With the intention of using the `HEAD` version of the `ghcjs-overlay` and letting the commit hash in the `url` ensure it is stable. The first `index-state` is found and `--index-state 2022-01-22T00:00:00Z` is passed on the command line to `cabal`. This overrides the `HEAD` setting for `ghcjs-overlay` and because the timestamps in the `ghcjs-overlay` depend solely on when the `hackage-overlay-repo-tool` ran none of them are included. The solution is to pass `--index-state` to `cabal` only when it was passed into the project function. When it is not provided `cabal` should still respect the setting in the `cabal.project` file, but it will not elevate it to replace other settings as it does now.

commite2b12dbff7903eb0083d867a50d59480becd0cf1 authorHamish Mackenzie <Hamish.K.Mackenzie@gmail.com> dateThu 24 Feb 2022, 23:55 (5 years ago) parentac01820
1 file changed+6−6
lib/call-cabal-project-to-nix.nix+6−6
lib/call-cabal-project-to-nix.nix+6−6
@@ -530,12 +530,12 @@ let
530530 index-state = cached-index-state;
531531 sha256 = index-sha256-found;
532532 }
533− } cabal v2-freeze \
534− --index-state=${
535− # Setting the desired `index-state` here in case it was not
536− # from the cabal.project file. This will further restrict the
537− # packages used by the solver (cached-index-state >= index-state-found).
538− index-state-found} \
533+ } cabal v2-freeze ${
534+ # Setting the desired `index-state` here in case it is not
535+ # in the cabal.project file. This will further restrict the
536+ # packages used by the solver (cached-index-state >= index-state-found).
537+ pkgs.lib.optionalString (index-state != null) "--index-state=${index-state}"
538+ } \
539539 -w ${
540540 # We are using `-w` rather than `--with-ghc` here to override
541541 # the `with-compiler:` in the `cabal.project` file.