-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
226 lines (212 loc) · 7.53 KB
/
flake.nix
File metadata and controls
226 lines (212 loc) · 7.53 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
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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
{
description = "up";
inputs = {
nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.1";
flake-schemas.url = "https://flakehub.com/f/DeterminateSystems/flake-schemas/0";
};
outputs =
{ self, ... }@inputs:
let
inherit (inputs.nixpkgs) lib;
supportedSystems = [
"x86_64-linux"
"aarch64-linux"
"aarch64-darwin"
];
forEachSupportedSystem =
f:
lib.genAttrs supportedSystems (
system:
f {
inherit system;
pkgs = import inputs.nixpkgs {
inherit system;
config = {
allowUnfree = true;
};
overlays = [ self.overlays.default ];
};
}
);
in
{
lib = import ./lib;
overlays.default = final: prev: {
lib =
prev.lib
// (self.lib {
inherit (prev) lib;
pkgs = prev;
});
};
schemas = {
inherit (inputs.flake-schemas.schemas)
overlays
schemas
;
}
// {
inherit (self.exportedSchemas) exportedSchemas;
};
exportedSchemas =
let
mkChildren = children: { inherit children; };
in
{
exportedSchemas = {
version = 1;
doc = ''
The `exportedSchemas` flake output defines flake schemas that you intend for other flakes to use.
'';
inventory =
output:
mkChildren (
builtins.mapAttrs (schemaName: schemaDef: {
shortDescription = "A schema checker for the `${schemaName}` flake output";
evalChecks.isValidSchema =
schemaDef.version or 0 == 1
&& schemaDef ? doc
&& builtins.isString schemaDef.doc
&& schemaDef ? inventory
&& builtins.isFunction schemaDef.inventory;
what = "flake schema";
}) output
);
};
tasks = {
version = 1;
doc = ''
The `tasks` output defines tasks that you can run independently or
'';
appendSystem = true;
roles.nix-run = { };
defaultAttrPath = [ "default" ];
inventory =
output:
mkChildren (
builtins.mapAttrs (system: tasks: {
forSystems = [ system ];
children = builtins.mapAttrs (_name: task: {
forSystems = [ system ];
evalChecks.isAttrsOrDerivation = builtins.isAttrs task;
what = task.description or "runnable task";
}) tasks;
}) output
);
};
taskRunners = {
version = 1;
doc = ''
The `taskRunners` output provides task runner scripts that you can run using `nix run`.
'';
roles.nix-run = { };
appendSystem = true;
defaultAttrPath = [ "default" ];
inventory =
output:
mkChildren (
builtins.mapAttrs (system: runners: {
forSystems = [ system ];
children = builtins.mapAttrs (_name: runner: {
forSystems = [ system ];
evalChecks.isDerivation = lib.isDerivation runner;
children = builtins.mapAttrs (taskName: task: {
forSystems = [ system ];
what = task.description or "task runner";
}) (runner.tasks or { });
}) runners;
}) output
);
};
staticEnvVars = {
version = 1;
doc = ''
The `staticEnvVars` output provides sets of environment variables
that can be sourced into shells or consumed by other tools.
'';
inventory =
output:
let
isEnv = v: builtins.isAttrs v && builtins.all (s: builtins.isString s) (builtins.attrValues v);
in
mkChildren (
builtins.mapAttrs (_name: env: {
evalChecks.isAttrs = builtins.isAttrs env;
evalChecks.allStrings = isEnv env;
what = "static environment variable set";
}) output
);
};
computedEnvVars = {
version = 1;
doc = ''
The `computedEnvVars` output provides sets of environment variables
that can be sourced into shells or consumed by other tools. Unlike `staticEnvVars`, these
sets are system specific and involve some kind of computation (like using packages from Nixpkgs).
'';
appendSystem = true;
inventory =
output:
let
isEnv = v: builtins.isAttrs v && builtins.all (s: builtins.isString s) (builtins.attrValues v);
in
mkChildren (
builtins.mapAttrs (system: envs: {
forSystems = [ system ];
children = builtins.mapAttrs (_name: env: {
forSystems = [ system ];
evalChecks.isAttrs = builtins.isAttrs env;
evalChecks.allStrings = isEnv env;
what = "computed environment variable set";
}) envs;
}) output
);
};
processes = {
version = 1;
doc = ''
The `processes` flake output contains declaratively defined long-running
processes that can be orchestrated by a process tree. Each
process is evaluated through the process module and exposes a generated
`script` derivation and `bin` path.
'';
inventory = output: {
children = builtins.mapAttrs (system: procs: {
forSystems = [ system ];
children = builtins.mapAttrs (procName: proc: {
forSystems = [ system ];
shortDescription = if proc.description == null then "" else proc.description;
what = "process";
derivation = proc.script;
}) procs;
}) output;
};
};
processTrees = {
version = 1;
doc = ''
The `processTrees` output provides process-compose configurations that you can run using `nix run`.
'';
roles.nix-run = { };
appendSystem = true;
defaultAttrPath = [ "default" ];
inventory =
output:
mkChildren (
builtins.mapAttrs (system: trees: {
forSystems = [ system ];
children = builtins.mapAttrs (_name: tree: {
forSystems = [ system ];
evalChecks.isDerivation = lib.isDerivation tree;
children = builtins.mapAttrs (procName: proc: {
forSystems = [ system ];
what = if proc.description != null then proc.description else "process";
shortDescription = if proc.command != null then proc.command else "";
}) (tree.processes or { });
}) trees;
}) output
);
};
};
};
}