-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwithDot.nix
34 lines (34 loc) · 1.01 KB
/
withDot.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
{ pkgs }:
with builtins;
let
names = attrNames pkgs;
lib = pkgs.lib;
gen = selected:
let
drv = pkgs.mkShell {
inherit (selected) inputsFrom packages;
name = if (selected.inputsFrom == [])
then "nix-shell-env"
else lib.concatStringsSep "-" (map (v: v.pname or v.name or "unknown") selected.inputsFrom);
};
mkAttrs = isInputs: (map
(n:
{
name = (if isInputs then "@" else "") + n;
value = (gen (if isInputs
then { inherit (selected) packages; inputsFrom = selected.inputsFrom ++ [ (getAttr n pkgs) ]; }
else { inherit (selected) inputsFrom; packages = selected.packages ++ [ (getAttr n pkgs) ]; }
));
}
)
names);
attrs_list = (mkAttrs true) ++ (mkAttrs false);
env = drv.overrideAttrs (oa: {
passthru =
listToAttrs attrs_list
// { _passthru = drv.passthru; };
});
in
env;
in
gen { inputsFrom = [ ]; packages = [ ]; }