forked from nix-community/nix-zsh-completions
-
Notifications
You must be signed in to change notification settings - Fork 1
/
_nix-store
108 lines (99 loc) · 4.02 KB
/
_nix-store
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
#compdef nix-store
#autoload
_nix-common-options
local -a _1st_arguments
_1st_arguments=(
{--realise,-r}':Build the specified store paths' \
'--gc:Perform garbage collection on the Nix store' \
'--delete:Delete store paths from the Nix store if it is safe to do so' \
{--query,-q}':Display information about store paths' \
'--add:Add paths to the Nix store' \
'--verify:Verify the consistency of the Nix database and store' \
'--verify-path:Compare the contents of each store path to the hashes stored in the database' \
'--repair-path:Attempt to repair the specified paths by redownloading them' \
'--dump:Produce a NAR file containing the contents of the given path' \
'--restore:Unpack a NAR archive, read from stdin, to the given path' \
'--export:Serialize the specified store paths to stdout in a format which can be imported' \
'--import:Read searialized store paths from stdin and add them to the Nix store' \
'--optimise:Find identical files in the Nix store and hardlink them together to reduce disk usage'\
{--read-log,-l}':Print the build log of the specified store paths' \
'--dump-db:Dump Nix database to stdout' \
'--load-db:Read a dump of the Nix database' \
'--print-env:Print the environment of a derivation as shell code' \
'--query-failed-paths:Print out store paths which failed to build' \
'--clear-failed-paths:Clear the "failed" state of the given store path' \
)
_arguments \
'*:: :->subcmds' && return 0
if (( CURRENT==1 )); then
_describe -t commands "nix-store subcommands" _1st_arguments
return
fi
case "$words[1]" in
--realise|-r)
_arguments \
$_nix_dry_run \
'--add-root[Register result as a root of the garbage collector]:Path (Hint /nix/var/nix/gcroots):_files -/'\
'--ignore-unknown[Silently ignore non-derivation paths with no substitute]' \
'*:Store Paths:_files'
;;
--gc)
_arguments \
$_nix_gc_common \
'--max-freed[Stop garbage collection once this many bytes has been freed]:Bytes:( )'
;;
--delete)
_arguments \
'--ignore-liveness[Ignore reachability from roots]' \
'*::Store path to garbage collect:_files'
;;
--query|-q)
local -a _queries
_queries=(
'--outputs:Print the output paths of the given store derivations' \
{--requisites,-R}':Print the closure of the given store paths' \
'--references:Print immediate dependencies of the given store paths' \
'--referrers:Print store paths which refer to these paths' \
'--referrers-closure:Print the closure under the referrers relation' \
'--deriver:Print the deriver of the store paths' \
'--graph:Print the references graph of the store paths in Graphviz format' \
'--tree:Print the references graph of the store paths as an ASCII tree' \
'--binding:Print the value of an attribute of the store derivations' \
'--hash:Print the SHA-256 hash of the contents of the store paths' \
'--size:Print the size in bytes of the contents of the store paths' \
'--roots:Print the garbage collector roots that point to the store paths' \
)
local -a _query_common
_query_common=(
'(--use-output -u)'{--use-output,-u}'[Apply the query to the output path of any store derivations]' \
'(--force-realise -f)'{--force-realise,-f}'[Realise each argument to the query first]' \
)
if (( CURRENT == 2 )); then
_describe -t commands "Query subcommands" _queries
return
fi
case "$words[2]" in
--requisites|-R)
_arguments $_query_common \
'--include-outputs[Also include the output paths of store derivations]' \
'*: :_files'
;;
*)
_arguments $_query_common \
'*: :_files'
;;
esac
;;
--verify)
_arguments \
'--check-contents[Compute and validate the SHA-256 hash of each store item]' \
'--repair[Attempt to repair invalid or missing paths by redownloading them]'
;;
--dump-db|--load-db|--query-failed-paths)
# Nothing to complete
;;
*)
_arguments \
'*: :_files'
;;
esac