_guix 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664
  1. #compdef guix
  2. #
  3. # GNU Guix --- Functional package management for GNU
  4. # Copyright © 2016 Eric Le Bihan <eric.le.bihan.dev@free.fr>
  5. # Copyright © 2021 Noah Evans <noah@nevans.me>
  6. # Copyright © 2021 Brice Waegeneire <brice@waegenei.re>
  7. #
  8. # This file is part of GNU Guix.
  9. #
  10. # GNU Guix is free software; you can redistribute it and/or modify it
  11. # under the terms of the GNU General Public License as published by
  12. # the Free Software Foundation; either version 3 of the License, or (at
  13. # your option) any later version.
  14. #
  15. # GNU Guix is distributed in the hope that it will be useful, but
  16. # WITHOUT ANY WARRANTY; without even the implied warranty of
  17. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. # GNU General Public License for more details.
  19. #
  20. # You should have received a copy of the GNU General Public License
  21. # along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  22. _guix_caching_policy()
  23. {
  24. local -a old_policy
  25. old_policy=( "$1"(Nmh+24) )
  26. (( $#old_policy ))
  27. }
  28. _guix_list_actions()
  29. {
  30. _guix_actions=( $(guix system --help | sed -n 's/^ \([a-z-]\+\)\s\+.\+/\1/p') )
  31. }
  32. _guix_list_checkers()
  33. {
  34. _guix_checkers=( $(guix lint -l | sed -n 's/^- \(.\+\): .\+/\1/p') )
  35. }
  36. _guix_list_graph_types()
  37. {
  38. _guix_graph_types=( $(guix graph --list-types | sed -n 's/^ - \(.\+\): .\+/\1/p') )
  39. }
  40. _guix_list_importers()
  41. {
  42. _guix_importers=( $(guix import --help | sed -n 's/^\s\+\([a-z]\+\)$/\1/p') )
  43. }
  44. _guix_list_updaters()
  45. {
  46. _guix_updaters=( $(guix lint -l | sed -n 's/^- \(.\+\): .\+/\1/p') )
  47. }
  48. _guix_list_available_packages()
  49. {
  50. if ( [[ ${+_guix_available_packages} -eq 0 ]] || _cache_invalid GUIX_AVAILABLE_PACKAGES ) \
  51. && ! _retrieve_cache GUIX_AVAILABLE_PACKAGES; then
  52. _guix_available_packages=(${${(f)"$(guix package -A | cut -f1)"}})
  53. _guix_available_packages=("${_guix_available_packages[@]// /}")
  54. _store_cache GUIX_AVAILABLE_PACKAGES _guix_available_packages
  55. fi
  56. }
  57. _guix_list_installed_packages()
  58. {
  59. _guix_installed_packages=( $(guix package -I "^${prefix}" | cut -f1) )
  60. }
  61. (( $+functions[_guix_build] )) || _guix_build()
  62. {
  63. _arguments \
  64. {-e,--expression=}'[build the package or derivation EXPR evaluates to]:EXPR' \
  65. {-f,--file=}'[build the package or derivation that the code within FILE evaluates to]:FILE:_files' \
  66. {-m,--manifest=}'[build the packages that the manifest given in FILE evaluates to]:FILE:_files' \
  67. {-S,--source}'[build the packages source derivations]' \
  68. '--sources=[build source derivations]:TYPE:(package all transitive)' \
  69. {-s,--system=}'[attempt to build for SYSTEM (e.g. "i686-linux")]:SYSTEM' \
  70. '--target=[cross-build for TRIPLET (e.g. "armel-linux-gnu")]:TRIPLET' \
  71. {-d,--derivations}'[return the derivation paths of the given packages]' \
  72. '--check[rebuild items to check for non-determinism issues]' \
  73. '--repair[repair the specified items]' \
  74. {-r,--root=}'[make FILE a symlink to the result, and register it as a GC root]:FILE:_files' \
  75. {-v,--verbosity=}'[use the given verbosity LEVEL]:LEVEL' \
  76. {-q,--quiet}'[do not show the build log]' \
  77. '--log-file[return the log file names for the given derivations]' \
  78. {-L,--load-path=}'[prepend DIR to the package module search path]:DIR:_files -\' \
  79. {-K,--keep-failed}'[keep build tree of failed builds]' \
  80. {-k,--keep-going}'[keep going when some of the derivations fail]' \
  81. {-n,--dry-run}'[do not build the derivations]' \
  82. '--fallback[fall back to building when the substituter fails]' \
  83. '--no-substitutes[build instead of resorting to pre-built substitutes]' \
  84. '--substitute-urls=[fetch substitute from URLS if they are authorized]:URLS:_urls' \
  85. '--no-grafts[do not graft packages]' \
  86. '--no-offload[do not attempt to offload builds]' \
  87. '--max-silent-time=[mark the build as failed after SECONDS of silence]:SECONDS' \
  88. '--timeout=[mark the build as failed after SECONDS of activity]:SECONDS' \
  89. '--rounds=[build N times in a row to detect non-determinism]:N' \
  90. {-c,--cores=}'[allow the use of up to N CPU cores for the build]:N' \
  91. {-M,--max-jobs=}'[allow at most N build jobs]:N' \
  92. '--debug=[produce debugging output at LEVEL]:LEVEL' \
  93. '--help-transform[list package transformation options not shown here]' \
  94. {-V,--version}'[display version information and exit]' \
  95. '*:package:->packages'
  96. if [[ "$state" = packages ]]; then
  97. _guix_list_available_packages
  98. compadd -a -- _guix_available_packages
  99. fi
  100. }
  101. (( $+functions[_guix_challenge] )) || _guix_challenge()
  102. {
  103. _arguments \
  104. '--substitute-urls=[compare build results with those at URLS]:URLS:_urls' \
  105. '--diff=[show differences according to MODE]:MODE' \
  106. {-v,--verbose}'[show details about successful comparisons]' \
  107. {-V,--version}'[display version information and exit]' \
  108. '*:package:->packages'
  109. if [[ "$state" = packages ]]; then
  110. _guix_list_available_packages
  111. compadd -a -- _guix_available_packages
  112. fi
  113. }
  114. (( $+functions[_guix_container] )) || _guix_container()
  115. {
  116. _arguments \
  117. ':action:(exec)' \
  118. '*:args'
  119. }
  120. (( $+functions[_guix_download] )) || _guix_download()
  121. {
  122. _arguments \
  123. {-f,--format=}'[write the hash in the given format]:FMT:(nix-base32 base16 base32 hex)' \
  124. {-H,--hash=}'[use the given hash ALGORITHM]:ALGORITHM' \
  125. '--no-check-certificate[do not validate the certificate of HTTPS servers ]' \
  126. {-o,--output=}'[download to FILE]:FILE:_files' \
  127. {-V,--version}'[display version information and exit]' \
  128. '1:URL:_urls'
  129. }
  130. (( $+functions[_guix_edit] )) || _guix_edit()
  131. {
  132. _guix_list_available_packages
  133. compadd -a -- _guix_available_packages
  134. }
  135. (( $+functions[_guix_environment] )) || _guix_environment()
  136. {
  137. _arguments \
  138. {-e,--expression=}'[create environment for the package that EXPR evaluates to]:EXPR' \
  139. {-l,--load=}'[create environment for the package that the code within FILE evaluates to]:FILE:_files' \
  140. {-m,--manifest=}'[create environment with the manifest from FILE]:FILE:_files' \
  141. {-p,--profile=}'[create environment from profile at PATH]:PATH:_files -/' \
  142. '--ad-hoc[include all specified packages in the environment instead of only their inputs]' \
  143. '--pure[unset existing environment variables]' \
  144. {-E,--preserve=}'[preserve environment variables that match REGEXP]:REGEXP' \
  145. '--search-paths[display needed environment variable definitions]' \
  146. {-s,--system=}'[attempt to build for SYSTEM (e.g. "i686-linux")]:SYSTEM' \
  147. {-r,--root=}'[make FILE a symlink to the result, and register it as a GC root]:FILE:_files' \
  148. {-C,--container}'[run command within an isolated container]' \
  149. {-N,--network}'[allow containers to access the network]' \
  150. {-P,--link-profile}'[link environment profile to ~/.guix-profile within an isolated container]' \
  151. {-u,--user=}'[instead of copying the name and home of the current user into an isolated container, use the name USER with home directory /home/USER]:USER:_users' \
  152. '--no-cwd[do not share current working directory with an isolated container]' \
  153. '--share=[for containers, share writable host file system according to SPEC]:SPEC' \
  154. '--expose=[for containers, expose read-only host file system according to SPEC]:SPEC' \
  155. {-v,--verbosity=}'[use the given verbosity LEVEL]:LEVEL' \
  156. '--bootstrap[use bootstrap binaries to build the environment]' \
  157. {-L,--load-path=}'[prepend DIR to the package module search path]:DIR:_files -/' \
  158. {-K,--keep-failed}'[keep build tree of failed builds]' \
  159. {-k,--keep-going}'[keep going when some of the derivations fail]' \
  160. {-n,--dry-run}'[do not build the derivations]' \
  161. '--fallback[fall back to building when the substituter fails]' \
  162. '--no-substitutes[build instead of resorting to pre-built substitutes]' \
  163. '--substitute-urls=[fetch substitute from URLS if they are authorized]:URLS:_urls' \
  164. '--no-grafts[do not graft packages]' \
  165. '--no-offload[do not attempt to offload builds]' \
  166. '--max-silent-time=[mark the build as failed after SECONDS of silence]:SECONDS' \
  167. '--timeout=[mark the build as failed after SECONDS of activity]:SECONDS' \
  168. '--rounds=[build N times in a row to detect non-determinism]:N' \
  169. {-c,--cores=}'[allow the use of up to N CPU cores for the build]:N' \
  170. {-M,--max-jobs=}'[allow at most N build jobs]:N' \
  171. '--debug=[produce debugging output at LEVEL]:LEVEL' \
  172. '--help-transform[list package transformation options not shown here]' \
  173. {-V,--version}'[display version information and exit]' \
  174. '*:package:->packages'
  175. if [[ "$state" = packages ]]; then
  176. _guix_list_available_packages
  177. compadd -a -- _guix_available_packages
  178. fi
  179. }
  180. (( $+functions[_guix_gc] )) || _guix_gc()
  181. {
  182. _arguments \
  183. {-C,--collect-garbage=}'[collect at least MIN bytes of garbage]:MIN' \
  184. {-F,--free-space=}'[attempt to reach FREE available space in the store]:FREE' \
  185. {-d,--delete-generations=}'[delete profile generations matching PATTERN]:PATTERN' \
  186. {-D,--delete}'[attempt to delete PATHS]' \
  187. '--list-roots[list the users GC roots]' \
  188. '--list-busy[list store items used by running processes]' \
  189. '--optimize[optimize the store by deduplicating identical files]' \
  190. '--list-dead[list dead paths]' \
  191. '--list-live[list live paths]' \
  192. '--references[list the references of PATHS]' \
  193. {-R,--requisites}'[list the requisites of PATHS]' \
  194. '--referrers[list the referrers of PATHS]' \
  195. '--derivers[list the derivers of PATHS]' \
  196. '--verify=[verify the integrity of the store]:OPTS:(contents repair)' \
  197. '--list-failures[list cached build failures]' \
  198. '--clear-failures[remove PATHS from the set of cached failures]' \
  199. {-V,--version}'[display version information and exit]:V' \
  200. '1:PATH:_files -/'
  201. }
  202. (( $+functions[_guix_graph] )) || _guix_graph()
  203. {
  204. _arguments \
  205. {-b,--backend=}'[produce a graph with the given backend TYPE]:TYPE:->types' \
  206. '--list-backends[list the available graph backends]' \
  207. {-t,--type=}'[represent nodes of the given TYPE]:TYPE:->types' \
  208. '--list-types[list the available graph types]' \
  209. '--path[display the shortest path between the given nodes]' \
  210. {-e,--expression=}'[consider the package EXPR evaluates to]:EXPR' \
  211. {-s,--system=}'[consider the graph for SYSTEM (e.g. "i686-linux")]:SYSTEM' \
  212. {-L,--load-path=}'[prepend DIR to the package module search path]:DIR:_files -/' \
  213. '--help-transform[list package transformation options not shown here]' \
  214. {-V,--version}'[display version information and exit]' \
  215. '1:PACKAGE:->packages'
  216. case "$state" in
  217. types)
  218. _guix_list_graph_types
  219. compadd -a -- _guix_graph_types
  220. ;;
  221. packages)
  222. _guix_list_available_packages
  223. compadd -a -- _guix_available_packages
  224. ;;
  225. esac
  226. }
  227. (( $+functions[_guix_hash] )) || _guix_hash()
  228. {
  229. _arguments \
  230. {-x,--exclude-vcs}'[exclude version control directories]' \
  231. {-H,--hash=}'[use the given hash ALGORITHM]:ALGORITHM' \
  232. {-f,--format=}'[write the hash in the given format]:FMT:(nix-base32 base16 base32 hex)' \
  233. {-r,--recursive}'[compute the hash on FILE recursively]' \
  234. {-V,--version}'[display version information and exit]' \
  235. '1:FILE:_files'
  236. }
  237. (( $+functions[_guix_import] )) || _guix_import()
  238. {
  239. _arguments \
  240. {-V,--version}'[display version information and exit]' \
  241. '1:IMPORTER:->importer' \
  242. '*:args:'
  243. if [[ "$state" = importer ]]; then
  244. _guix_list_importers
  245. compadd -a -- _guix_importers
  246. fi
  247. }
  248. (( $+functions[_guix_lint] )) || _guix_lint()
  249. {
  250. _arguments \
  251. {-c,--checkers=}'[only run the specified checkers]:CHECKERS:->checkers' \
  252. {-x,--exclude=}'[exclude the specified checkers]:CHECKERSS:->checkers' \
  253. {-n,--no-network}'[only run checkers that do not access the network]' \
  254. {-L,--load-path=}'[prepend DIR to the package module search path]:DIR:_files -/' \
  255. {-l,--list-checkers}'[display the list of available lint checkers]' \
  256. {-V,--version}'[display version information and exit]' \
  257. '1:PACKAGE:->packages'
  258. case "$state" in
  259. checkers)
  260. _guix_list_checkers
  261. compadd -a -- _guix_checkers
  262. ;;
  263. packages)
  264. _guix_list_available_packages
  265. compadd -a -- _guix_available_packages
  266. ;;
  267. esac
  268. }
  269. (( $+functions[_guix_package] )) || _guix_package()
  270. {
  271. _arguments \
  272. {-i,--install}'[install one or more packages]: :->install' \
  273. {-e,--install-from-expression=}'[install the package EXP evaluates to]:EXP' \
  274. {-f,--install-from-file=}'[install the package evaluated from FILE]:FILE:_files' \
  275. {-r,--remove}'[remove one or more packages]: :->remove' \
  276. {-u,--upgrade=}'[upgrade all the installed packages matching REGEXP]:REGEXP' \
  277. {-m,--manifest=}'[create a new profile generation from FILE]:FILE:_files' \
  278. '--do-not-upgrade=[do not upgrade any packages matching REGEXP]:REGEXP' \
  279. '--roll-back[roll back to the previous generation]' \
  280. '--search-paths=[display needed environment variable definitions]:KINDS' \
  281. {-l,--list-generations=}'[list generations matching PATTERN]:PATTERN' \
  282. {-d,--delete-generations=}'[delete generations matching PATTERN]:PATTERN' \
  283. {-S,--switch-generation=}'[switch to a generation matching PATTERN]:PATTERN' \
  284. '--export-manifest[print a manifest for the chosen profile]' \
  285. '--export-channels[print channels for the chosen profile]' \
  286. {-p,--profile}'[use PROFILE instead of the default profile]:PROFILE:_files -/' \
  287. '--list-profiles[list the profiles]' \
  288. '--allow-collisions[do not treat collisions in the profile as an error]' \
  289. '--bootstrap[use the bootstrap Guile to build the profile]' \
  290. {-s,--search=}'[search in synopsis and description using REGEXP]:REGEXP' \
  291. {-I,--list-installed=}'[list installed packages matching REGEXP]:REGEXP' \
  292. {-A,--list-available=}'[list available packages matching REGEXP]:REGEXP' \
  293. '--show=[show details about a package]: :->show' \
  294. {-L,--load-path=}'[prepend DIR to the package module search path]:DIR:_files -/' \
  295. {-K,--keep-failed}'[keep build tree of failed builds]' \
  296. {-k,--keep-going}'[keep going when some of the derivations fail]' \
  297. {-n,--dry-run}'[do not build the derivations]' \
  298. '--fallback[fall back to building when the substituter fails]' \
  299. '--no-substitutes[build instead of resorting to pre-built substitutes]' \
  300. '--substitute-urls=[fetch substitute from URLS if they are authorized]:URLS:_urls' \
  301. '--no-grafts[do not graft packages]' \
  302. '--no-offload[do not attempt to offload builds]' \
  303. '--max-silent-time=[mark the build as failed after SECONDS of silence]:SECONDS' \
  304. '--timeout=[mark the build as failed after SECONDS of activity]:SECONDS' \
  305. '--rounds=[build N times in a row to detect non-determinism]:N' \
  306. {-c,--cores=}'[allow the use of up to N CPU cores for the build]:N' \
  307. {-M,--max-jobs=}'[allow at most N build jobs]:N' \
  308. '--debug=[produce debugging output at LEVEL]' \
  309. '--help-transform[list package transformation options not shown here]' \
  310. {-v,--verbosity=}'[use the given verbosity LEVEL]' \
  311. {-V,--version}'[display version information and exit]'
  312. case "$state" in
  313. install|show)
  314. _guix_list_available_packages
  315. compadd -a -- _guix_available_packages
  316. ;;
  317. remove)
  318. _guix_list_installed_packages
  319. compadd -a -- _guix_installed_packages
  320. ;;
  321. esac
  322. }
  323. (( $+functions[_guix_install] )) || _guix_install()
  324. {
  325. _arguments \
  326. {-p,--profile=}'[use PROFILE instead of the users default profile]:PROFILE:_files -/' \
  327. {-v,--verbosity=}'[use the given verbosity LEVEL]:LEVEL' \
  328. {-L,--load-path=}'[prepend DIR to the package module search path]:DIR:_files -/' \
  329. {-K,--keep-failed}'[keep build tree of failed builds]' \
  330. {-k,--keep-going}'[keep going when some of the derivations fail]' \
  331. {-n,--dry-run}'[do not build the derivations]' \
  332. '--fallback[fall back to building when the substituter fails]' \
  333. '--no-substitutes[build instead of resorting to pre-built substitutes]' \
  334. '--substitute-urls=[fetch substitute from URLS if they are authorized]:URLS:_urls' \
  335. '--no-grafts[do not graft packages]' \
  336. '--no-offload[do not attempt to offload builds]' \
  337. '--max-silent-time=[mark the build as failed after SECONDS of silence]:SECONDS' \
  338. '--timeout=[mark the build as failed after SECONDS of activity]:SECONDS' \
  339. '--rounds=[build N times in a row to detect non-determinism]:N' \
  340. {-c,--cores=}'[allow the use of up to N CPU cores for the build]:N' \
  341. {-M,--max-jobs=}'[allow at most N build jobs]:N' \
  342. '--debug=[produce debugging output at LEVEL]:LEVEL' \
  343. '--help-transform[list package transformation options not shown here]' \
  344. {-V,--version}'[display version information and exit]' \
  345. '*:package:->packages'
  346. if [[ "$state" = packages ]]; then
  347. _guix_list_available_packages
  348. compadd -a -- _guix_available_packages
  349. fi
  350. }
  351. (( $+functions[_guix_remove] )) || _guix_remove()
  352. {
  353. _arguments \
  354. {-p,--profile=}'[use PROFILE instead of the users default profile]:PROFILE:_files -/' \
  355. {-v,--verbosity=}'[use the given verbosity LEVEL]:LEVEL' \
  356. {-L,--load-path=}'[prepend DIR to the package module search path]:DIR:_files -/' \
  357. {-K,--keep-failed}'[keep build tree of failed builds]' \
  358. {-k,--keep-going}'[keep going when some of the derivations fail]' \
  359. {-n,--dry-run}'[do not build the derivations]' \
  360. '--fallback[fall back to building when the substituter fails]' \
  361. '--no-substitutes[build instead of resorting to pre-built substitutes]' \
  362. '--substitute-urls=[fetch substitute from URLS if they are authorized]:URLS:_urls' \
  363. '--no-grafts[do not graft packages]' \
  364. '--no-offload[do not attempt to offload builds]' \
  365. '--max-silent-time=[mark the build as failed after SECONDS of silence]:SECONDS' \
  366. '--timeout=[mark the build as failed after SECONDS of activity]:SECONDS' \
  367. '--rounds=[build N times in a row to detect non-determinism]:N' \
  368. {-c,--cores=}'[allow the use of up to N CPU cores for the build]:N' \
  369. {-M,--max-jobs=}'[allow at most N build jobs]:N' \
  370. '--debug=[produce debugging output at LEVEL]:LEVEL' \
  371. {-V,--version}'[display version information and exit]' \
  372. '*:package:->packages'
  373. if [[ "$state" = packages ]]; then
  374. _guix_list_installed_packages
  375. compadd -a -- _guix_installed_packages
  376. fi
  377. }
  378. (( $+functions[_guix_upgrade] )) || _guix_upgrade()
  379. {
  380. _arguments \
  381. {-p,--profile=}'[use PROFILE instead of the users default profile]:PROFILE:_files -/' \
  382. {-v,--verbosity=}'[use the given verbosity LEVEL]:LEVEL' \
  383. '--do-not-upgrade=[do not upgrade any packages matching REGEXP]:REGEXP' \
  384. {-L,--load-path=}'[prepend DIR to the package module search path]:DIR:_files -/' \
  385. {-K,--keep-failed}'[keep build tree of failed builds]' \
  386. {-k,--keep-going}'[keep going when some of the derivations fail]' \
  387. {-n,--dry-run}'[do not build the derivations]' \
  388. '--fallback[fall back to building when the substituter fails]' \
  389. '--no-substitutes[build instead of resorting to pre-built substitutes]' \
  390. '--substitute-urls=[fetch substitute from URLS if they are authorized]:URLS:_urls' \
  391. '--no-grafts[do not graft packages]' \
  392. '--no-offload[do not attempt to offload builds]' \
  393. '--max-silent-time=[mark the build as failed after SECONDS of silence]:SECONDS' \
  394. '--timeout=[mark the build as failed after SECONDS of activity]:SECONDS' \
  395. '--rounds=[build N times in a row to detect non-determinism]:N' \
  396. {-c,--cores=}'[allow the use of up to N CPU cores for the build]:N' \
  397. {-M,--max-jobs=}'[allow at most N build jobs]:N' \
  398. '--debug=[produce debugging output at LEVEL]:LEVEL' \
  399. '--help-transform[list package transformation options not shown here]' \
  400. {-V,--version}'[display version information and exit]' \
  401. '*:regexp'
  402. }
  403. (( $+functions[_guix_publish] )) || _guix_publish()
  404. {
  405. _arguments \
  406. {-p,--port=}'[listen on PORT]:PORT' \
  407. '--listen=[listen on the network interface for HOST]:HOST_hosts' \
  408. {-u,--user=}'[change privileges to USER as soon as possible]:USER_users' \
  409. {-a,--advertise}'[advertise on the local network]' \
  410. {-C,--compression=}'[compress archives with METHOD at LEVEL]:METHOD' \
  411. {-c,--cache=}'[cache published items to DIRECTORY]:DIRECTORY:_files -/' \
  412. '--cache-bypass-threshold=[serve store items below SIZE even when not cached]:SIZE' \
  413. '--workers=[use N workers to bake items]:N' \
  414. '--ttl=[announce narinfos can be cached for TTL seconds]:TTL' \
  415. '--negative-ttl=[announce missing narinfos can be cached for TTL seconds]:TTL' \
  416. '--nar-path=[use PATH as the prefix for nar URLs]:PATH' \
  417. '--public-key=[use FILE as the public key for signatures]:FILE:_files' \
  418. '--private-key=[use FILE as the private key for signatures]:FILE:_files' \
  419. {-r,--repl=}'[spawn REPL server on PORT]:PORT' \
  420. {-V,--version}'[display version information and exit]' \
  421. }
  422. (( $+functions[_guix_pull] )) || _guix_pull()
  423. {
  424. _arguments \
  425. {-C,--channels=}'[deploy the channels defined in FILE]:FILE:_files' \
  426. '--url=[download from the Git repository at URL]:URL:_urls' \
  427. '--commit=[download the specified COMMIT]:COMMIT' \
  428. '--branch=[download the tip of the specified BRANCH]:BRANCH' \
  429. '--allow-downgrades[allow downgrades to earlier channel revisions]' \
  430. '--disable-authentication[disable channel authentication]' \
  431. {-N,--news}'[display news compared to the previous generation]' \
  432. {-l,--list-generations=}'[list generations matching PATTERN]:PATTERN' \
  433. '--roll-back[roll back to the previous generation]' \
  434. {-d,--delete-generations=}'[delete generations matching PATTERN]:PATTERN' \
  435. {-S,--switch-generation=}'[switch to a generation matching PATTERN]:PATTERN' \
  436. {-p,--profile=}'[use PROFILE instead of ~/.config/guix/current]:PROFILE:_files -/' \
  437. {-v,--verbosity=}'[use the given verbosity LEVEL]:LEVEL' \
  438. {-s,--system=}'[attempt to build for SYSTEM (e.g. "i686-linux")]:SYSTEM' \
  439. '--bootstrap[use the bootstrap Guile to build the new Guix]' \
  440. {-L,--load-path=}'[prepend DIR to the package module search path]:DIR:_files -/' \
  441. {-K,--keep-failed}'[keep build tree of failed builds]' \
  442. {-k,--keep-going}'[keep going when some of the derivations fail]' \
  443. {-n,--dry-run}'[do not build the derivations]' \
  444. '--fallback[fall back to building when the substituter fails]' \
  445. '--no-substitutes[build instead of resorting to pre-built substitutes]' \
  446. '--substitute-urls=[fetch substitute from URLS if they are authorized]:URLS:_urls' \
  447. '--no-grafts[do not graft packages]' \
  448. '--no-offload[do not attempt to offload builds]' \
  449. '--max-silent-time=[mark the build as failed after SECONDS of silence]:SECONDS' \
  450. '--timeout=[mark the build as failed after SECONDS of activity]:SECONDS' \
  451. '--rounds=[build N times in a row to detect non-determinism]:N' \
  452. {-c,--cores=}'[allow the use of up to N CPU cores for the build]:N' \
  453. {-M,--max-jobs=}'[allow at most N build jobs]:N' \
  454. '--debug=[produce debugging output at LEVEL]:LEVEL' \
  455. {-V,--version}'[display version information and exit]'
  456. }
  457. (( $+functions[_guix_refresh] )) || _guix_refresh()
  458. {
  459. _arguments \
  460. {-e,--expression=}'[consider the package EXPR evaluates to]:EXPR' \
  461. {-u,--update}'[update source files in place]' \
  462. {-s,--select=}'[select all the packages in SUBSET, one of]:SUBSET:(core non-core)' \
  463. {-m,--manifest=}'[select all the packages from the manifest in FILE]:FILE:_files' \
  464. {-t,--type=}'[restrict to updates from the specified updaters]:UPDATER:-.updaters' \
  465. {-L,--list-updaters}'[list available updaters and exit]' \
  466. {-l,--list-dependent}'[list top-level dependent packages that would need to be rebuilt as a result of upgrading PACKAGE...]' \
  467. {-r,--recursive}'[check the PACKAGE and its inputs for upgrades]' \
  468. '--list-transitive[list all the packages that PACKAGE depends on]' \
  469. '--keyring=[use FILE as the keyring of upstream OpenPGP keys]:FILE:_files' \
  470. '--key-server=[use HOST as the OpenPGP key server]:HOST_hosts' \
  471. '--gpg=[use COMMAND as the GnuPG 2.x command]:COMMAND' \
  472. '--key-download=[handle missing OpenPGP keys according to POLICY:]:POLICY:(always interactive never)' \
  473. '--load-path=[prepend DIR to the package module search path]:DIR:_files -/' \
  474. {-V,--version}'[display version information and exit]' \
  475. '*:package:->packages'
  476. case "$state" in
  477. updaters)
  478. _guix_list_updaters
  479. compadd -a -- _guix_updaters
  480. ;;
  481. packages)
  482. _guix_list_available_packages
  483. compadd -a -- _guix_available_packages
  484. ;;
  485. esac
  486. }
  487. (( $+functions[_guix_size] )) || _guix_size()
  488. {
  489. _arguments \
  490. '--substitute-urls=[fetch substitute from URLS if they are authorized]:URLS:_urls' \
  491. {-s,--system=}'[consider packages for SYSTEM (e.g. "i686-linux")]:SYSTEM' \
  492. '--sort=[sort according to KEY]:KEY:(closure self)' \
  493. {-m,--map-file=}'[write to FILE a graphical map of disk usage]:FILE:_files' \
  494. {-L,--load-path=}'[prepend DIR to the package module search path]:DIR:_files -/' \
  495. {-V,--version}'[display version information and exit]' \
  496. '*:package:->packages'
  497. if [[ "$state" = packages ]]; then
  498. _guix_list_available_packages
  499. compadd -a -- _guix_available_packages
  500. fi
  501. }
  502. (( $+functions[_guix_system] )) || _guix_system()
  503. {
  504. _arguments \
  505. {-L,--load-path=}'[prepend DIR to the package module search path]:DIR:_files -/' \
  506. {-K,--keep-failed}'[keep build tree of failed builds]' \
  507. {-k,--keep-going}'[keep going when some of the derivations fail]' \
  508. {-n,--dry-run}'[do not build the derivations]' \
  509. '--fallback[fall back to building when the substituter fails]' \
  510. '--no-substitutes[build instead of resorting to pre-built substitutes]' \
  511. '--substitute-urls=[fetch substitute from URLS if they are authorized]:URLS:_urls' \
  512. '--no-grafts[do not graft packages]' \
  513. '--no-offload[do not attempt to offload builds]' \
  514. '--max-silent-time=[mark the build as failed after SECONDS of silence]:SECONDS' \
  515. '--timeout=[mark the build as failed after SECONDS of activity]:SECONDS' \
  516. '--rounds=[build N times in a row to detect non-determinism]:N' \
  517. {-c,--cores=}'[allow the use of up to N CPU cores for the build]:N' \
  518. {-M,--max-jobs=}'[allow at most N build jobs]:N' \
  519. '--debug=[produce debugging output at LEVEL]:LEVEL' \
  520. {-d,--derivation}'[return the derivation of the given system]' \
  521. {-e,--expression=}'[consider the operating-system EXPR evaluates to instead of reading FILE, when applicable]:EXPR' \
  522. '--allow-downgrades[for reconfigure, allow downgrades to earlier channel revisions]' \
  523. '--on-error=[apply STRATEGY when an error occurs while reading FILE]:STRATEGY:(nothing-special backtrace debug)' \
  524. '--list-image-types[list available image types]' \
  525. {-t,--image-type=}'[for image, produce an image of TYPE]:TYPE' \
  526. '--image-size=[for image, produce an image of SIZE]:SIZE' \
  527. '--no-bootloader[for init, do not install a bootloader]' \
  528. '--volatile[for image, make the root file system volatile]' \
  529. '--label=[for image, label disk image with LABEL]:LABEL' \
  530. '--save-provenance[save provenance information]' \
  531. '--share=[for vm and container, share host file system with read/write access according to SPEC]:SPEC' \
  532. '--expose=[for vm and container, expose host file system directory as read-only according to SPEC]:SPEC' \
  533. {-N,--network}'[for container, allow containers to access the network]' \
  534. {-r,--root=}'[for vm, image, container and build, make FILE a symlink to the result, and register it as a GC root]:FILE:_files' \
  535. '--full-boot[for vm, make a full boot sequence]' \
  536. '--skip-checks[skip file system and initrd module safety checks]' \
  537. '--target=[cross-build for TRIPLET (e.g. "armel-linux-gnu")]:TRIPLET' \
  538. {-v,--verbosity=}'[use the given verbosity LEVEL]:LEVEL' \
  539. '--graph-backend=[use BACKEND for extension-graphs and shepherd-graph]:BACKEND' \
  540. {-V,--version}'[display version information and exit]' \
  541. '1:action:->actions' \
  542. '*:file:_files'
  543. if [[ "$state" = actions ]]; then
  544. _guix_list_actions
  545. compadd -a -- _guix_actions
  546. fi
  547. }
  548. (( $+functions[_guix_command] )) || _guix_command()
  549. {
  550. local -a _guix_cmds
  551. _guix_cmds=(
  552. "archive:Export/import one or more packages from/to the store"
  553. "build:Build a given package"
  554. "challenge:Challenge the substitutes for a package"
  555. "container:Build and manipulate Linux containers"
  556. "copy:Copy store items remotely over SSH"
  557. "deploy:Deploy operating systems on a set of machines"
  558. "describe:Describe the channel revisions currently used"
  559. "download:Download the file at given URL and add it to the store"
  560. "edit:Edit the definitions of a package"
  561. "environment:Build an environment with a package and its dependencies"
  562. "gc:Invoke the garbage collector"
  563. "git:Operate on Git repositories"
  564. "graph:Emit a DOT representation of the dependencies of a package"
  565. "hash:Return the cryptographic hash of a file"
  566. "import:Run an importer"
  567. "install:Install packages"
  568. "lint:Run a set of checkers on a package"
  569. "offload:Set up and operate build offloading"
  570. "pack:Create application bundles"
  571. "package:Install, remove, or upgrade packages"
  572. "processes:List currently running sessions"
  573. "publish:Publish /gnu/store over HTTP."
  574. "pull:Download and deploy the latest version of Guix"
  575. "refresh:Update package definitions to match the latest version"
  576. "remove:Remove packages"
  577. "repl:Read-eval-print loop (REPL) for interactive programming"
  578. "search:Search for packages"
  579. "show:Show information about packages"
  580. "size:Report the size of a package and its dependencies"
  581. "system:Build the operating system"
  582. "time-machine:Run commands from a different revision"
  583. "upgrade:Upgrade packages"
  584. "weather:Report on the availability of pre-built package binaries"
  585. )
  586. if (( CURRENT == 1 )); then
  587. _describe -t commands 'guix command' _guix_cmds || compadd "$@"
  588. else
  589. local curcontext="$curcontext"
  590. cmd="${${_guix_cmds[(r)$words[1]:*]%%:*}}"
  591. if (( $#cmd )); then
  592. local cache_policy
  593. zstyle -s ":completion:${curcontext}:" cache-policy cache_policy
  594. if [[ -z "$cache_policy" ]]; then
  595. zstyle ":completion:${curcontext}:" cache-policy _guix_caching_policy
  596. fi
  597. curcontext="${curcontext%:*:*}:guix-${cmd}:"
  598. _call_function ret _guix_${cmd} || _message 'no more arguments'
  599. else
  600. _message "unknown guix command: $words[1]"
  601. fi
  602. return ret
  603. fi
  604. }
  605. _arguments \
  606. '(--version)--version[Display version information and exit]' \
  607. '*::guix command:_guix_command'
  608. # vim: ts=4 sts=4 sw=4 et ai
  609. # Local variables:
  610. # mode: sh
  611. # End: