-
-
Notifications
You must be signed in to change notification settings - Fork 29
/
flake-module.nix
70 lines (69 loc) · 2.03 KB
/
flake-module.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
/*
A module to import into flakes based on flake-parts.
Makes integration into a flake easy and tidy.
See https://flake.parts, https://flake.parts/options/nix-topology
*/
{
lib,
self,
config,
flake-parts-lib,
...
}: let
inherit
(lib)
mkOption
types
;
in {
options = {
flake = flake-parts-lib.mkSubmoduleOptions {
topology = mkOption {
type = types.lazyAttrsOf types.unspecified;
default =
lib.mapAttrs
(_system: config':
import ./. {
inherit (config'.topology) pkgs;
modules =
config'.topology.modules
++ [
{inherit (config'.topology) nixosConfigurations;}
];
})
config.allSystems;
defaultText = "Automatically filled by nix-topology";
readOnly = true;
description = ''
The evaluated topology configuration, for each of the specified systems.
Build the output by running `nix build .#topology.$system.config.output`.
'';
};
};
perSystem = flake-parts-lib.mkPerSystemOption ({
lib,
pkgs,
...
}: {
options.topology = {
nixosConfigurations = mkOption {
type = types.lazyAttrsOf types.unspecified;
description = "All nixosSystems that should be evaluated for topology definitions.";
default = self.nixosConfigurations;
defaultText = lib.literalExpression "self.nixosConfigurations";
};
pkgs = mkOption {
type = types.unspecified;
description = "The package set to use for the topology evaluation on this system.";
default = pkgs.extend (import ./pkgs/default.nix);
defaultText = lib.literalExpression "pkgs # (module argument)";
};
modules = mkOption {
type = types.listOf types.unspecified;
description = "A list of additional topology modules to evaluate in your global topology.";
default = [];
};
};
});
};
}