This adds a way to specify the `evalSystem` or `evalPackages` explicitly when calling the `project` functions.
Currently if we want to make a `flake` that supports multiple systems we have few options:
* Require builders for all the supported systems (even just for `nix flake show`).
* Pass `--impure` so that haskell.nix can see `builtins.currentSystem` to set up `pkgs.evalPackages` to use that. Unfortunately this prevents nix from caching some of the work it does and often results in it recalculating for each supported system when it would otherwise be cached and take no time at all.
* Add an overlay to replace `evalPackages`. This works, but it is not straight forward.
* Materialize the nix files for the project.
This change allows `evalSystem = "x86_64-linux";` to be passed telling `haskell.nix` to run `cabal` and `nix-tools` on that system. The user will have to have a builder for that system, but does not need to have builders for the others (unless building outputs for them).
When downloading a `repository` block we get a number of files (not just the index). For some repositories these files will be necessary for `cabal configure` and the vanilla ones created by haskell.nix will not work. This change keeps these extra files and combines them with the main hackage index using `lndir`, so that changes to the repo will not require a new copy of the hackage index in the store.
This change also introduces `inputMap` that allows flake or niv inputs to be used to pin repository. It also works with `source-repository-package` blocks.
* Improve support for external Hackage repositories
This change builds #535. `repository` blocks in `cabal.project` parsed and `cabal` is used to automatically downloaded them. Then `hackage-to-nix` is used to produce the nix required.
To make it work with restricted eval (on hydra for instance) we need to include a sha256 like this:
```
repository ghcjs-overlay
url: https://input-output-hk.github.io/hackage-overlay-ghcjs
secure: True
root-keys:
key-threshold: 0
--sha256: sha256-EPlLYPmIGtxeahlOspRzwJv+60N5mqrNC2BY4jZKceE=
```
To find the correct `sha256` put in an invalid one and attempt a build.
* Add `package.buildable` option
Turning off building for a whole package requires setting `buildable = lib.mkForce false` on each of the components of the package. This change adds support for `package.buildable = false` to make it easier.
So:
```
packages.marlowe-actus.components.library.buildable = lib.mkForce false;
packages.marlowe-actus.components.exes.marlowe-actus-test-kit.buildable = lib.mkForce false;
packages.marlowe-actus.components.tests.marlowe-actus-test.buildable = lib.mkForce false;
```
Can be replaced with:
```
packages.marlowe-actus.package.buildable = false;
```
This change updates to the latest `nix-tools` to get the following fixes (there are 3 PRs in nix-tools, but just the one in haskell.nix to avoid having to update the materialized files multiple times):
## Better support for source repository packages
* https://github.com/input-output-hk/nix-tools/pull/107
Currently these are replaced by the `cabalProject` functions with regular `packages:` before running cabal configure. Cabal does not treat these the same (the setting of `tests:` and `benchmarks:` in the `cabal.project` file):
* The plan found by `cabalProject` may not match the one used when running `cabal`.
* The performance of the solver may not be consistent with running `cabal`.
This change replaces `source-repository-package` with another `source-repository-package` pointing at a minimal git repo.
## Only include planned components
* https://github.com/input-output-hk/nix-tools/pull/108
Only the components in the `plan.json` are now included in the haskell.nix cabal projects. This avoids missing dependencies attempting to build components that were not in the plan. Should fix#993.
## Pick latest packages
* https://github.com/input-output-hk/nix-tools/pull/109
When the same package occurs more than once in a `plan.json` file (perhaps because it is needed both by the project itself and by one of the `setup` dependencies or `build-tool-dependencies` of the project) the latest version will now be the one picked by haskell.nix. This is a work around for a common issue with `cabal-doctest` when cross compiling to windows (an old version of Win32 is used even if a newer one was required by the projects `constraints`).
* Do not use evalPackages to create sourceRepo for builds
but still use it when creating source repo for plan calculation.
This might be a way to fix#917
* Update unit tests
* Refactor this patch, and add some comments
this is much less convoluted. I moved the fetchgit invocation from
`cabal-project-parser.nix` to `call-cabal-project-to-nix` (which makes
sense in a way, if a parser should return parsed data, and not do
stuff), and then some simplifications could happen.
Also added some comments.
* Update unit tests
* Dead code
* Less repetition in tests
* Comment tweaks
Co-authored-by: Hamish Mackenzie <Hamish.Mackenzie@iohk.io>
It is now possible to specify multiple subdirs in a
`source-repository-package` block. This change fixes the parser
code in haskell.nix so that it understands.