feat(devShells): init
This commit is contained in:
parent
6e2812d32f
commit
17924ee1f1
2 changed files with 84 additions and 1 deletions
80
devShells/default.nix
Normal file
80
devShells/default.nix
Normal 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
|
||||
);
|
||||
}
|
||||
|
|
@ -10,7 +10,10 @@
|
|||
*/
|
||||
{ inputs, ... }:
|
||||
{
|
||||
imports = [ inputs.flake-file.flakeModules.default ];
|
||||
imports = [
|
||||
inputs.flake-file.flakeModules.default
|
||||
../devShells
|
||||
];
|
||||
|
||||
systems = [ "x86_64-linux" ];
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue