6 Commits

Author SHA1 Message Date
Hamish Mackenzie b90fbaa272 Add shell.allDeps as a fix for #1793 (#1794)
* Add `shell.allDeps` as a fix for #1793

#1769 added all the tool dependencies of the hsPkgs in a project to the shell.  This is great for cabal projects where the set of packages will be limited to those in the plan.  It allows these packages to be rebuilt by cabal.

For stack projects however this set is much larger (all of stackage), likely to include unwanted tools and tools that may be broken.

This change adds `shell.allDeps` and defaults it to `false` for stack projects.

Fixes #1793

* Added comments
2022-12-02 10:50:05 +13:00
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 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 f279cdef5f Update the project modules and fix missing args param (#1144)
There are now 4 project modules used to check the arguments passed to the various project functions:

* `project-common.nix` - Arguments used by all the project functions
* `stack-project.nix` - Used by the `stackProject` and `stackProject'` functions
* `cabal-project.nix` - Used by the `cabalProject` and `cabalProject'` functions
* `project.nix` - Just the `projectFileName` argument that is used by `project` and `project'` functions to determine whether to call `stackProject` or `cabalProject` function.

This also includes the `rawProject.args` that was mistakenly left out of #1141 causing #1142 and improvements for the docs for the use of the `shell` argument in `flake.nix` files.
2021-06-20 18:00:22 +12:00
Hamish Mackenzie c3841b4208 Add cross compilation and devShell to project.flake (#1141)
The default shell `devShell` works by adding a default `shell` to all projects.  You can pass the shell arguments to the project function using the new `shell` argument:

```
let myProject = haskell-nix.project {
  src = ./.;
  shell.tools = { cabal = {}; };
  shell.crossPlatforms = p: [ p.cross ];
};
```

This will include js-unknown-ghcjs-cabal in the `devShell`.

To add cross compiled outputs to the flake pass `crossPlatforms` to the `flake` function.

```
myProject.flake { crossPlatforms = p: [ p.cross ]; }
```

To cross compile a component include the platforms `config` string to the output name like this

```
nix build .#js-unknown-ghcjs:pkg-name:lib:pkg-name
```
2021-06-17 19:07:37 +12:00
Hamish Mackenzie 4f449d37f5 Use nix module system to check project arguments (#1087)
* Use nix module system to check project arguments

This change uses the nix module system for the arguments to:

* `cabalProject'`
* `cabalProject`
* `stackProject'`
* `stackProject`

This will:

* Give an error when the name or type of an argument is incorrect
  (currently misnamed args are quietly ignored).

* Fixes a problem with `projectCross` not having a way to pass different args to `cabalProject`
  for different platforms. We can now use:
    `({pkgs, ...}: { cabalProjectLocal = if pkgs.stdenv.hostPlatform.isX then ... })`
2021-04-08 12:06:26 +12:00