-
Notifications
You must be signed in to change notification settings - Fork 1
/
default.nix
81 lines (77 loc) · 2.16 KB
/
default.nix
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
{ lib, config, self, inputs, ... }:
{
imports = [
../lib
];
options = let
inherit (lib)
types
;
inherit (config.lib)
createThings
;
createDevShells = baseDir:
createThings {
inherit baseDir;
thingType = "devShell";
raw = false;
extras.systems = {
default = lib.const true;
};
};
in {
auto.devShells = lib.mkOption {
description = ''
Automagically generate devShells from walking directories with Nix files
'';
type = types.submodule (submodule: {
options = {
enable = lib.mkEnableOption "Automatic devShells extraction";
dir = lib.mkOption {
description = ''
Base directory of the contained devShells
'';
type = types.path;
default = "${self}/shells";
defaultText = ''''${self}/shells'';
};
result = lib.mkOption {
description = ''
The resulting automatic devShells
'';
type = types.attrsOf (types.submodule { options = {
devShell = lib.mkOption { type = types.unspecified; };
systems = lib.mkOption { type = types.functionTo types.bool; };
};});
readOnly = true;
internal = true;
default =
lib.optionalAttrs
config.auto.devShells.enable
(createDevShells config.auto.devShells.dir);
};
};
});
default = {};
};
};
config = {
perSystem = { lib, pkgs, system, ... }: let
# NOTE: flake's packages, done here to avoid infinite recursion
pkgs' = pkgs.extend (final: prev: inputs.self.packages.${system});
devShells =
lib.pipe
config.auto.devShells.result
[
(lib.filterAttrs
(name: { devShell, systems }:
pkgs'.callPackage systems { inherit inputs; }))
(lib.mapAttrs
(name: { devShell, systems }:
pkgs'.callPackage devShell { inherit inputs; }))
];
in {
inherit devShells;
};
};
}