-
-
Notifications
You must be signed in to change notification settings - Fork 32
/
_nixos-container
70 lines (63 loc) · 2 KB
/
_nixos-container
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
#compdef nixos-container
#autoload
_nix-common-options
_containers () {
containers=($(nixos-container list))
_wanted containers expl 'containers' compadd -a containers
}
local -a _1st_arguments
_1st_arguments=(
'list:Show list of containers'\
'create:Create a container'\
'destroy:Destroy a container'\
'start:Start a container'\
'stop:Stop a container'\
'status:Get status of a container'\
'update:Update container'\
'login:Login to a container'\
'root-login:Login to a container as root (no password needed)'\
'run:Run a container'\
'show-ip:Display the IP of a container'\
'show-host-key:Display the host key of a container'
)
_arguments \
'(- 1 *)--help[Display help]'\
'*:: :->subcmds' && return 0
if (( CURRENT==1 )); then
_describe -t commands "nixos-container subcommands" _1st_arguments
return
fi
local _container_name='1:Container Name:_containers';
local _container_config='--config[Config]:Config:( )';
local _container_file='--config-file[Path to the container config file]:Path:_files';
case "$words[1]" in
create)
_arguments\
$_container_name\
$_container_config\
$_container_file\
'--system-path[System path]:Path:_files'\
'--ensure-unique-name[Avoid name conflicts with other containers]'\
'--auto-start[Start the container immediately]'\
'--nixos-path[Path to <nixpkgs/nixos>]:Path:_files'\
'--host-address[Host IP of the veth interface]:host address:'\
'--local-address[IPv4 address assined to the interface in the container]:local address:'\
'--bridge[Put the host-side of the veth-pair into the named bridge]:Bridge interface'\
'--port[Port forwarding]:port forwarding'
;;
run)
# TODO: There are a few more arguments in this case
_arguments\
$_container_name\
;;
update)
_arguments\
$_container_name\
$_container_config\
$_container_file
;;
destroy|start|stop|status|login|root-login|show-ip|show-host-key)
_arguments\
$_container_name
;;
esac