blob: 18b5cd8601f52d6da8b47c575ea4269cbc811998 (
plain)
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
|
{ lib }: rec {
source = lib.types.submodule ({ config, ... }: {
options = {
type = let
known-types = lib.attrNames source-types;
type-candidates = lib.filter (k: config.${k} != null) known-types;
in lib.mkOption {
default = if lib.length type-candidates == 1
then lib.head type-candidates
else throw "cannot determine type";
type = lib.types.enum known-types;
};
derivation = lib.mkOption {
apply = x:
if lib.types.str.check x
then { text = x; }
else x;
default = null;
type = lib.types.nullOr (lib.types.either lib.types.str source-types.derivation);
};
file = lib.mkOption {
apply = x:
if lib.types.absolute-pathname.check x || lib.types.package.check x
then { path = x; }
else x;
default = null;
type = lib.types.nullOr (lib.types.oneOf [
lib.types.absolute-pathname
lib.types.package
source-types.file
]);
};
git = lib.mkOption {
default = null;
type = lib.types.nullOr source-types.git;
};
pass = lib.mkOption {
default = null;
type = lib.types.nullOr source-types.pass;
};
pipe = lib.mkOption {
apply = x:
if lib.types.absolute-pathname.check x
then { command = x; }
else x;
default = null;
type = lib.types.nullOr (lib.types.either lib.types.absolute-pathname source-types.pipe);
};
symlink = lib.mkOption {
apply = x:
if lib.types.pathname.check x
then { target = x; }
else x;
default = null;
type = lib.types.nullOr (lib.types.either lib.types.pathname source-types.symlink);
};
};
});
filter = lib.types.submodule {
options = {
type = lib.mkOption {
type = lib.types.enum ["include" "exclude"];
default = "exclude";
};
pattern = lib.mkOption {
type = lib.types.str;
};
};
};
source-types = {
derivation = lib.types.submodule {
options = {
text = lib.mkOption {
type = lib.types.str;
};
};
};
file = lib.types.submodule {
options = {
path = lib.mkOption {
type = lib.types.absolute-pathname;
};
useChecksum = lib.mkOption {
default = false;
type = lib.types.bool;
};
exclude = lib.mkOption {
apply = x:
if x != [] then
lib.warn
"file.*.exclude is deprecated in favor of file.*.filters"
x
else
x;
description = ''
DEPRECATED, use `filters`.
'';
type = lib.types.listOf lib.types.str;
default = [];
example = [".git"];
};
filters = lib.mkOption {
type = lib.types.listOf filter;
default = [];
example = [
{
type = "include";
pattern = "*.nix";
}
{
type = "include";
pattern = "*/";
}
{
type = "exclude";
pattern = "*";
}
];
};
deleteExcluded = lib.mkOption {
default = true;
type = lib.types.bool;
};
};
};
git = lib.types.submodule {
options = {
clean = {
exclude = lib.mkOption {
default = [];
type = lib.types.listOf lib.types.str;
};
};
fetchAlways = lib.mkOption {
type = lib.types.bool;
default = false;
};
ref = lib.mkOption {
type = lib.types.str; # TODO lib.types.git.ref
};
url = lib.mkOption {
type = lib.types.str; # TODO lib.types.git.url
};
shallow = lib.mkOption {
default = false;
type = lib.types.bool;
};
};
};
pass = lib.types.submodule {
options = {
dir = lib.mkOption {
type = lib.types.absolute-pathname;
};
name = lib.mkOption {
type = lib.types.pathname; # TODO relative-pathname
};
};
};
pipe = lib.types.submodule {
options = {
command = lib.mkOption {
type = lib.types.absolute-pathname;
};
};
};
symlink = lib.types.submodule {
options = {
target = lib.mkOption {
type = lib.types.pathname; # TODO relative-pathname
};
};
};
};
}
|