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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
|
{
config,
lib,
withSystem,
inputs,
self,
...
}:
let
nixosSystem =
{
nixpkgs,
modules,
specialArgs,
...
}@args:
nixpkgs.lib.nixosSystem (
lib.removeAttrs args [ "nixpkgs" ]
// {
modules = modules ++ builtins.attrValues (self.nixosModules or [ ]);
specialArgs = specialArgs // {
inherit inputs;
};
}
);
darwinSystem =
{
nix-darwin,
modules,
specialArgs,
...
}@args:
nix-darwin.lib.darwinSystem (
lib.removeAttrs args [ "nix-darwin" ]
// {
modules = modules ++ builtins.attrValues (self.darwinModules or { });
specialArgs = specialArgs // {
inherit inputs;
};
}
);
homeManagerConfiguration =
{
modules,
extraSpecialArgs,
...
}@args:
inputs.home-manager.lib.homeManagerConfiguration (
args
// {
modules = modules ++ builtins.attrValues (self.homeModules or self.homeManagerModules or { });
extraSpecialArgs = extraSpecialArgs // {
inherit inputs;
};
}
);
modulesOption = lib.mkOption {
type = lib.types.listOf lib.types.unspecified;
default = [ ];
description = ''
List of modules to use in the configuration
'';
};
specialArgsOption = lib.mkOption {
type = lib.types.lazyAttrsOf lib.types.raw;
default = { };
description = ''
Extra arguments to pass to the configuration
'';
};
freeformType = lib.types.attrsOf lib.types.raw;
nixosConfigurationSubmodule = {
inherit freeformType;
options = {
nixpkgs = lib.mkOption {
type = lib.types.lazyAttrsOf lib.types.raw;
default = inputs.nixpkgs or (throw "Could not find flake input `nixpkgs`");
description = ''
Instance of nixpkgs to use `lib.nixosSystem` from
'';
example = lib.literalExpression ''
inputs.nixpkgs-stable
'';
};
modules = modulesOption;
specialArgs = specialArgsOption;
};
};
homeConfigurationSubmodule = {
inherit freeformType;
options = {
pkgs = lib.mkOption {
type = lib.types.lazyAttrsOf lib.types.raw;
default = withSystem "x86_64-linux" ({ pkgs, ... }: pkgs);
description = ''
Instance of nixpkgs to use with the configuration
'';
example = lib.literalExpression ''
inputs.nixpkgs.legacyPackages.aarch64-darwin
'';
};
modules = modulesOption;
extraSpecialArgs = specialArgsOption;
};
};
darwinConfigurationSubmodule = {
inherit freeformType;
options = {
nix-darwin = lib.mkOption {
type = lib.types.lazyAttrsOf lib.types.raw;
default =
inputs.nix-darwin or inputs.darwin
or (throw "Could not find flake input `nixpkgs` or `nix-darwin`");
description = ''
Instance of nix-darwin to use `lib.nix-darwin` from
'';
};
modules = modulesOption;
specialArgs = specialArgsOption;
};
};
in
{
options = {
nixosConfigurations = lib.mkOption {
type = lib.types.lazyAttrsOf (lib.types.submodule nixosConfigurationSubmodule);
default = { };
apply = lib.mapAttrs (lib.const nixosSystem);
description = ''
Map of configuration names and arguments to `nixosSystem`
'';
example = lib.literalExpression ''
{
my-machine = { modules = [ ./configuration.nix ]; };
}
'';
};
homeConfigurations = lib.mkOption {
type = lib.types.lazyAttrsOf (lib.types.submodule homeConfigurationSubmodule);
default = { };
apply = lib.mapAttrs (lib.const homeManagerConfiguration);
description = ''
Map of configuration names and arguments to `homeManagerConfiguration`
'';
example = lib.literalExpression ''
{
me = { pkgs = nixpkgs.legacyPackages.x86_64-linux; };
}
'';
};
darwinConfigurations = lib.mkOption {
type = lib.types.lazyAttrsOf (lib.types.submodule darwinConfigurationSubmodule);
default = { };
apply = lib.mapAttrs (lib.const darwinSystem);
description = ''
Map of configuration names and arguments to `darwinSystem`
'';
example = lib.literalExpression ''
{
my-mac = { modules = [ ./darwin-configuration.nix ]; };
}
'';
};
};
config.flake = {
inherit (config) nixosConfigurations homeConfigurations darwinConfigurations;
/*
nixosConfigurations = lib.mapAttrs (lib.const nixosSystem) config.nixosConfigurations;
homeConfigurations = lib.mapAttrs (lib.const homeManagerConfiguration) config.homeConfigurations;
darwinConfigurations = lib.mapAttrs (lib.const darwinSystem) config.darwinConfigurations;
*/
};
}
|