on iko/ghcjs-patch-master help sign in
Add `otherShells` arg to `shellFor` (#937)

Makes it easier to include cross compilation shells. The buildInputs and nativeBuildInputs of the shells are added.

commite729389f3266e50602f36b7035c5e34177b705ac authorHamish Mackenzie <Hamish.Mackenzie@iohk.io> dateTue 24 Nov 2020, 16:28 (6 years ago) parent899e933
3 files changed+7−2
builder/shell-for.nix+5−2 changelog.md+1 docs/reference/library.md+1
builder/shell-for.nix+5−2
@@ -20,6 +20,7 @@
2020, withHoogle ? true
2121, exactDeps ? false
2222, tools ? {}
23+, otherShells ? [] # List of other shells to include in this one
2324, ... } @ args:
2425
2526let
@@ -116,18 +117,20 @@ let
116117 }
117118 ));
118119
119− mkDrvArgs = builtins.removeAttrs args ["packages" "additional" "withHoogle" "tools"];
120+ mkDrvArgs = builtins.removeAttrs args ["packages" "additional" "withHoogle" "tools" "otherShells"];
120121in
121122 stdenv.mkDerivation (mkDrvArgs // {
122123 name = mkDrvArgs.name or name;
123124
124125 buildInputs = systemInputs
125126 ++ mkDrvArgs.buildInputs or []
126− ++ lib.optional withHoogle' hoogleIndex;
127+ ++ lib.optional withHoogle' hoogleIndex
128+ ++ lib.concatMap (s: s.buildInputs) otherShells;
127129 nativeBuildInputs = [ ghcEnv ]
128130 ++ nativeBuildInputs
129131 ++ mkDrvArgs.nativeBuildInputs or []
130132 ++ lib.attrValues (buildPackages.haskell-nix.tools compiler.nix-name tools)
133+ ++ lib.concatMap (s: s.nativeBuildInputs) otherShells
131134 # If this shell is a cross compilation shell include
132135 # wrapper script for running cabal build with appropriate args.
133136 ++ lib.optional (ghcEnv.targetPrefix != "") (
changelog.md+1
@@ -4,6 +4,7 @@ that will impact users.
44## Nov 24, 2020
55* Added `${targetPrefix}cabal` wrapper script for running cross
66 compilers in `shellFor`.
7+* `otherShells` arg added to `shellFor`.
78
89## Oct 31, 2020
910* Passing `tools.hoogle` to `shellFor` with a value suitable for `haskel-nix.tool` will
docs/reference/library.md+1
@@ -428,6 +428,7 @@ shellFor =
428428| `withHoogle` | Boolean | Whether to build a Hoogle documentation index and provide the `hoogle` command. |
429429| `exactDeps` | Boolean | Prevents the Cabal solver from choosing any package dependency other than what are in the package set. |
430430| `tools` | Function | AttrSet of tools to make available e.g. `{ cabal = "3.2.0.0"; }` or `{ cabal = { version = "3.2.0.0"; }; }`. If an AttrSet is provided for a tool, the additional arguments will be passed to the function creating the derivation for that tool. So you can provide an `index-state` or a `materialized` argument like that `{ cabal = { version = "3.2.0.0"; index-state = "2020-10-30T00:00:00Z"; materialized = ./cabal.materialized; }; }` for example. You can specify and materialize the version of hoogle used to construct the hoogle index by including something like `{ hoogle = { version = "5.0.17.15"; index-state = "2020-05-31T00:00:00Z"; materialized = ./hoogle.materialized; }`. Uses a default version of hoogle if omitted. |
431+| `otherShells | List | List of other shells to include in this one. The `buildInputs` and `nativeBuildInputs` of each will be included.
431432| `{ ... }` | Attrset | All the other arguments are passed to [`mkDerivation`](https://nixos.org/nixpkgs/manual/#sec-using-stdenv). |
432433
433434**Return value**: a derivation