Commit Graph

8 Commits

Author SHA1 Message Date
Hamish Mackenzie
a443611ecf
Add evalSystem and evalPackages project args (#1546)
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).
2022-07-28 20:03:05 +12:00
Hamish Mackenzie
e81f3bb011
Avoid filtering repo to just 01-index.tar.gz file (#1432)
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.
2022-04-14 02:35:37 +12:00
Hamish Mackenzie
2576a948b5
Improve support for external Hackage repositories (#1370)
* 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.
2022-02-18 00:42:11 +13:00
Hamish Mackenzie
3835023cda
Add package.buildable option (#1205)
* 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;
```
2021-08-19 00:52:59 +12:00
Hamish Mackenzie
674f5b0a3d
Better support for source-repository-packages, only include planned components and pick latest packages (#1166)
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`).
2021-07-23 14:27:56 +12:00
Joachim Breitner
bdd69693b9
Do not use evalPackages to create sourceRepo for builds (#918)
* 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>
2020-11-11 11:49:27 +00:00
Hamish Mackenzie
251c899804
Fix use of multiple subdirs in cabal.project (#790)
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.
2020-07-28 14:19:58 +12:00
Rodney Lorrimar
8642facf1e
tests: Add unit tests for library functions 2019-01-30 15:38:38 +10:00