diff --git a/packages/lib/devshell.nix b/packages/lib/devshell.nix new file mode 100644 index 0000000..bab9629 --- /dev/null +++ b/packages/lib/devshell.nix @@ -0,0 +1,28 @@ +{ inputs, pkgs, ... }: +let + inherit (pkgs) system; + + inherit (inputs.devshell.legacyPackages.${system}) mkShell; + + injectAttrName = name: value: value // { inherit name; }; + + mkNamedAttrs = builtins.mapAttrs injectAttrName; + + attrsToNamedList = attrs: builtins.attrValues (mkNamedAttrs attrs); +in + { + packages ? [], + commands ? {}, + env ? {}, + config ? {} + }: + mkShell { + imports = [ + config + { + inherit packages; + commands = attrsToNamedList commands; + env = attrsToNamedList env; + } + ]; + } diff --git a/packages/projects.nix b/packages/projects.nix index e9d1a89..e72861d 100644 --- a/packages/projects.nix +++ b/packages/projects.nix @@ -1,4 +1,4 @@ -{ pkgs, inputs, ... }: +{ pkgs, inputs, ... }@args: let inherit (pkgs) system; dream2nix = inputs.dream2nix.lib2.init { @@ -11,6 +11,8 @@ let poetry2nix = pkgs.poetry2nix.overrideScope' (final: prev: { defaultPoetryOverrides = prev.defaultPoetryOverrides.extend (import ./poetry2nix-overrides); }); + + mkShell = import lib/devshell.nix args; in { packages = {