Skip to content

Commit

Permalink
Merge #3700
Browse files Browse the repository at this point in the history
3700: Fix index-state syntax r=Anviking a=andreabedini

The second index-state stanza completely ovverides the first, resetting hackage index state to HEAD. See haskell/cabal#8568


<!--
Detail in a few bullet points the work accomplished in this PR.

Before you submit, don't forget to:

* Make sure the GitHub PR fields are correct:
   ✓ Set a good Title for your PR.
   ✓ Assign yourself to the PR.
   ✓ Assign one or more reviewer(s).
   ✓ Link to a Jira issue, and/or other GitHub issues or PRs.
   ✓ In the PR description delete any empty sections
     and all text commented in <!--, so that this text does not appear
     in merge commit messages.

* Don't waste reviewers' time:
   ✓ If it's a draft, select the Create Draft PR option.
   ✓ Self-review your changes to make sure nothing unexpected slipped through.

* Try to make your intent clear:
   ✓ Write a good Description that explains what this PR is meant to do.
   ✓ Jira will detect and link to this PR once created, but you can also
     link this PR in the description of the corresponding Jira ticket.
   ✓ Highlight what Testing you have done.
   ✓ Acknowledge any changes required to the Documentation.
-->


- [ ] I have ...

### Comments

<!-- Additional comments, links, or screenshots to attach, if any. -->

### Issue Number

<!-- Reference the Jira/GitHub issue that this PR relates to, and which requirements it tackles.
  Note: Jira issues of the form ADP- will be auto-linked. -->


Co-authored-by: Andrea Bedini <[email protected]>
  • Loading branch information
iohk-bors[bot] and andreabedini authored Feb 22, 2023
2 parents 5b04c4b + 7168051 commit 6dca83f
Show file tree
Hide file tree
Showing 28 changed files with 26 additions and 6,054 deletions.
5 changes: 4 additions & 1 deletion cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,11 @@ repository cardano-haskell-packages
c00aae8461a256275598500ea0e187588c35a5d5d7454fb57eac18d9edb86a56
d4a35cd3121aa00d18544bb0ac01c3e1691d618f462c46129271bccf39f7e8ee

-- repeating the index-state for hackage to work around hackage.nix parsing limitation
index-state: 2022-09-27T00:00:00Z
index-state: cardano-haskell-packages 2022-10-25T20:00:00Z
index-state:
, hackage.haskell.org 2022-09-27T00:00:00Z
, cardano-haskell-packages 2022-10-25T20:00:00Z

with-compiler: ghc-8.10.7

Expand Down
55 changes: 2 additions & 53 deletions docs/contributing/Notes-from-upgrading-GHC-version.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Here is a reference PR that upgrades to GHC 8.10.7: https://github.com/input-out
**WARNING**: Updating haskell.nix and/or GHC changes a lot of the build environment. You should expect to spend time fixing breakages.

## Process

- Update "with-compiler" in cabal.project:
```diff
diff --git a/cabal.project b/cabal.project
Expand All @@ -22,64 +23,12 @@ index 1ba2edf625..109534719a 100644
lib/wallet/
```

- Update "compiler-nix-name" in nix/overlays/build-tools

```diff
diff --git a/nix/overlays/build-tools.nix b/nix/overlays/build-tools.nix
index 28c46f2e4df..6b0778eb5d0 100644
--- a/nix/overlays/build-tools.nix
+++ b/nix/overlays/build-tools.nix
@@ -41,7 +41,7 @@ let
weeder.version = "2.1.3";
};

- compiler-nix-name = "ghc8105"; # TODO: get it from the project
+ compiler-nix-name = "ghc8107"; # TODO: get it from the project
in

pkgs: super: let
```

- Update haskell.nix `niv update haskell.nix -b master`.
- Run nix/regenerate.sh.
- Update haskell.nix `nix flake lock --update-input haskellNix`.

## Troubleshooting

The following is a list of issues encountered so far while executing this process:

### nix/regenerate.sh fails

For example:

```
error: assertion ((final).buildPackages.haskell-nix.compiler."${compiler-nix-name'}".version == (final).buildPackages.haskell-nix.compiler."${(((plan-pkgs).pkgs hackage)).compiler.nix-name}".version) failed at /nix/store/zs00ba6w5972g0sy95r89z4nzbm16kqi-haskell.nix-src/overlays/haskell.nix:152:15
```

This particular issue was caused by a mismatch in the GHC versions of the Nix expressions updated above, and the GHC version listed in the materialized (cached) files. Regenerate should change the cached files, but instead was failing with the above error.

To fix this, I had to:

- Navigate to overlays/build-tools.nix, and change the following lines:

```diff
diff --git a/nix/overlays/build-tools.nix b/nix/overlays/build-tools.nix
index 28c46f2e4..3e80caad4 100644
--- a/nix/overlays/build-tools.nix
+++ b/nix/overlays/build-tools.nix
@@ -50,7 +50,7 @@ pkgs: super: let
mkTool = name: args: pkgs.haskell-nix.hackage-package ({
inherit name index-state compiler-nix-name;
} // pkgs.lib.optionalAttrs enableMaterialization {
- checkMaterialization = false;
+ checkMaterialization = true;
materialized = ../materialized + "/${name}";
} // builtins.removeAttrs args ["exe"]);
```

Re-run nix/regenerate.sh and it should fail with an error that contains an `updateMaterialized` script to run. Run that script, and return `checkMaterialization` to `false`.

Alternatively, running `s/ghc8105/ghc8107/`, then re-running nix/regenerate.sh, would have done the trick.

### Compile-time error when building a package or dependency

For example:
Expand Down
2 changes: 0 additions & 2 deletions docs/developers/Building.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
| [cabal][] | >= 3.4.0.0 | Required |
| [[Nix]] | >= 2.5.1 | Optional |

See [`nix/overlays/build-tools.nix`](https://github.com/input-output-hk/cardano-wallet/blob/master/nix/overlays/build-tools.nix#L1) for a list of other Haskell development tools that are used. CI will use exactly the versions specified in this file.

[cabal]: https://www.haskell.org/cabal/download.html
[ghc]: https://www.haskell.org/downloads/

Expand Down
4 changes: 0 additions & 4 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,6 @@
iohkNix.overlays.crypto
iohkNix.overlays.haskell-nix-extra
iohkNix.overlays.cardano-lib
# Haskell build tools
(import ./nix/overlays/build-tools.nix)
# Cardano deployments
(import ./nix/overlays/cardano-deployments.nix)
# Other packages overlay
Expand Down Expand Up @@ -397,8 +395,6 @@
inherit (config) dockerHubRepoName;
};
inherit (pkgs) checkCabalProject cabalProjectRegenerate;
buildToolsGenerateMaterialized = pkgs.haskell-build-tools.regenerateMaterialized;
iohkNixGenerateMaterialized = pkgs.iohk-nix-utils.regenerateMaterialized;
} // (lib.optionalAttrs buildPlatform.isLinux {
nixosTests = import ./nix/nixos/tests {
inherit pkgs project;
Expand Down
36 changes: 19 additions & 17 deletions nix/haskell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,15 @@ CHaP: haskell-nix: haskell-nix.cabalProject' [

# setGitRev is a postInstall script to stamp executables with
# version info. It uses the "gitrev" option.
# use buildPackages here, we want set-git-rev on the build machine even under
# cross compilation (e.g. to windows)
setGitRevPostInstall = setGitRevPostInstall' config.gitrev;
setGitRevPostInstall' = gitrev: ''
${pkgs.buildPackages.iohk-nix-utils}/bin/set-git-rev "${gitrev}" $out/bin/*
${pkgs.buildPackages.haskellBuildUtils}/bin/set-git-rev "${gitrev}" $out/bin/*
'';

rewriteLibsPostInstall = lib.optionalString (pkgs.stdenv.hostPlatform.isDarwin) ''
export PATH=$PATH:${lib.makeBinPath (with pkgs.buildPackages; [ iohk-nix-utils binutils nix ])}
export PATH=$PATH:${lib.makeBinPath (with pkgs.buildPackages; [ haskellBuildUtils binutils nix ])}
rewrite-libs $out/bin $out/bin/*
'';

Expand Down Expand Up @@ -103,18 +105,20 @@ CHaP: haskell-nix: haskell-nix.cabalProject' [
shell = {
name = "cardano-wallet-shell${lib.optionalString config.profiling "-profiled"}";
packages = ps: builtins.attrValues (haskellLib.selectProjectPackages ps);

# Should prevents cabal from choosing alternate plans, so that
# *all* dependencies are provided by Nix....
# but: https://github.com/input-output-hk/haskell.nix/issues/231
# exactDeps = true;

# fixme: this is needed to prevent Haskell.nix double-evaluating hoogle
tools.hoogle = {
inherit (pkgs.haskell-build-tools.hoogle) version;
inherit (pkgs.haskell-build-tools.hoogle.project) index-state;
checkMaterialization = false;
materialized = ./materialized + "/hoogle";
tools = {
cabal-cache.version = "1.0.2.1";
haskell-language-server = {
version = "1.8.0.0";
modules = [{ reinstallableLibGhc = false; }];
};
hie-bios = {
modules = [{ reinstallableLibGhc = false; }];
};
hoogle.version = "5.0.18.1";
hlint.version = "3.3.1";
lentil.version = "1.5.2.0";
stylish-haskell.version = "0.11.0.3";
weeder.version = "2.1.3";
};
nativeBuildInputs = with buildProject.hsPkgs; [
cardano-node.components.exes.cardano-node
Expand All @@ -134,9 +138,7 @@ CHaP: haskell-nix: haskell-nix.cabalProject' [
yq
nixWrapped
cabalWrapped
] ++ lib.filter
(drv: lib.isDerivation drv && drv.name != "regenerate-materialized-nix")
(lib.attrValues haskell-build-tools));
]);
};

inputMap = { "https://input-output-hk.github.io/cardano-haskell-packages" = CHaP; };
Expand Down
159 changes: 0 additions & 159 deletions nix/materialized/cabal-cache/.plan.nix/cabal-cache.nix

This file was deleted.

Loading

0 comments on commit 6dca83f

Please sign in to comment.