diff --git a/devShells/default.nix b/devShells/default.nix new file mode 100644 index 0000000..0fc55c9 --- /dev/null +++ b/devShells/default.nix @@ -0,0 +1,80 @@ +# Development shells + +/** + Isolated environments for convenient software development. + Provides shells for all languages I use: + - ~~❄️ [Nix]~~ (not yet) + - ~~🦀 Rust~~ (not yet) + - ~~🐍 Python~~ (not yet) + + Also provides separate shell for configuration development (not yet). + + `devShells/{name}/default.nix` files contain package list (as attrset for documentation comments) and, + for some shells, shell hooks. It usually looks like this: + ```nix + # {language name} + /** + Some info on shell + * / + pkgs: + { + /** + description on foo + * / + packages.foo = pkgs.foo; + /** + description on bar + * / + packages.bar = pkgs.bar + + /** + comments on shell hook + * / + shellHook = '' + ... + ''; + } + ``` + + Also, it has templates, so you can use development shell for projects which don't have their own. +*/ +let + dirs = + let + contents = builtins.readDir ./.; + in + builtins.filter (name: contents.${name} == "directory") (builtins.attrNames contents); +in +{ + perSystem = + { + pkgs, + ... + }: + + { + devShells = builtins.listToAttrs ( + map (name: { + inherit name; + value = + let + cfg = import ./${name}/default.nix pkgs; + in + pkgs.mkShell { + inherit name; + packages = map (p: p) (builtins.attrValues cfg.packages); + shellHook = cfg.shellHook or ""; + }; + }) dirs + ); + }; + flake.templates = builtins.listToAttrs ( + map (name: { + inherit name; + value = { + path = ./${name}; + description = "${name}"; + }; + }) dirs + ); +} diff --git a/flake/default.nix b/flake/default.nix index 770fc99..ecde453 100644 --- a/flake/default.nix +++ b/flake/default.nix @@ -10,7 +10,10 @@ */ { inputs, ... }: { - imports = [ inputs.flake-file.flakeModules.default ]; + imports = [ + inputs.flake-file.flakeModules.default + ../devShells + ]; systems = [ "x86_64-linux" ];