_guix 32 KB

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