feat(devShells): init

This commit is contained in:
Sk7Str1p3 2026-04-15 18:51:23 +03:00
parent 6e2812d32f
commit 17924ee1f1
No known key found for this signature in database
GPG key ID: 4DD995933D06D43B
2 changed files with 84 additions and 1 deletions

80
devShells/default.nix Normal file
View file

@ -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
);
}