on iko/ghcjs-patch-master help sign in
Replace `otherShells` with `mkShell` `inputsFrom` (#939)

It turns out the `otherShells` arg we added to `shellFor` is very similar to the `inputsFrom` argument of `mkShell`. We can use `inputsFrom` instead having `otherShells` by replacing the use of `mkDerivation` with `mkShell` in `shellFor`.

commitc0931c9a562fe01e9a2f7abb62780f37466bef6a authorHamish Mackenzie <Hamish.Mackenzie@iohk.io> dateThu 26 Nov 2020, 21:15 (6 years ago) parent5df5be0
3 files changed+8−8
builder/shell-for.nix+4−7 changelog.md+3 docs/reference/library.md+1−1
builder/shell-for.nix+4−7
@@ -1,4 +1,4 @@
1−{ lib, stdenv, glibcLocales, pkgconfig, ghcForComponent, makeConfigFiles, hsPkgs, hoogleLocal, haskellLib, buildPackages, compiler }:
1+{ lib, stdenv, mkShell, glibcLocales, pkgconfig, ghcForComponent, makeConfigFiles, hsPkgs, hoogleLocal, haskellLib, buildPackages, compiler }:
22
33{ # `packages` function selects packages that will be worked on in the shell itself.
44 # These packages will not be built by `shellFor`, but their
@@ -20,7 +20,6 @@
2020, withHoogle ? true
2121, exactDeps ? false
2222, tools ? {}
23−, otherShells ? [] # List of other shells to include in this one
2423, ... } @ args:
2524
2625let
@@ -117,19 +116,17 @@ let
117116 }
118117 ));
119118
120− mkDrvArgs = builtins.removeAttrs args ["packages" "additional" "withHoogle" "tools" "otherShells"];
119+ mkDrvArgs = builtins.removeAttrs args ["packages" "additional" "withHoogle" "tools"];
121120in
122− stdenv.mkDerivation (mkDrvArgs // {
121+ mkShell (mkDrvArgs // {
123122 name = mkDrvArgs.name or name;
124123
125124 buildInputs = systemInputs
126− ++ mkDrvArgs.buildInputs or []
127− ++ lib.concatMap (s: s.buildInputs) otherShells;
125+ ++ mkDrvArgs.buildInputs or [];
128126 nativeBuildInputs = [ ghcEnv ]
129127 ++ nativeBuildInputs
130128 ++ mkDrvArgs.nativeBuildInputs or []
131129 ++ lib.attrValues (buildPackages.haskell-nix.tools compiler.nix-name tools)
132− ++ lib.concatMap (s: s.nativeBuildInputs) otherShells
133130 # If this shell is a cross compilation shell include
134131 # wrapper script for running cabal build with appropriate args.
135132 ++ lib.optional (ghcEnv.targetPrefix != "") (
changelog.md+3
@@ -1,6 +1,9 @@
11This file contains a summary of changes to Haskell.nix and `nix-tools`
22that will impact users.
33
4+## Nov 26, 2020
5+* Renamed `otherShells` arg for `shellFor` to `inputsFrom
6+
47## Nov 25, 2020
58* The `shellFor` `makeConfigFiles` `ghcWithHoogle` and `ghcWithPackages`
69 functions have been removed from `project.hsPkgs`. Instead access
docs/reference/library.md+1−1
@@ -433,7 +433,7 @@ shellFor =
433433| `withHoogle` | Boolean | Whether to build a Hoogle documentation index and provide the `hoogle` command. |
434434| `exactDeps` | Boolean | Prevents the Cabal solver from choosing any package dependency other than what are in the package set. |
435435| `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. |
436−| `otherShells | List | List of other shells to include in this one. The `buildInputs` and `nativeBuildInputs` of each will be included.
436+| `inputsFrom` | List | List of other shells to include in this one. The `buildInputs` and `nativeBuildInputs` of each will be included using [mkShell](https://nixos.org/manual/nixpkgs/stable/#sec-pkgs-mkShell).
437437| `{ ... }` | Attrset | All the other arguments are passed to [`mkDerivation`](https://nixos.org/nixpkgs/manual/#sec-using-stdenv). |
438438
439439**Return value**: a derivation