@@ -24,6 +24,7 @@ use super::debian::DebianTarget;
24
24
use super :: fedora:: FedoraTarget ;
25
25
use super :: redhat:: RedhatTarget ;
26
26
use super :: ubuntu:: UbuntuTarget ;
27
+ use super :: nixos:: NixOsTarget ;
27
28
use host:: telemetry:: TelemetryTarget ;
28
29
29
30
static mut LINUX_PLATFORM : LinuxPlatform = LinuxPlatform :: Centos ;
@@ -35,6 +36,7 @@ enum LinuxPlatform {
35
36
Fedora ,
36
37
Redhat ,
37
38
Ubuntu ,
39
+ NixOs ,
38
40
}
39
41
40
42
//
@@ -49,6 +51,7 @@ impl CommandTarget for Target {
49
51
& LinuxPlatform :: Fedora => FedoraTarget :: exec ( host, cmd) ,
50
52
& LinuxPlatform :: Redhat => RedhatTarget :: exec ( host, cmd) ,
51
53
& LinuxPlatform :: Ubuntu => UbuntuTarget :: exec ( host, cmd) ,
54
+ & LinuxPlatform :: NixOs => NixOsTarget :: exec ( host, cmd) ,
52
55
}
53
56
}
54
57
}
@@ -65,6 +68,7 @@ impl<P: AsRef<Path>> DirectoryTarget<P> for Target {
65
68
& LinuxPlatform :: Fedora => FedoraTarget :: directory_is_directory ( host, path) ,
66
69
& LinuxPlatform :: Redhat => RedhatTarget :: directory_is_directory ( host, path) ,
67
70
& LinuxPlatform :: Ubuntu => UbuntuTarget :: directory_is_directory ( host, path) ,
71
+ & LinuxPlatform :: NixOs => NixOsTarget :: directory_is_directory ( host, path) ,
68
72
}
69
73
}
70
74
@@ -75,6 +79,7 @@ impl<P: AsRef<Path>> DirectoryTarget<P> for Target {
75
79
& LinuxPlatform :: Fedora => FedoraTarget :: directory_exists ( host, path) ,
76
80
& LinuxPlatform :: Redhat => RedhatTarget :: directory_exists ( host, path) ,
77
81
& LinuxPlatform :: Ubuntu => UbuntuTarget :: directory_exists ( host, path) ,
82
+ & LinuxPlatform :: NixOs => NixOsTarget :: directory_exists ( host, path) ,
78
83
}
79
84
}
80
85
@@ -85,6 +90,7 @@ impl<P: AsRef<Path>> DirectoryTarget<P> for Target {
85
90
& LinuxPlatform :: Fedora => FedoraTarget :: directory_create ( host, path, recursive) ,
86
91
& LinuxPlatform :: Redhat => RedhatTarget :: directory_create ( host, path, recursive) ,
87
92
& LinuxPlatform :: Ubuntu => UbuntuTarget :: directory_create ( host, path, recursive) ,
93
+ & LinuxPlatform :: NixOs => NixOsTarget :: directory_create ( host, path, recursive) ,
88
94
}
89
95
}
90
96
@@ -95,6 +101,7 @@ impl<P: AsRef<Path>> DirectoryTarget<P> for Target {
95
101
& LinuxPlatform :: Fedora => FedoraTarget :: directory_delete ( host, path, recursive) ,
96
102
& LinuxPlatform :: Redhat => RedhatTarget :: directory_delete ( host, path, recursive) ,
97
103
& LinuxPlatform :: Ubuntu => UbuntuTarget :: directory_delete ( host, path, recursive) ,
104
+ & LinuxPlatform :: NixOs => NixOsTarget :: directory_delete ( host, path, recursive) ,
98
105
}
99
106
}
100
107
@@ -105,6 +112,7 @@ impl<P: AsRef<Path>> DirectoryTarget<P> for Target {
105
112
& LinuxPlatform :: Fedora => FedoraTarget :: directory_mv ( host, path, new_path) ,
106
113
& LinuxPlatform :: Redhat => RedhatTarget :: directory_mv ( host, path, new_path) ,
107
114
& LinuxPlatform :: Ubuntu => UbuntuTarget :: directory_mv ( host, path, new_path) ,
115
+ & LinuxPlatform :: NixOs => NixOsTarget :: directory_mv ( host, path, new_path) ,
108
116
}
109
117
}
110
118
@@ -115,6 +123,7 @@ impl<P: AsRef<Path>> DirectoryTarget<P> for Target {
115
123
& LinuxPlatform :: Fedora => FedoraTarget :: directory_get_owner ( host, path) ,
116
124
& LinuxPlatform :: Redhat => RedhatTarget :: directory_get_owner ( host, path) ,
117
125
& LinuxPlatform :: Ubuntu => UbuntuTarget :: directory_get_owner ( host, path) ,
126
+ & LinuxPlatform :: NixOs => NixOsTarget :: directory_get_owner ( host, path) ,
118
127
}
119
128
}
120
129
@@ -125,6 +134,7 @@ impl<P: AsRef<Path>> DirectoryTarget<P> for Target {
125
134
& LinuxPlatform :: Fedora => FedoraTarget :: directory_set_owner ( host, path, user, group) ,
126
135
& LinuxPlatform :: Redhat => RedhatTarget :: directory_set_owner ( host, path, user, group) ,
127
136
& LinuxPlatform :: Ubuntu => UbuntuTarget :: directory_set_owner ( host, path, user, group) ,
137
+ & LinuxPlatform :: NixOs => NixOsTarget :: directory_set_owner ( host, path, user, group) ,
128
138
}
129
139
}
130
140
@@ -135,6 +145,7 @@ impl<P: AsRef<Path>> DirectoryTarget<P> for Target {
135
145
& LinuxPlatform :: Fedora => FedoraTarget :: directory_get_mode ( host, path) ,
136
146
& LinuxPlatform :: Redhat => RedhatTarget :: directory_get_mode ( host, path) ,
137
147
& LinuxPlatform :: Ubuntu => UbuntuTarget :: directory_get_mode ( host, path) ,
148
+ & LinuxPlatform :: NixOs => NixOsTarget :: directory_get_mode ( host, path) ,
138
149
}
139
150
}
140
151
@@ -145,6 +156,7 @@ impl<P: AsRef<Path>> DirectoryTarget<P> for Target {
145
156
& LinuxPlatform :: Fedora => FedoraTarget :: directory_set_mode ( host, path, mode) ,
146
157
& LinuxPlatform :: Redhat => RedhatTarget :: directory_set_mode ( host, path, mode) ,
147
158
& LinuxPlatform :: Ubuntu => UbuntuTarget :: directory_set_mode ( host, path, mode) ,
159
+ & LinuxPlatform :: NixOs => NixOsTarget :: directory_set_mode ( host, path, mode) ,
148
160
}
149
161
}
150
162
}
@@ -161,6 +173,7 @@ impl<P: AsRef<Path>> FileTarget<P> for Target {
161
173
& LinuxPlatform :: Fedora => FedoraTarget :: file_is_file ( host, path) ,
162
174
& LinuxPlatform :: Redhat => RedhatTarget :: file_is_file ( host, path) ,
163
175
& LinuxPlatform :: Ubuntu => UbuntuTarget :: file_is_file ( host, path) ,
176
+ & LinuxPlatform :: NixOs => NixOsTarget :: file_is_file ( host, path) ,
164
177
}
165
178
}
166
179
@@ -171,6 +184,7 @@ impl<P: AsRef<Path>> FileTarget<P> for Target {
171
184
& LinuxPlatform :: Fedora => FedoraTarget :: file_exists ( host, path) ,
172
185
& LinuxPlatform :: Redhat => RedhatTarget :: file_exists ( host, path) ,
173
186
& LinuxPlatform :: Ubuntu => UbuntuTarget :: file_exists ( host, path) ,
187
+ & LinuxPlatform :: NixOs => NixOsTarget :: file_exists ( host, path) ,
174
188
}
175
189
}
176
190
@@ -181,6 +195,7 @@ impl<P: AsRef<Path>> FileTarget<P> for Target {
181
195
& LinuxPlatform :: Fedora => FedoraTarget :: file_delete ( host, path) ,
182
196
& LinuxPlatform :: Redhat => RedhatTarget :: file_delete ( host, path) ,
183
197
& LinuxPlatform :: Ubuntu => UbuntuTarget :: file_delete ( host, path) ,
198
+ & LinuxPlatform :: NixOs => NixOsTarget :: file_delete ( host, path) ,
184
199
}
185
200
}
186
201
@@ -191,6 +206,7 @@ impl<P: AsRef<Path>> FileTarget<P> for Target {
191
206
& LinuxPlatform :: Fedora => FedoraTarget :: file_mv ( host, path, new_path) ,
192
207
& LinuxPlatform :: Redhat => RedhatTarget :: file_mv ( host, path, new_path) ,
193
208
& LinuxPlatform :: Ubuntu => UbuntuTarget :: file_mv ( host, path, new_path) ,
209
+ & LinuxPlatform :: NixOs => NixOsTarget :: file_mv ( host, path, new_path) ,
194
210
}
195
211
}
196
212
@@ -201,6 +217,7 @@ impl<P: AsRef<Path>> FileTarget<P> for Target {
201
217
& LinuxPlatform :: Fedora => FedoraTarget :: file_copy ( host, path, new_path) ,
202
218
& LinuxPlatform :: Redhat => RedhatTarget :: file_copy ( host, path, new_path) ,
203
219
& LinuxPlatform :: Ubuntu => UbuntuTarget :: file_copy ( host, path, new_path) ,
220
+ & LinuxPlatform :: NixOs => NixOsTarget :: file_copy ( host, path, new_path) ,
204
221
}
205
222
}
206
223
@@ -211,6 +228,7 @@ impl<P: AsRef<Path>> FileTarget<P> for Target {
211
228
& LinuxPlatform :: Fedora => FedoraTarget :: file_get_owner ( host, path) ,
212
229
& LinuxPlatform :: Redhat => RedhatTarget :: file_get_owner ( host, path) ,
213
230
& LinuxPlatform :: Ubuntu => UbuntuTarget :: file_get_owner ( host, path) ,
231
+ & LinuxPlatform :: NixOs => NixOsTarget :: file_get_owner ( host, path) ,
214
232
}
215
233
}
216
234
@@ -221,6 +239,7 @@ impl<P: AsRef<Path>> FileTarget<P> for Target {
221
239
& LinuxPlatform :: Fedora => FedoraTarget :: file_set_owner ( host, path, user, group) ,
222
240
& LinuxPlatform :: Redhat => RedhatTarget :: file_set_owner ( host, path, user, group) ,
223
241
& LinuxPlatform :: Ubuntu => UbuntuTarget :: file_set_owner ( host, path, user, group) ,
242
+ & LinuxPlatform :: NixOs => NixOsTarget :: file_set_owner ( host, path, user, group) ,
224
243
}
225
244
}
226
245
@@ -231,6 +250,7 @@ impl<P: AsRef<Path>> FileTarget<P> for Target {
231
250
& LinuxPlatform :: Fedora => FedoraTarget :: file_get_mode ( host, path) ,
232
251
& LinuxPlatform :: Redhat => RedhatTarget :: file_get_mode ( host, path) ,
233
252
& LinuxPlatform :: Ubuntu => UbuntuTarget :: file_get_mode ( host, path) ,
253
+ & LinuxPlatform :: NixOs => NixOsTarget :: file_get_mode ( host, path) ,
234
254
}
235
255
}
236
256
@@ -241,6 +261,7 @@ impl<P: AsRef<Path>> FileTarget<P> for Target {
241
261
& LinuxPlatform :: Fedora => FedoraTarget :: file_set_mode ( host, path, mode) ,
242
262
& LinuxPlatform :: Redhat => RedhatTarget :: file_set_mode ( host, path, mode) ,
243
263
& LinuxPlatform :: Ubuntu => UbuntuTarget :: file_set_mode ( host, path, mode) ,
264
+ & LinuxPlatform :: NixOs => NixOsTarget :: file_set_mode ( host, path, mode) ,
244
265
}
245
266
}
246
267
}
@@ -257,6 +278,7 @@ impl PackageTarget for Target {
257
278
& LinuxPlatform :: Fedora => FedoraTarget :: default_provider ( host) ,
258
279
& LinuxPlatform :: Redhat => RedhatTarget :: default_provider ( host) ,
259
280
& LinuxPlatform :: Ubuntu => UbuntuTarget :: default_provider ( host) ,
281
+ & LinuxPlatform :: NixOs => NixOsTarget :: default_provider ( host) ,
260
282
}
261
283
}
262
284
}
@@ -273,6 +295,7 @@ impl ServiceTarget for Target {
273
295
& LinuxPlatform :: Fedora => FedoraTarget :: service_action ( host, name, action) ,
274
296
& LinuxPlatform :: Redhat => RedhatTarget :: service_action ( host, name, action) ,
275
297
& LinuxPlatform :: Ubuntu => UbuntuTarget :: service_action ( host, name, action) ,
298
+ & LinuxPlatform :: NixOs => NixOsTarget :: service_action ( host, name, action) ,
276
299
}
277
300
}
278
301
}
@@ -289,6 +312,7 @@ impl TelemetryTarget for Target {
289
312
& LinuxPlatform :: Fedora => FedoraTarget :: telemetry_init ( host) ,
290
313
& LinuxPlatform :: Redhat => RedhatTarget :: telemetry_init ( host) ,
291
314
& LinuxPlatform :: Ubuntu => UbuntuTarget :: telemetry_init ( host) ,
315
+ & LinuxPlatform :: NixOs => NixOsTarget :: telemetry_init ( host) ,
292
316
}
293
317
}
294
318
}
@@ -314,6 +338,10 @@ fn fingerprint_os() -> &'static LinuxPlatform {
314
338
// RedHat
315
339
else if let Ok ( _) = fs:: metadata ( "/etc/redhat-release" ) {
316
340
unsafe { LINUX_PLATFORM = LinuxPlatform :: Redhat ; }
341
+ }
342
+ // NixOS
343
+ else if let Ok ( _) = fs:: metadata ( "/etc/nixos/configuration.nix" ) {
344
+ unsafe { LINUX_PLATFORM = LinuxPlatform :: NixOs ; }
317
345
} else {
318
346
panic ! ( "Unknown Linux distro" ) ;
319
347
}
0 commit comments