depot/packages/lib/devshell.nix

37 lines
785 B
Nix
Raw Normal View History

2022-03-21 22:41:18 +02:00
{ inputs, pkgs, ... }:
let
inherit (pkgs) system;
inherit (inputs.devshell.legacyPackages.${system}) mkShell;
wrapInAttrs = value: if builtins.isAttrs value then value else { inherit value; };
2022-03-22 00:10:20 +02:00
wrapPackage = package: { inherit package; };
injectAttrName = name: value: { inherit name; } // wrapInAttrs value;
2022-03-21 22:41:18 +02:00
mkNamedAttrs = builtins.mapAttrs injectAttrName;
attrsToNamedList = attrs: builtins.attrValues (mkNamedAttrs attrs);
in
{
packages ? [],
2022-03-22 00:10:20 +02:00
tools ? [],
2022-03-21 22:41:18 +02:00
commands ? {},
env ? {},
config ? {}
}:
mkShell {
imports = [
config
2022-03-22 00:10:20 +02:00
{
commands = map wrapPackage tools;
}
2022-03-21 22:41:18 +02:00
{
inherit packages;
commands = attrsToNamedList commands;
env = attrsToNamedList env;
}
];
}