-
Notifications
You must be signed in to change notification settings - Fork 17
/
nix-env.sh
710 lines (654 loc) · 54.1 KB
/
nix-env.sh
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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
#!/usr/bin/env bash
# Automatic generated, DON'T MODIFY IT.
# {{ nix-env --install
# @cmd add packages to user environment
# @alias -i
# @flag -b --prebuilt-only Use only derivations for which a substitute is registered, i.e., there is a pre-built binary available that can be downloaded in lieu of building the derivation.
# @flag -P --preserve-installed Do not remove derivations with a name matching one of the derivations being installed.
# @flag -r --remove-all Remove all previously installed packages first.
# @option -f --file[`_module_nix_path`] <path> Specifies the Nix expression (designated below as the active Nix expression) used by the --install, --upgrade, and --query --available operations to obtain derivations.
# @option -p --profile[`_module_nix_profile`] <path> Specifies the profile to be used by those operations that operate on a profile (designated below as the active profile).
# @flag --dry-run For the --install, --upgrade, --uninstall, --switch-generation, --delete-generations and --rollback operations, this flag will cause nix-env to print what would be done if this flag had not been specified, without actually doing it.
# @option --system-filter <system> By default, operations such as --query --available show derivations matching any platform.
# @flag --help Prints out a summary of the command syntax and exits.
# @flag --version Prints out the Nix version number on standard output and exits.
# @option -v --verbose[`_module_nix_verbose`] Increases the level of verbosity of diagnostic messages printed on standard error.
# @flag --quiet Decreases the level of verbosity of diagnostic messages printed on standard error.
# @option --log-format[`_module_nix_log_format`] <format> This option can be used to change the output of the log format, with format being one of:
# @flag -Q --no-build-output By default, output written by builders to standard output and standard error is echoed to the Nix command’s standard error.
# @option -j --max-jobs <number> Sets the maximum number of build jobs that Nix will perform in parallel to the specified number.
# @flag --cores Sets the value of the NIX_BUILD_CORES environment variable in the invocation of builders.
# @flag --max-silent-time Sets the maximum number of seconds that a builder can go without producing any data on standard output or standard error.
# @flag --timeout Sets the maximum number of seconds that a builder can run.
# @flag -k --keep-going Keep going in case of failed builds, to the greatest extent possible.
# @flag -K --keep-failed Specifies that in case of a build failure, the temporary directory (usually in /tmp) in which the build takes place should not be deleted.
# @flag --fallback Whenever Nix attempts to build a derivation for which substitutes are known for each output path, but realising the output paths through the substitutes fails, fall back on building the derivation.
# @flag --readonly-mode When this option is used, no attempt is made to open the Nix database.
# @option --arg*[`_module_nix_arg_name`] <name> <value> This option is accepted by nix-env, nix-instantiate, nix-shell and nix-build.
# @option --argstr*[`_module_nix_arg_name`] <name> <value> This option is like --arg, only the value is not a Nix expression but a string.
# @option -A --attr*[`_module_nix_attr`] <attrPath+> Select an attribute from the top-level Nix expression being evaluated.
# @flag -E --expr Interpret the command line arguments as a list of Nix expressions to be parsed and evaluated, rather than as a list of file names of Nix expressions.
# @option -I --include <path> Add an entry to the list of search paths used to resolve lookup paths.
# @option --option <name> <value> Set the Nix configuration option name to value.
# @flag --repair Fix corrupted or missing store paths by redownloading or rebuilding them.
# @arg args*[`_choice_package`]
--install() {
:;
}
# }} nix-env --install
# {{ nix-env --upgrade
# @cmd upgrade packages in user environment
# @alias -u
# @flag --lt Only upgrade a derivation to newer versions.
# @flag --leq In addition to upgrading to newer versions, also “upgrade” to derivations that have the same version.
# @flag --eq Only “upgrade” to derivations that have the same version.
# @flag --always In addition to upgrading to newer versions, also “upgrade” to derivations that have the same or a lower version.
# @flag -b --prebuilt-only Use only derivations for which a substitute is registered, i.e., there is a pre-built binary available that can be downloaded in lieu of building the derivation.
# @flag -P --preserve-installed Do not remove derivations with a name matching one of the derivations being installed.
# @option -f --file[`_module_nix_path`] <path> Specifies the Nix expression (designated below as the active Nix expression) used by the --install, --upgrade, and --query --available operations to obtain derivations.
# @option -p --profile[`_module_nix_profile`] <path> Specifies the profile to be used by those operations that operate on a profile (designated below as the active profile).
# @flag --dry-run For the --install, --upgrade, --uninstall, --switch-generation, --delete-generations and --rollback operations, this flag will cause nix-env to print what would be done if this flag had not been specified, without actually doing it.
# @option --system-filter <system> By default, operations such as --query --available show derivations matching any platform.
# @flag --help Prints out a summary of the command syntax and exits.
# @flag --version Prints out the Nix version number on standard output and exits.
# @option -v --verbose[`_module_nix_verbose`] Increases the level of verbosity of diagnostic messages printed on standard error.
# @flag --quiet Decreases the level of verbosity of diagnostic messages printed on standard error.
# @option --log-format[`_module_nix_log_format`] <format> This option can be used to change the output of the log format, with format being one of:
# @flag -Q --no-build-output By default, output written by builders to standard output and standard error is echoed to the Nix command’s standard error.
# @option -j --max-jobs <number> Sets the maximum number of build jobs that Nix will perform in parallel to the specified number.
# @flag --cores Sets the value of the NIX_BUILD_CORES environment variable in the invocation of builders.
# @flag --max-silent-time Sets the maximum number of seconds that a builder can go without producing any data on standard output or standard error.
# @flag --timeout Sets the maximum number of seconds that a builder can run.
# @flag -k --keep-going Keep going in case of failed builds, to the greatest extent possible.
# @flag -K --keep-failed Specifies that in case of a build failure, the temporary directory (usually in /tmp) in which the build takes place should not be deleted.
# @flag --fallback Whenever Nix attempts to build a derivation for which substitutes are known for each output path, but realising the output paths through the substitutes fails, fall back on building the derivation.
# @flag --readonly-mode When this option is used, no attempt is made to open the Nix database.
# @option --arg*[`_module_nix_arg_name`] <name> <value> This option is accepted by nix-env, nix-instantiate, nix-shell and nix-build.
# @option --argstr*[`_module_nix_arg_name`] <name> <value> This option is like --arg, only the value is not a Nix expression but a string.
# @option -A --attr*[`_module_nix_attr`] <attrPath+> Select an attribute from the top-level Nix expression being evaluated.
# @flag -E --expr Interpret the command line arguments as a list of Nix expressions to be parsed and evaluated, rather than as a list of file names of Nix expressions.
# @option -I --include <path> Add an entry to the list of search paths used to resolve lookup paths.
# @option --option <name> <value> Set the Nix configuration option name to value.
# @flag --repair Fix corrupted or missing store paths by redownloading or rebuilding them.
# @arg args*[`_choice_installed_package`]
--upgrade() {
:;
}
# }} nix-env --upgrade
# {{ nix-env --uninstall
# @cmd remove packages from user environment
# @option -f --file[`_module_nix_path`] <path> Specifies the Nix expression (designated below as the active Nix expression) used by the --install, --upgrade, and --query --available operations to obtain derivations.
# @option -p --profile[`_module_nix_profile`] <path> Specifies the profile to be used by those operations that operate on a profile (designated below as the active profile).
# @flag --dry-run For the --install, --upgrade, --uninstall, --switch-generation, --delete-generations and --rollback operations, this flag will cause nix-env to print what would be done if this flag had not been specified, without actually doing it.
# @option --system-filter <system> By default, operations such as --query --available show derivations matching any platform.
# @flag --help Prints out a summary of the command syntax and exits.
# @flag --version Prints out the Nix version number on standard output and exits.
# @option -v --verbose[`_module_nix_verbose`] Increases the level of verbosity of diagnostic messages printed on standard error.
# @flag --quiet Decreases the level of verbosity of diagnostic messages printed on standard error.
# @option --log-format[`_module_nix_log_format`] <format> This option can be used to change the output of the log format, with format being one of:
# @flag -Q --no-build-output By default, output written by builders to standard output and standard error is echoed to the Nix command’s standard error.
# @option -j --max-jobs <number> Sets the maximum number of build jobs that Nix will perform in parallel to the specified number.
# @flag --cores Sets the value of the NIX_BUILD_CORES environment variable in the invocation of builders.
# @flag --max-silent-time Sets the maximum number of seconds that a builder can go without producing any data on standard output or standard error.
# @flag --timeout Sets the maximum number of seconds that a builder can run.
# @flag -k --keep-going Keep going in case of failed builds, to the greatest extent possible.
# @flag -K --keep-failed Specifies that in case of a build failure, the temporary directory (usually in /tmp) in which the build takes place should not be deleted.
# @flag --fallback Whenever Nix attempts to build a derivation for which substitutes are known for each output path, but realising the output paths through the substitutes fails, fall back on building the derivation.
# @flag --readonly-mode When this option is used, no attempt is made to open the Nix database.
# @option --arg*[`_module_nix_arg_name`] <name> <value> This option is accepted by nix-env, nix-instantiate, nix-shell and nix-build.
# @option --argstr*[`_module_nix_arg_name`] <name> <value> This option is like --arg, only the value is not a Nix expression but a string.
# @option -A --attr*[`_module_nix_attr`] <attrPath+> Select an attribute from the top-level Nix expression being evaluated.
# @flag -E --expr Interpret the command line arguments as a list of Nix expressions to be parsed and evaluated, rather than as a list of file names of Nix expressions.
# @option -I --include <path> Add an entry to the list of search paths used to resolve lookup paths.
# @option --option <name> <value> Set the Nix configuration option name to value.
# @flag --repair Fix corrupted or missing store paths by redownloading or rebuilding them.
# @arg drvnames*[`_choice_installed_package`]
--uninstall() {
:;
}
# }} nix-env --uninstall
# {{ nix-env --set
# @cmd set profile to contain a specified derivation
# @option -f --file[`_module_nix_path`] <path> Specifies the Nix expression (designated below as the active Nix expression) used by the --install, --upgrade, and --query --available operations to obtain derivations.
# @option -p --profile[`_module_nix_profile`] <path> Specifies the profile to be used by those operations that operate on a profile (designated below as the active profile).
# @flag --dry-run For the --install, --upgrade, --uninstall, --switch-generation, --delete-generations and --rollback operations, this flag will cause nix-env to print what would be done if this flag had not been specified, without actually doing it.
# @option --system-filter <system> By default, operations such as --query --available show derivations matching any platform.
# @flag --help Prints out a summary of the command syntax and exits.
# @flag --version Prints out the Nix version number on standard output and exits.
# @option -v --verbose[`_module_nix_verbose`] Increases the level of verbosity of diagnostic messages printed on standard error.
# @flag --quiet Decreases the level of verbosity of diagnostic messages printed on standard error.
# @option --log-format[`_module_nix_log_format`] <format> This option can be used to change the output of the log format, with format being one of:
# @flag -Q --no-build-output By default, output written by builders to standard output and standard error is echoed to the Nix command’s standard error.
# @option -j --max-jobs <number> Sets the maximum number of build jobs that Nix will perform in parallel to the specified number.
# @flag --cores Sets the value of the NIX_BUILD_CORES environment variable in the invocation of builders.
# @flag --max-silent-time Sets the maximum number of seconds that a builder can go without producing any data on standard output or standard error.
# @flag --timeout Sets the maximum number of seconds that a builder can run.
# @flag -k --keep-going Keep going in case of failed builds, to the greatest extent possible.
# @flag -K --keep-failed Specifies that in case of a build failure, the temporary directory (usually in /tmp) in which the build takes place should not be deleted.
# @flag --fallback Whenever Nix attempts to build a derivation for which substitutes are known for each output path, but realising the output paths through the substitutes fails, fall back on building the derivation.
# @flag --readonly-mode When this option is used, no attempt is made to open the Nix database.
# @option --arg*[`_module_nix_arg_name`] <name> <value> This option is accepted by nix-env, nix-instantiate, nix-shell and nix-build.
# @option --argstr*[`_module_nix_arg_name`] <name> <value> This option is like --arg, only the value is not a Nix expression but a string.
# @option -A --attr*[`_module_nix_attr`] <attrPath+> Select an attribute from the top-level Nix expression being evaluated.
# @flag -E --expr Interpret the command line arguments as a list of Nix expressions to be parsed and evaluated, rather than as a list of file names of Nix expressions.
# @option -I --include <path> Add an entry to the list of search paths used to resolve lookup paths.
# @option --option <name> <value> Set the Nix configuration option name to value.
# @flag --repair Fix corrupted or missing store paths by redownloading or rebuilding them.
# @arg drvname[`_choice_installed_package`]
--set() {
:;
}
# }} nix-env --set
# {{ nix-env --set-flag
# @cmd modify meta attributes of installed packages
# @option -f --file[`_module_nix_path`] <path> Specifies the Nix expression (designated below as the active Nix expression) used by the --install, --upgrade, and --query --available operations to obtain derivations.
# @option -p --profile[`_module_nix_profile`] <path> Specifies the profile to be used by those operations that operate on a profile (designated below as the active profile).
# @flag --dry-run For the --install, --upgrade, --uninstall, --switch-generation, --delete-generations and --rollback operations, this flag will cause nix-env to print what would be done if this flag had not been specified, without actually doing it.
# @option --system-filter <system> By default, operations such as --query --available show derivations matching any platform.
# @flag --help Prints out a summary of the command syntax and exits.
# @flag --version Prints out the Nix version number on standard output and exits.
# @option -v --verbose[`_module_nix_verbose`] Increases the level of verbosity of diagnostic messages printed on standard error.
# @flag --quiet Decreases the level of verbosity of diagnostic messages printed on standard error.
# @option --log-format[`_module_nix_log_format`] <format> This option can be used to change the output of the log format, with format being one of:
# @flag -Q --no-build-output By default, output written by builders to standard output and standard error is echoed to the Nix command’s standard error.
# @option -j --max-jobs <number> Sets the maximum number of build jobs that Nix will perform in parallel to the specified number.
# @flag --cores Sets the value of the NIX_BUILD_CORES environment variable in the invocation of builders.
# @flag --max-silent-time Sets the maximum number of seconds that a builder can go without producing any data on standard output or standard error.
# @flag --timeout Sets the maximum number of seconds that a builder can run.
# @flag -k --keep-going Keep going in case of failed builds, to the greatest extent possible.
# @flag -K --keep-failed Specifies that in case of a build failure, the temporary directory (usually in /tmp) in which the build takes place should not be deleted.
# @flag --fallback Whenever Nix attempts to build a derivation for which substitutes are known for each output path, but realising the output paths through the substitutes fails, fall back on building the derivation.
# @flag --readonly-mode When this option is used, no attempt is made to open the Nix database.
# @option --arg*[`_module_nix_arg_name`] <name> <value> This option is accepted by nix-env, nix-instantiate, nix-shell and nix-build.
# @option --argstr*[`_module_nix_arg_name`] <name> <value> This option is like --arg, only the value is not a Nix expression but a string.
# @option -A --attr*[`_module_nix_attr`] <attrPath+> Select an attribute from the top-level Nix expression being evaluated.
# @flag -E --expr Interpret the command line arguments as a list of Nix expressions to be parsed and evaluated, rather than as a list of file names of Nix expressions.
# @option -I --include <path> Add an entry to the list of search paths used to resolve lookup paths.
# @option --option <name> <value> Set the Nix configuration option name to value.
# @flag --repair Fix corrupted or missing store paths by redownloading or rebuilding them.
# @arg name[`_choice_flag_name`]
# @arg value[`_choice_flag_value`]
# @arg drvnames*[`_choice_installed_package`]
--set-flag() {
:;
}
# }} nix-env --set-flag
# {{ nix-env --query
# @cmd display information about packages
# @alias -q
# @flag --installed The query operates on the store paths that are installed in the current generation of the active profile.
# @flag -a --available The query operates on the derivations that are available in the active Nix expression.
# @flag --xml Print the result in an XML representation suitable for automatic processing by other tools.
# @flag --json Print the result in a JSON representation suitable for automatic processing by other tools.
# @flag -b --prebuilt-only Show only derivations for which a substitute is registered, i.e., there is a pre-built binary available that can be downloaded in lieu of building the derivation.
# @flag -s --status Print the status of the derivation.
# @flag -P --attr-path Print the attribute path of the derivation, which can be used to unambiguously select it using the --attr option available in commands that install derivations like nix-env --install.
# @flag --no-name Suppress printing of the name attribute of each derivation.
# @flag -c --compare-versions Compare installed versions to available versions, or vice versa (if --available is given).
# @flag --system Print the system attribute of the derivation.
# @flag --drv-path Print the path of the store derivation.
# @flag --out-path Print the output path of the derivation.
# @flag --description Print a short (one-line) description of the derivation, if available.
# @flag --meta Print all of the meta-attributes of the derivation.
# @option -f --file[`_module_nix_path`] <path> Specifies the Nix expression (designated below as the active Nix expression) used by the --install, --upgrade, and --query --available operations to obtain derivations.
# @option -p --profile[`_module_nix_profile`] <path> Specifies the profile to be used by those operations that operate on a profile (designated below as the active profile).
# @flag --dry-run For the --install, --upgrade, --uninstall, --switch-generation, --delete-generations and --rollback operations, this flag will cause nix-env to print what would be done if this flag had not been specified, without actually doing it.
# @option --system-filter <system> By default, operations such as --query --available show derivations matching any platform.
# @flag --help Prints out a summary of the command syntax and exits.
# @flag --version Prints out the Nix version number on standard output and exits.
# @option -v --verbose[`_module_nix_verbose`] Increases the level of verbosity of diagnostic messages printed on standard error.
# @flag --quiet Decreases the level of verbosity of diagnostic messages printed on standard error.
# @option --log-format[`_module_nix_log_format`] <format> This option can be used to change the output of the log format, with format being one of:
# @flag -Q --no-build-output By default, output written by builders to standard output and standard error is echoed to the Nix command’s standard error.
# @option -j --max-jobs <number> Sets the maximum number of build jobs that Nix will perform in parallel to the specified number.
# @flag --cores Sets the value of the NIX_BUILD_CORES environment variable in the invocation of builders.
# @flag --max-silent-time Sets the maximum number of seconds that a builder can go without producing any data on standard output or standard error.
# @flag --timeout Sets the maximum number of seconds that a builder can run.
# @flag -k --keep-going Keep going in case of failed builds, to the greatest extent possible.
# @flag -K --keep-failed Specifies that in case of a build failure, the temporary directory (usually in /tmp) in which the build takes place should not be deleted.
# @flag --fallback Whenever Nix attempts to build a derivation for which substitutes are known for each output path, but realising the output paths through the substitutes fails, fall back on building the derivation.
# @flag --readonly-mode When this option is used, no attempt is made to open the Nix database.
# @option --arg*[`_module_nix_arg_name`] <name> <value> This option is accepted by nix-env, nix-instantiate, nix-shell and nix-build.
# @option --argstr*[`_module_nix_arg_name`] <name> <value> This option is like --arg, only the value is not a Nix expression but a string.
# @option -A --attr*[`_module_nix_attr`] <attrPath+> Select an attribute from the top-level Nix expression being evaluated.
# @flag -E --expr Interpret the command line arguments as a list of Nix expressions to be parsed and evaluated, rather than as a list of file names of Nix expressions.
# @option -I --include <path> Add an entry to the list of search paths used to resolve lookup paths.
# @option --option <name> <value> Set the Nix configuration option name to value.
# @flag --repair Fix corrupted or missing store paths by redownloading or rebuilding them.
# @arg names*
--query() {
:;
}
# }} nix-env --query
# {{ nix-env --switch-profile
# @cmd set user environment to given profile
# @alias -S
# @option -f --file[`_module_nix_path`] <path> Specifies the Nix expression (designated below as the active Nix expression) used by the --install, --upgrade, and --query --available operations to obtain derivations.
# @option -p --profile[`_module_nix_profile`] <path> Specifies the profile to be used by those operations that operate on a profile (designated below as the active profile).
# @flag --dry-run For the --install, --upgrade, --uninstall, --switch-generation, --delete-generations and --rollback operations, this flag will cause nix-env to print what would be done if this flag had not been specified, without actually doing it.
# @option --system-filter <system> By default, operations such as --query --available show derivations matching any platform.
# @flag --help Prints out a summary of the command syntax and exits.
# @flag --version Prints out the Nix version number on standard output and exits.
# @option -v --verbose[`_module_nix_verbose`] Increases the level of verbosity of diagnostic messages printed on standard error.
# @flag --quiet Decreases the level of verbosity of diagnostic messages printed on standard error.
# @option --log-format[`_module_nix_log_format`] <format> This option can be used to change the output of the log format, with format being one of:
# @flag -Q --no-build-output By default, output written by builders to standard output and standard error is echoed to the Nix command’s standard error.
# @option -j --max-jobs <number> Sets the maximum number of build jobs that Nix will perform in parallel to the specified number.
# @flag --cores Sets the value of the NIX_BUILD_CORES environment variable in the invocation of builders.
# @flag --max-silent-time Sets the maximum number of seconds that a builder can go without producing any data on standard output or standard error.
# @flag --timeout Sets the maximum number of seconds that a builder can run.
# @flag -k --keep-going Keep going in case of failed builds, to the greatest extent possible.
# @flag -K --keep-failed Specifies that in case of a build failure, the temporary directory (usually in /tmp) in which the build takes place should not be deleted.
# @flag --fallback Whenever Nix attempts to build a derivation for which substitutes are known for each output path, but realising the output paths through the substitutes fails, fall back on building the derivation.
# @flag --readonly-mode When this option is used, no attempt is made to open the Nix database.
# @option --arg*[`_module_nix_arg_name`] <name> <value> This option is accepted by nix-env, nix-instantiate, nix-shell and nix-build.
# @option --argstr*[`_module_nix_arg_name`] <name> <value> This option is like --arg, only the value is not a Nix expression but a string.
# @option -A --attr*[`_module_nix_attr`] <attrPath+> Select an attribute from the top-level Nix expression being evaluated.
# @flag -E --expr Interpret the command line arguments as a list of Nix expressions to be parsed and evaluated, rather than as a list of file names of Nix expressions.
# @option -I --include <path> Add an entry to the list of search paths used to resolve lookup paths.
# @option --option <name> <value> Set the Nix configuration option name to value.
# @flag --repair Fix corrupted or missing store paths by redownloading or rebuilding them.
# @arg path[`_module_nix_profile`]
--switch-profile() {
:;
}
# }} nix-env --switch-profile
# {{ nix-env --list-generations
# @cmd list profile generations
# @option -f --file[`_module_nix_path`] <path> Specifies the Nix expression (designated below as the active Nix expression) used by the --install, --upgrade, and --query --available operations to obtain derivations.
# @option -p --profile[`_module_nix_profile`] <path> Specifies the profile to be used by those operations that operate on a profile (designated below as the active profile).
# @flag --dry-run For the --install, --upgrade, --uninstall, --switch-generation, --delete-generations and --rollback operations, this flag will cause nix-env to print what would be done if this flag had not been specified, without actually doing it.
# @option --system-filter <system> By default, operations such as --query --available show derivations matching any platform.
# @flag --help Prints out a summary of the command syntax and exits.
# @flag --version Prints out the Nix version number on standard output and exits.
# @option -v --verbose[`_module_nix_verbose`] Increases the level of verbosity of diagnostic messages printed on standard error.
# @flag --quiet Decreases the level of verbosity of diagnostic messages printed on standard error.
# @option --log-format[`_module_nix_log_format`] <format> This option can be used to change the output of the log format, with format being one of:
# @flag -Q --no-build-output By default, output written by builders to standard output and standard error is echoed to the Nix command’s standard error.
# @option -j --max-jobs <number> Sets the maximum number of build jobs that Nix will perform in parallel to the specified number.
# @flag --cores Sets the value of the NIX_BUILD_CORES environment variable in the invocation of builders.
# @flag --max-silent-time Sets the maximum number of seconds that a builder can go without producing any data on standard output or standard error.
# @flag --timeout Sets the maximum number of seconds that a builder can run.
# @flag -k --keep-going Keep going in case of failed builds, to the greatest extent possible.
# @flag -K --keep-failed Specifies that in case of a build failure, the temporary directory (usually in /tmp) in which the build takes place should not be deleted.
# @flag --fallback Whenever Nix attempts to build a derivation for which substitutes are known for each output path, but realising the output paths through the substitutes fails, fall back on building the derivation.
# @flag --readonly-mode When this option is used, no attempt is made to open the Nix database.
# @option --arg*[`_module_nix_arg_name`] <name> <value> This option is accepted by nix-env, nix-instantiate, nix-shell and nix-build.
# @option --argstr*[`_module_nix_arg_name`] <name> <value> This option is like --arg, only the value is not a Nix expression but a string.
# @option -A --attr*[`_module_nix_attr`] <attrPath+> Select an attribute from the top-level Nix expression being evaluated.
# @flag -E --expr Interpret the command line arguments as a list of Nix expressions to be parsed and evaluated, rather than as a list of file names of Nix expressions.
# @option -I --include <path> Add an entry to the list of search paths used to resolve lookup paths.
# @option --option <name> <value> Set the Nix configuration option name to value.
# @flag --repair Fix corrupted or missing store paths by redownloading or rebuilding them.
--list-generations() {
:;
}
# }} nix-env --list-generations
# {{ nix-env --delete-generations
# @cmd delete profile generations
# @option -f --file[`_module_nix_path`] <path> Specifies the Nix expression (designated below as the active Nix expression) used by the --install, --upgrade, and --query --available operations to obtain derivations.
# @option -p --profile[`_module_nix_profile`] <path> Specifies the profile to be used by those operations that operate on a profile (designated below as the active profile).
# @flag --dry-run For the --install, --upgrade, --uninstall, --switch-generation, --delete-generations and --rollback operations, this flag will cause nix-env to print what would be done if this flag had not been specified, without actually doing it.
# @option --system-filter <system> By default, operations such as --query --available show derivations matching any platform.
# @flag --help Prints out a summary of the command syntax and exits.
# @flag --version Prints out the Nix version number on standard output and exits.
# @option -v --verbose[`_module_nix_verbose`] Increases the level of verbosity of diagnostic messages printed on standard error.
# @flag --quiet Decreases the level of verbosity of diagnostic messages printed on standard error.
# @option --log-format[`_module_nix_log_format`] <format> This option can be used to change the output of the log format, with format being one of:
# @flag -Q --no-build-output By default, output written by builders to standard output and standard error is echoed to the Nix command’s standard error.
# @option -j --max-jobs <number> Sets the maximum number of build jobs that Nix will perform in parallel to the specified number.
# @flag --cores Sets the value of the NIX_BUILD_CORES environment variable in the invocation of builders.
# @flag --max-silent-time Sets the maximum number of seconds that a builder can go without producing any data on standard output or standard error.
# @flag --timeout Sets the maximum number of seconds that a builder can run.
# @flag -k --keep-going Keep going in case of failed builds, to the greatest extent possible.
# @flag -K --keep-failed Specifies that in case of a build failure, the temporary directory (usually in /tmp) in which the build takes place should not be deleted.
# @flag --fallback Whenever Nix attempts to build a derivation for which substitutes are known for each output path, but realising the output paths through the substitutes fails, fall back on building the derivation.
# @flag --readonly-mode When this option is used, no attempt is made to open the Nix database.
# @option --arg*[`_module_nix_arg_name`] <name> <value> This option is accepted by nix-env, nix-instantiate, nix-shell and nix-build.
# @option --argstr*[`_module_nix_arg_name`] <name> <value> This option is like --arg, only the value is not a Nix expression but a string.
# @option -A --attr*[`_module_nix_attr`] <attrPath+> Select an attribute from the top-level Nix expression being evaluated.
# @flag -E --expr Interpret the command line arguments as a list of Nix expressions to be parsed and evaluated, rather than as a list of file names of Nix expressions.
# @option -I --include <path> Add an entry to the list of search paths used to resolve lookup paths.
# @option --option <name> <value> Set the Nix configuration option name to value.
# @flag --repair Fix corrupted or missing store paths by redownloading or rebuilding them.
# @arg generations*[`_choice_generation`]
--delete-generations() {
:;
}
# }} nix-env --delete-generations
# {{ nix-env --switch-generation
# @cmd set user environment to given profile generation
# @option -f --file[`_module_nix_path`] <path> Specifies the Nix expression (designated below as the active Nix expression) used by the --install, --upgrade, and --query --available operations to obtain derivations.
# @option -p --profile[`_module_nix_profile`] <path> Specifies the profile to be used by those operations that operate on a profile (designated below as the active profile).
# @flag --dry-run For the --install, --upgrade, --uninstall, --switch-generation, --delete-generations and --rollback operations, this flag will cause nix-env to print what would be done if this flag had not been specified, without actually doing it.
# @option --system-filter <system> By default, operations such as --query --available show derivations matching any platform.
# @flag --help Prints out a summary of the command syntax and exits.
# @flag --version Prints out the Nix version number on standard output and exits.
# @option -v --verbose[`_module_nix_verbose`] Increases the level of verbosity of diagnostic messages printed on standard error.
# @flag --quiet Decreases the level of verbosity of diagnostic messages printed on standard error.
# @option --log-format[`_module_nix_log_format`] <format> This option can be used to change the output of the log format, with format being one of:
# @flag -Q --no-build-output By default, output written by builders to standard output and standard error is echoed to the Nix command’s standard error.
# @option -j --max-jobs <number> Sets the maximum number of build jobs that Nix will perform in parallel to the specified number.
# @flag --cores Sets the value of the NIX_BUILD_CORES environment variable in the invocation of builders.
# @flag --max-silent-time Sets the maximum number of seconds that a builder can go without producing any data on standard output or standard error.
# @flag --timeout Sets the maximum number of seconds that a builder can run.
# @flag -k --keep-going Keep going in case of failed builds, to the greatest extent possible.
# @flag -K --keep-failed Specifies that in case of a build failure, the temporary directory (usually in /tmp) in which the build takes place should not be deleted.
# @flag --fallback Whenever Nix attempts to build a derivation for which substitutes are known for each output path, but realising the output paths through the substitutes fails, fall back on building the derivation.
# @flag --readonly-mode When this option is used, no attempt is made to open the Nix database.
# @option --arg*[`_module_nix_arg_name`] <name> <value> This option is accepted by nix-env, nix-instantiate, nix-shell and nix-build.
# @option --argstr*[`_module_nix_arg_name`] <name> <value> This option is like --arg, only the value is not a Nix expression but a string.
# @option -A --attr*[`_module_nix_attr`] <attrPath+> Select an attribute from the top-level Nix expression being evaluated.
# @flag -E --expr Interpret the command line arguments as a list of Nix expressions to be parsed and evaluated, rather than as a list of file names of Nix expressions.
# @option -I --include <path> Add an entry to the list of search paths used to resolve lookup paths.
# @option --option <name> <value> Set the Nix configuration option name to value.
# @flag --repair Fix corrupted or missing store paths by redownloading or rebuilding them.
# @arg generation[`_choice_generation`]
--switch-generation() {
:;
}
# }} nix-env --switch-generation
# {{ nix-env --rollback
# @cmd set user environment to previous generation
# @option -f --file[`_module_nix_path`] <path> Specifies the Nix expression (designated below as the active Nix expression) used by the --install, --upgrade, and --query --available operations to obtain derivations.
# @option -p --profile[`_module_nix_profile`] <path> Specifies the profile to be used by those operations that operate on a profile (designated below as the active profile).
# @flag --dry-run For the --install, --upgrade, --uninstall, --switch-generation, --delete-generations and --rollback operations, this flag will cause nix-env to print what would be done if this flag had not been specified, without actually doing it.
# @option --system-filter <system> By default, operations such as --query --available show derivations matching any platform.
# @flag --help Prints out a summary of the command syntax and exits.
# @flag --version Prints out the Nix version number on standard output and exits.
# @option -v --verbose[`_module_nix_verbose`] Increases the level of verbosity of diagnostic messages printed on standard error.
# @flag --quiet Decreases the level of verbosity of diagnostic messages printed on standard error.
# @option --log-format[`_module_nix_log_format`] <format> This option can be used to change the output of the log format, with format being one of:
# @flag -Q --no-build-output By default, output written by builders to standard output and standard error is echoed to the Nix command’s standard error.
# @option -j --max-jobs <number> Sets the maximum number of build jobs that Nix will perform in parallel to the specified number.
# @flag --cores Sets the value of the NIX_BUILD_CORES environment variable in the invocation of builders.
# @flag --max-silent-time Sets the maximum number of seconds that a builder can go without producing any data on standard output or standard error.
# @flag --timeout Sets the maximum number of seconds that a builder can run.
# @flag -k --keep-going Keep going in case of failed builds, to the greatest extent possible.
# @flag -K --keep-failed Specifies that in case of a build failure, the temporary directory (usually in /tmp) in which the build takes place should not be deleted.
# @flag --fallback Whenever Nix attempts to build a derivation for which substitutes are known for each output path, but realising the output paths through the substitutes fails, fall back on building the derivation.
# @flag --readonly-mode When this option is used, no attempt is made to open the Nix database.
# @option --arg*[`_module_nix_arg_name`] <name> <value> This option is accepted by nix-env, nix-instantiate, nix-shell and nix-build.
# @option --argstr*[`_module_nix_arg_name`] <name> <value> This option is like --arg, only the value is not a Nix expression but a string.
# @option -A --attr*[`_module_nix_attr`] <attrPath+> Select an attribute from the top-level Nix expression being evaluated.
# @flag -E --expr Interpret the command line arguments as a list of Nix expressions to be parsed and evaluated, rather than as a list of file names of Nix expressions.
# @option -I --include <path> Add an entry to the list of search paths used to resolve lookup paths.
# @option --option <name> <value> Set the Nix configuration option name to value.
# @flag --repair Fix corrupted or missing store paths by redownloading or rebuilding them.
--rollback() {
:;
}
# }} nix-env --rollback
. "$ARGC_COMPLETIONS_ROOT/utils/_argc_utils.sh"
_choice_package() {
_choice_available_cached | \
gawk -F';' -v CWORD="$ARGC_CWORD" '{if(index($2, CWORD)) { print $2 }}'
}
_choice_installed_package() {
nix-env --query --installed --json | \
yq 'to_entries | .[].value.pname'
}
_choice_flag_name() {
cat <<-'EOF'
priority Resolve package name conflicts
keep Prevent package from being upgraded
active Package is symlinked to profile
EOF
}
_choice_flag_value() {
case "$argc_name" in
priority)
;;
keep|active)
printf "%s\n" true false
;;
esac
}
_choice_generation() {
nix-env --list-generations | \
sed -n 's/^\s*\(\S\+\)\s\+\(.*\)/\1\t\2/p'
}
_choice_available() {
nix-env --query --available --json | \
yq 'to_entries | .[] | .key + ";" + .value.pname + ";" + .value.version'
}
_choice_available_cached() {
_argc_util_cache 86400 _choice_available
}
_module_nix_arg_name() {
if [[ "${argc__args[-2]}" != @(--arg|--argstr) ]]; then
return
fi
local func opt
if [[ -n "$argc_expr" ]]; then
func="${argc__positionals[0]}"
else
local file="$(_module_nix_get_file)"
func="${file:+"import $file"}"
fi
if [[ -z "$func" ]]; then
return
fi
names=($(_module_nix_eval_stdin 2>&1 <<NIX_FILE
if builtins.typeOf ($func) == "lambda" then
builtins.attrNames (builtins.functionArgs ($func))
else
""
NIX_FILE
))
if [[ $? -gt 0 ]]; then
return 1
fi
printf "%s\n" "${names[@]}"
}
_module_nix_attr() {
local defexpr func
if [[ -n "$argc_expr" ]]; then
func="${argc__positionals[0]}"
else
local file="$(_module_nix_get_file)"
if [[ -n "$file" ]]; then
func="import $file"
fi
fi
if [[ -n "$func" ]]; then
local i len args=""
len="${#argc_arg[@]}"
for ((i=0; i<$len; i+=2)); do
args+="${argc_arg[$i]} = ${argc_arg[$((i+1))]};"
done
len="${#argc_argstr[@]}"
for ((i=0; i<$len; i+=2)); do
args+="${argc_arg[$i]} = \"${argc_arg[$((i+1))]}\";"
done
defexpr="$func $args"
else
local cmd_name="$(_module_nix_cmd_name)"
if [[ "$cmd_name" == nix-env ]]; then
defexpr=$(_module_nix_gen_defexpr ~/.nix-defexpr)
elif [[ "$cmd_name" == nix ]]; then
local channels
IFS=':' read -ra channels <<< "$NIX_PATH"
channels+=( ${argc_I[@]} )
declare -A names
for channel in "${channels[@]}"; do
name="${channel%%=*}"
nix_path="${channel#*=}"
if [[ "$name" != "$channel" ]]; then
names["$name"]=1
fi
done
defexpr=$'{ '
for name in "${!names[@]}"; do
[[ "$name" == nixos-config ]] && continue
defexpr+="$name = import <${name}>; "
done
defexpr+=' }'
fi
fi
if [[ -n "$defexpr" ]]; then
_module_nix_gen_attr "$defexpr"
fi
}
_module_nix_cmd_name() {
if [[ -z "$nix_cmd_name" ]]; then
nix_cmd_name="$(basename ${argc__args[0]})"
nix_cmd_name="${nix_cmd_name%%.*}"
fi
echo "$nix_cmd_name"
}
_module_nix_eval_stdin() {
local i override
if [[ -n "$argc_I" ]]; then
override=$(IFS=':'; echo "${argc_I[*]}")
fi
override+=${override:+:}${NIX_PATH}
while [[ "$override" == *@(=|:)channel:* ]]; do
local channel=${override#*channel:}
channel="channel:"${channel%%:*}
local url="https://nixos.org/channels/"${channel:8}"/nixexprs.tar.xz"
override=${override/"$channel"/"$url"}
done
while [[ "$override" == *https://* ]]; do
local url=${override#*https://}
url="https://"${url%%:*}
local cache=$(_module_nix_resolve_url "$url")
override=${override/"$url"/"$cache"}
done
NIX_PATH=$override nix-instantiate --eval - 2> /dev/null | tr '"[]' ' '
}
_module_nix_gen_attr() {
local cur="$ARGC_CWORD"
if [[ $cur == .* ]]; then
return
fi
local defexpr="$1"
_argc_util_comp_parts .
local -a paths=(${argc__parts_prefix//./ })
paths=(${paths[*]/%/\"})
paths=(${paths[*]/#/\"})
local -a result
result=($(_module_nix_eval_stdin <<NIX_FILE
let
autocall = setOrLambda:
if builtins.isFunction setOrLambda then
setOrLambda {}
else
setOrLambda;
top = autocall ($defexpr);
names = [ ${paths[*]} ];
# Returns attr.name calling it if it's a function
reducer = set: name:
autocall (builtins.getAttr name set);
result = builtins.foldl' reducer top names; #'
in
if builtins.isAttrs result then
builtins.attrNames result
else
""
NIX_FILE
))
if [[ $? -gt 0 ]]; then
return 1
fi
if [[ -z "$argc__parts_prefix" ]]; then
printf "%s\n" "${result[@]}" | _argc_util_transform suffix=. nospace
else
printf "%s\n" "${result[@]}"
fi
}
_module_nix_gen_defexpr() {
shopt -s nullglob
declare -A result
local -a initialQueue=("$1/channels" "$1/channels_root" $(echo "$1"/*))
local -a queue=("${initialQueue[@]}")
while [[ ${#queue[@]} -gt 0 ]]; do
local current="${queue[0]}"
queue=(${queue[@]:1})
if [[ -e "$current/default.nix" ]]; then
local name
name="$(basename "$current")"
if [[ -z "${result[$name]}" ]]; then
result["$name"]=$current
fi
else
queue=($(echo "$current"/*) "${queue[@]}")
fi
done
local nix_expr="{ "
for name in "${!result[@]}"; do
local expr_path="${result[$name]}"
nix_expr+="$name = import $expr_path;"
nix_expr+=" "
done
nix_expr+="}"
echo "$nix_expr"
}
_module_nix_get_file() {
local file
local cmd_name="$(_module_nix_cmd_name)"
if [[ "$cmd_name" == @(nix-env|nix) ]]; then
file="$argc_file"
elif [[ -e shell.nix && "$cmd_name" == nix-shell ]]; then
file="shell.nix"
elif [[ -e default.nix ]]; then
file="default.nix"
fi
if [[ "$file" ]]; then
if [[ "$file" == channel:* ]]; then
file="https://nixos.org/channels/"${file:8}"/nixexprs.tar.xz"
fi
if [[ -e $file ]]; then
file=$(realpath "$file" 2>/dev/null)
elif [[ "$file" == https://* ]]; then
file=$(_module_nix_resolve_url $file)
fi
fi
printf -- "$file"
}
_module_nix_log_format() {
cat <<-'EOF'
raw This is the raw format, as outputted by nix-build.
internal-json Outputs the logs in a structured manner.
bar Only display a progress bar during the builds.
bar-with-logs Display the raw logs, with the progress bar at the bottom.
EOF
}
_module_nix_path() {
_module_nix_shortcut
_argc_util_comp_path exts:.nix
printf "%s\n" https:// http://
}
_module_nix_profile() {
target="/nix/var/nix/profiles/"
if [[ "$target" == "$ARGC_CWORD"* ]]; then
echo "$target"
else
_argc_util_comp_path
fi
}
_module_nix_resolve_url() {
local url=$1
local input="${url##*/}\0$url"
local sha
sha=$(nix-hash --flat --base32 --type sha256 <(printf "$input"))
local cache=${XDG_CACHE_HOME:-~/.cache}/nix/tarballs
local link="$cache"/"$sha"-file
if [[ -e "$link" ]]; then
echo "$cache/$(basename $(readlink $link))-unpacked"
fi
}
_module_nix_shortcut() {
echo $NIX_PATH | sed 's/:/\n/g' | sed 's/^\(\S\+\)=\(.*\)/<\1>\t\2/'
}
_module_nix_verbose() {
cat <<-'EOF'
0 “Errors only”: only print messages explaining why the Nix invocation failed.
1 “Informational”: print useful messages about what Nix is doing. This is the default.
2 “Talkative”: print more informational messages.
3 “Chatty”: print even more informational messages.
4 “Debug”: print debug information.
5 “Vomit”: print vast amounts of debug information.
EOF
}
command eval "$(argc --argc-eval "$0" "$@")"