-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathrequest.nix
77 lines (76 loc) · 1.9 KB
/
request.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
/*
This module holds the main data structure that's used when handling a
"request" from the user to generate a configuration file.
*/
{
lib,
config,
engines,
...
}:
with lib; let
hook = types.submodule ({
config,
lib,
...
}: {
options = {
# TODO: Make this a list
extra = mkOption {
type = types.either types.str (types.functionTo types.str);
description = "Shell code to run when the file is updated";
default = "";
};
mode = mkOption {
type = types.str;
description = "The output mode to use (copy or link)";
default = "link";
};
};
});
in {
freeformType = types.anything;
options = {
data = mkOption {
type = types.anything;
description = "The raw configuration data";
};
engine = mkOption {
type = types.functionTo types.package;
description = "The engine to use for generating the derivation";
default = engines.nix {};
};
format = mkOption {
type = types.str;
description = "The format of the output file";
default = (
let
parts = splitString "." config.output;
in
builtins.elemAt parts ((builtins.length parts) - 1)
);
};
hook = mkOption {
type = hook;
description = "Additional options for controlling hook generation";
default = {};
};
apply = mkOption {
type = types.functionTo types.anything;
description = "Apply this transformation to `data`";
default = x: x;
};
output = mkOption {
type = types.str;
description = "The relative path to link the generated file";
};
root = mkOption {
type = types.path;
description = "The root path from which the relative path is derived";
default =
if builtins.getEnv "PRJ_ROOT" == ""
then ./.
else /. + (builtins.getEnv "PRJ_ROOT");
};
};
}