Skip to content

Commit

Permalink
WIP: implement packagesFrom
Browse files Browse the repository at this point in the history
  • Loading branch information
zimbatm committed Nov 5, 2020
1 parent 0d44c41 commit 69b1e40
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
5 changes: 5 additions & 0 deletions devshell.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ packages = [
"mdsh",
]

# Expose all the dependencies from a package to the environment.
packagesFrom = [
"direnv"
]

# Message Of The Day (MOTD) is displayed when entering the environment with an
# interactive shell. By default it will show the project name.
#
Expand Down
25 changes: 22 additions & 3 deletions mkDevShell/options.nix
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,14 @@ let
'';
};
};

# Returns a list of all the input derivation ... for a derivation.
inputsOf = drv:
(drv.buildInputs or [ ]) ++
(drv.nativeBuildInputs or [ ]) ++
(drv.propagatedBuildInputs or [ ]) ++
(drv.propagatedNativeBuildInputs or [ ])
;
in
{
options = {
Expand Down Expand Up @@ -215,6 +223,15 @@ in
'';
};

packagesFrom = mkOption {
type = types.listOf strOrPackage;
default = [ ];
description = ''
Add all the build dependencies from the listed packages to the
environment.
'';
};

};

config = {
Expand All @@ -230,8 +247,10 @@ in
];

packages =
builtins.filter
(x: x != null)
(map (x: x.package) config.commands);
# Get all the packages from the commands
builtins.filter (x: x != null) (map (x: x.package) config.commands)
# Get all the packages from packagesFrom
++ builtins.foldl' (sum: drv: sum ++ (inputsOf drv)) [ ] config.packagesFrom
;
};
}

0 comments on commit 69b1e40

Please sign in to comment.