forked from divnix/std
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmkShell.nix
More file actions
65 lines (61 loc) · 1.98 KB
/
mkShell.nix
File metadata and controls
65 lines (61 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
let
inherit (inputs.cells.std.errors) requireInput;
inherit (requireInput "devshell" "github:numtide/devshell" "std.lib.dev.mkShell") devshell nixago;
l = inputs.nixpkgs.lib // builtins;
pkgs = import inputs.nixpkgs {
inherit (inputs.nixpkgs) system;
overlays = [devshell.overlays.default];
};
in
configuration: let
nixagoModule = {
config,
lib,
...
}:
with lib; let
cfg = config;
in {
options.nixago = mkOption {
type = types.listOf types.attrs;
default = [];
apply = x: l.catAttrs "__passthru" x;
description = "List of `std` Nixago pebbles to load";
};
config = let
# effectuate side effects on treefmt nixago, if present
# to prevent treefmt from formatting auto-generated files
partitioned = l.partition (n: n.output == "treefmt.toml") cfg.nixago;
treefmt' =
l.map (
t:
l.recursiveUpdate t
{
data.global.excludes =
t.data.global.excludes
or []
++ (l.map (o: o.output) cfg.nixago);
}
)
# if there's more than one treefmt, that's a malconfiguration
# but here: we don't deal with that case
partitioned.right;
updated = treefmt' ++ partitioned.wrong;
in
mkIf (cfg.nixago != []) {
devshell = let
acc = l.foldl l.recursiveUpdate {};
in
acc (
[]
++ (l.map (o: o.devshell) updated)
++ [{startup.nixago-setup-hook = l.stringsWithDeps.noDepEntry (nixago.lib.makeAll updated).shellHook;}]
);
packages = l.concatMap (o: o.packages) updated;
commands = l.concatMap (o: o.commands) updated;
};
};
in
pkgs.devshell.mkShell {
imports = [configuration nixagoModule];
}