From 69b1e40283ac262b557b596a8211c0c05040c9ef Mon Sep 17 00:00:00 2001 From: zimbatm Date: Mon, 24 Aug 2020 14:43:55 +0200 Subject: [PATCH] WIP: implement packagesFrom --- devshell.toml | 5 +++++ mkDevShell/options.nix | 25 ++++++++++++++++++++++--- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/devshell.toml b/devshell.toml index 8012e7d3..62b03d38 100644 --- a/devshell.toml +++ b/devshell.toml @@ -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. # diff --git a/mkDevShell/options.nix b/mkDevShell/options.nix index c2537031..095c4ff2 100644 --- a/mkDevShell/options.nix +++ b/mkDevShell/options.nix @@ -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 = { @@ -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 = { @@ -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 + ; }; }