status-mobile/nix/lib/mergeSh.nix
Jakub Sokołowski 64b8b9f170
nix: add support for more build inputs in mergeSh
Signed-off-by: Jakub Sokołowski <jakub@status.im>
2020-05-15 16:19:27 +02:00

21 lines
803 B
Nix

# this is an utility for mergeing shells created with mkShell
# TODO: make this an attribute of mkShell result set. Or just use inputsFrom.
{ lib }:
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);
})