depot/packages/lib/devshell.nix
2022-03-21 23:10:20 +01:00

36 lines
785 B
Nix

{ inputs, pkgs, ... }:
let
inherit (pkgs) system;
inherit (inputs.devshell.legacyPackages.${system}) mkShell;
wrapInAttrs = value: if builtins.isAttrs value then value else { inherit value; };
wrapPackage = package: { inherit package; };
injectAttrName = name: value: { inherit name; } // wrapInAttrs value;
mkNamedAttrs = builtins.mapAttrs injectAttrName;
attrsToNamedList = attrs: builtins.attrValues (mkNamedAttrs attrs);
in
{
packages ? [],
tools ? [],
commands ? {},
env ? {},
config ? {}
}:
mkShell {
imports = [
config
{
commands = map wrapPackage tools;
}
{
inherit packages;
commands = attrsToNamedList commands;
env = attrsToNamedList env;
}
];
}