Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: implement packagesFrom #6

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
;
};
}