git.iko.soy/typeable/nixpkgs
on master help sign in
mkshell: improve mergeInputs

mergeInputs is now simply defined in terms of `concatLists` and `catAttrs` instead of a more complicated `foldr`. Note that the order of PATH has also changed. For example running the following with nix-shell: let pkgs = import <nixpkgs> {}; shell1 = pkgs.mkShell { buildInputs = [ pkgs.htop ]; }; shell2 = pkgs.mkShell { buildInputs = [ pkgs.hello ]; }; shell3 = pkgs.mkShell { inputsFrom = [ shell1 shell2 ]; buildInputs = [ pkgs.tree ]; }; in shell3 Results in the following PATH: $ echo $PATH ... /nix/store/yifq4bikf7m07160bpia7z48ciqddbfi-tree-1.8.0/bin: /nix/store/vhxqk81234ivqw1a7j200a1c69k8mywi-htop-2.2.0/bin: /nix/store/n9vm3m58y1n3rg3mlll17wanc9hln58k-hello-2.10/bin ... Previously the order was: /nix/store/n9vm3m58y1n3rg3mlll17wanc9hln58k-hello-2.10/bin /nix/store/vhxqk81234ivqw1a7j200a1c69k8mywi-htop-2.2.0/bin: /nix/store/yifq4bikf7m07160bpia7z48ciqddbfi-tree-1.8.0/bin: I think the new order makes more sense because it allows to override the PATH in the outermost mkShell.

commitcee35739ff0800f5738ecbedb43c356a2f06c96f authorBas van Dijk <v.dijk.bas@gmail.com> dateSun 23 Jun 2019, 21:39 (7 years ago) parent76ef802
1 file changed+2−7
pkgs/build-support/mkshell/default.nix+2−7
pkgs/build-support/mkshell/default.nix+2−7
@@ -11,13 +11,8 @@
1111 ...
1212}@attrs:
1313let
14− mergeInputs = name:
15− let
16− op = item: sum: sum ++ item."${name}" or [];
17− nul = [];
18− list = [attrs] ++ inputsFrom;
19− in
20− lib.foldr op nul list;
14+ mergeInputs = name: lib.concatLists (lib.catAttrs name
15+ ([attrs] ++ inputsFrom));
2116
2217 rest = builtins.removeAttrs attrs [
2318 "inputsFrom"