nix: add support for more build inputs in mergeSh

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2020-05-15 12:19:07 +02:00
parent 73a8992db7
commit 64b8b9f170
No known key found for this signature in database
GPG Key ID: 4EF064D0E6D63020
1 changed files with 17 additions and 6 deletions

View File

@ -1,9 +1,20 @@
# this is an utility for mergeing shells created with mkShell
# TODO: make this an attribute of mkShell result set.
# TODO: make this an attribute of mkShell result set. Or just use inputsFrom.
{ lib }:
super: shells: super.overrideAttrs(super: with lib; {
inputsFrom = (super.inputsFrom or []) ++ unique (catAttrs "inputsFrom" shells);
buildInputs = (super.buildInputs or []) ++ unique (catAttrs "buildInputs" shells);
shellHook = (super.shellHook or "") + concatStrings (catAttrs "shellHook" shells);
})
super: shells:
super.overrideAttrs (super:
let
inherit (lib) attrByPath unique catAttrs concatStrings;
mergeAttrsFor = attrName:
(attrByPath [attrName] [] super) ++ unique (catAttrs attrName shells);
in {
inputsFrom = mergeAttrsFor "inputsFrom";
buildInputs = mergeAttrsFor "buildInputs";
nativeBuildInputs = mergeAttrsFor "nativeBuildInputs";
propagatedBuildInputs = mergeAttrsFor "propagatedBuildInputs";
propagatedNativeBuildInputs = mergeAttrsFor "propagatedNativeBuildInputs";
# shellHook is a string, not a list
shellHook = (super.shellHook or "") + concatStrings (catAttrs "shellHook" shells);
})