Skip to content

Commit 69b1e40

Browse files
committed
WIP: implement packagesFrom
1 parent 0d44c41 commit 69b1e40

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

devshell.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ packages = [
1111
"mdsh",
1212
]
1313

14+
# Expose all the dependencies from a package to the environment.
15+
packagesFrom = [
16+
"direnv"
17+
]
18+
1419
# Message Of The Day (MOTD) is displayed when entering the environment with an
1520
# interactive shell. By default it will show the project name.
1621
#

mkDevShell/options.nix

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,14 @@ let
116116
'';
117117
};
118118
};
119+
120+
# Returns a list of all the input derivation ... for a derivation.
121+
inputsOf = drv:
122+
(drv.buildInputs or [ ]) ++
123+
(drv.nativeBuildInputs or [ ]) ++
124+
(drv.propagatedBuildInputs or [ ]) ++
125+
(drv.propagatedNativeBuildInputs or [ ])
126+
;
119127
in
120128
{
121129
options = {
@@ -215,6 +223,15 @@ in
215223
'';
216224
};
217225

226+
packagesFrom = mkOption {
227+
type = types.listOf strOrPackage;
228+
default = [ ];
229+
description = ''
230+
Add all the build dependencies from the listed packages to the
231+
environment.
232+
'';
233+
};
234+
218235
};
219236

220237
config = {
@@ -230,8 +247,10 @@ in
230247
];
231248

232249
packages =
233-
builtins.filter
234-
(x: x != null)
235-
(map (x: x.package) config.commands);
250+
# Get all the packages from the commands
251+
builtins.filter (x: x != null) (map (x: x.package) config.commands)
252+
# Get all the packages from packagesFrom
253+
++ builtins.foldl' (sum: drv: sum ++ (inputsOf drv)) [ ] config.packagesFrom
254+
;
236255
};
237256
}

0 commit comments

Comments
 (0)