Skip to content

Commit 875c1fb

Browse files
committed
WIP: implement packagesFrom
1 parent 7817220 commit 875c1fb

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

devshell.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ name = "mkDevShell"
88
# NOTE: don't forget to put commas between items! :)
99
packages = []
1010

11+
# Expose all the dependencies from a package to the environment.
12+
packagesFrom = [
13+
"direnv"
14+
]
15+
1116
# Message Of The Day (MOTD) is displayed when entering the environment with an
1217
# interactive shell. By default it will show the project name.
1318
#

options.nix

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,14 @@ let
5050
'';
5151
};
5252
};
53+
54+
# Returns a list of all the input derivation ... for a derivation.
55+
inputsOf = drv:
56+
(drv.buildInputs or [ ]) ++
57+
(drv.nativeBuildInputs or [ ]) ++
58+
(drv.propagatedBuildInputs or [ ]) ++
59+
(drv.propagatedNativeBuildInputs or [ ])
60+
;
5361
in
5462
{
5563
options = {
@@ -142,6 +150,15 @@ in
142150
'';
143151
};
144152

153+
packagesFrom = mkOption {
154+
type = types.listOf strOrPackage;
155+
default = [ ];
156+
description = ''
157+
Add all the build dependencies from the listed packages to the
158+
environment.
159+
'';
160+
};
161+
145162
};
146163

147164
config = {
@@ -158,7 +175,10 @@ in
158175
];
159176

160177
packages =
161-
builtins.filter (x: x != null)
162-
(map (x: x.package) config.commands);
178+
# Get all the packages from the commands
179+
builtins.filter (x: x != null) (map (x: x.package) config.commands)
180+
# Get all the packages from packagesFrom
181+
++ builtins.foldl' (sum: drv: sum ++ (inputsOf drv)) [ ] config.packagesFrom
182+
;
163183
};
164184
}

0 commit comments

Comments
 (0)