-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake-module.nix
62 lines (55 loc) · 1.42 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
{
lib,
flakeLib,
...
}: {
inputs,
config,
...
}: let
cfg = config.nix-machine;
modules = flakeLib.config.merge cfg.configurations;
darwinSystem = flakeLib.systems.darwin {inherit inputs;};
asDarwinConfiguration = _machineName: machineConfig: (darwinSystem {
inherit modules;
inherit machineConfig;
});
configurationOptions = {
options = lib.mkOption {
type = lib.types.listOf lib.types.deferredModule;
default = [];
};
darwin = lib.mkOption {
type = lib.types.listOf lib.types.deferredModule;
default = [];
};
home = lib.mkOption {
type = lib.types.listOf lib.types.deferredModule;
default = [];
};
path = lib.mkOption {
type = lib.types.nullOr lib.types.path;
default = null;
};
scheme = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = null;
};
};
in {
options.nix-machine.configurations = lib.mkOption {
type = lib.types.attrsOf (lib.types.submodule {options = configurationOptions;});
default = {};
};
options.nix-machine.macos = lib.mkOption {
type = lib.types.attrsOf (lib.types.submoduleWith {
modules = modules.options;
});
default = {};
};
imports = [./configuration];
config.flake.nix-machine.lib = {
mkDarwinMachine = asDarwinConfiguration "_";
};
config.flake.darwinConfigurations = builtins.mapAttrs asDarwinConfiguration cfg.macos;
}