contributing.texi 83 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984
  1. @node Contributing
  2. @chapter Contributing
  3. This project is a cooperative effort, and we need your help to make it
  4. grow! Please get in touch with us on @email{guix-devel@@gnu.org} and
  5. @code{#guix} on the Libera Chat IRC network. We welcome ideas, bug
  6. reports, patches, and anything that may be helpful to the project. We
  7. particularly welcome help on packaging (@pxref{Packaging Guidelines}).
  8. @cindex code of conduct, of contributors
  9. @cindex contributor covenant
  10. We want to provide a warm, friendly, and harassment-free environment, so
  11. that anyone can contribute to the best of their abilities. To this end
  12. our project uses a ``Contributor Covenant'', which was adapted from
  13. @url{https://contributor-covenant.org/}. You can find a local version in
  14. the @file{CODE-OF-CONDUCT} file in the source tree.
  15. Contributors are not required to use their legal name in patches and
  16. on-line communication; they can use any name or pseudonym of their
  17. choice.
  18. @menu
  19. * Building from Git:: The latest and greatest.
  20. * Running Guix Before It Is Installed:: Hacker tricks.
  21. * The Perfect Setup:: The right tools.
  22. * Packaging Guidelines:: Growing the distribution.
  23. * Coding Style:: Hygiene of the contributor.
  24. * Submitting Patches:: Share your work.
  25. * Tracking Bugs and Patches:: Keeping it all organized.
  26. * Commit Access:: Pushing to the official repository.
  27. * Updating the Guix Package:: Updating the Guix package definition.
  28. * Translating Guix:: Make Guix speak your native language.
  29. @end menu
  30. @node Building from Git
  31. @section Building from Git
  32. If you want to hack Guix itself, it is recommended to use the latest
  33. version from the Git repository:
  34. @example
  35. git clone https://git.savannah.gnu.org/git/guix.git
  36. @end example
  37. @cindex authentication, of a Guix checkout
  38. How do you ensure that you obtained a genuine copy of the repository?
  39. To do that, run @command{guix git authenticate}, passing it the commit
  40. and OpenPGP fingerprint of the @dfn{channel introduction}
  41. (@pxref{Invoking guix git authenticate}):
  42. @c The commit and fingerprint below must match those of the channel
  43. @c introduction in '%default-channels'.
  44. @example
  45. git fetch origin keyring:keyring
  46. guix git authenticate 9edb3f66fd807b096b48283debdcddccfea34bad \
  47. "BBB0 2DDF 2CEA F6A8 0D1D E643 A2A0 6DF2 A33A 54FA"
  48. @end example
  49. @noindent
  50. This command completes with exit code zero on success; it prints an
  51. error message and exits with a non-zero code otherwise.
  52. As you can see, there is a chicken-and-egg problem: you first need to
  53. have Guix installed. Typically you would install Guix System
  54. (@pxref{System Installation}) or Guix on top of another distro
  55. (@pxref{Binary Installation}); in either case, you would verify the
  56. OpenPGP signature on the installation medium. This ``bootstraps'' the
  57. trust chain.
  58. The easiest way to set up a development environment for Guix is, of
  59. course, by using Guix! The following command starts a new shell where
  60. all the dependencies and appropriate environment variables are set up to
  61. hack on Guix:
  62. @example
  63. guix shell -D guix --pure
  64. @end example
  65. @xref{Invoking guix shell}, for more information on that command.
  66. If you are unable to use Guix when building Guix from a checkout, the
  67. following are the required packages in addition to those mentioned in the
  68. installation instructions (@pxref{Requirements}).
  69. @itemize
  70. @item @url{https://gnu.org/software/autoconf/, GNU Autoconf};
  71. @item @url{https://gnu.org/software/automake/, GNU Automake};
  72. @item @url{https://gnu.org/software/gettext/, GNU Gettext};
  73. @item @url{https://gnu.org/software/texinfo/, GNU Texinfo};
  74. @item @url{https://www.graphviz.org/, Graphviz};
  75. @item @url{https://www.gnu.org/software/help2man/, GNU Help2man (optional)}.
  76. @end itemize
  77. On Guix, extra dependencies can be added by instead running @command{guix
  78. shell}:
  79. @example
  80. guix shell -D guix help2man git strace --pure
  81. @end example
  82. From there you can generate the build system infrastructure
  83. using Autoconf and Automake:
  84. @example
  85. ./bootstrap
  86. @end example
  87. If you get an error like this one:
  88. @example
  89. configure.ac:46: error: possibly undefined macro: PKG_CHECK_MODULES
  90. @end example
  91. @noindent
  92. it probably means that Autoconf couldn’t find @file{pkg.m4}, which is
  93. provided by pkg-config. Make sure that @file{pkg.m4} is available. The
  94. same holds for the @file{guile.m4} set of macros provided by Guile. For
  95. instance, if you installed Automake in @file{/usr/local}, it wouldn’t
  96. look for @file{.m4} files in @file{/usr/share}. In that case, you have
  97. to invoke the following command:
  98. @example
  99. export ACLOCAL_PATH=/usr/share/aclocal
  100. @end example
  101. @xref{Macro Search Path,,, automake, The GNU Automake Manual}, for
  102. more information.
  103. Then, run:
  104. @example
  105. ./configure --localstatedir=/var
  106. @end example
  107. @noindent
  108. ... where @file{/var} is the normal @code{localstatedir} value
  109. (@pxref{The Store}, for information about this). Note that you will
  110. probably not run @command{make install} at the end (you don't have to)
  111. but it's still important to pass the right @code{localstatedir}.
  112. Finally, you can build Guix and, if you feel so inclined, run the tests
  113. (@pxref{Running the Test Suite}):
  114. @example
  115. make
  116. make check
  117. @end example
  118. @noindent
  119. If anything fails, take a look at installation instructions
  120. (@pxref{Installation}) or send a message to the
  121. @email{guix-devel@@gnu.org, mailing list}.
  122. From there on, you can authenticate all the commits included in your
  123. checkout by running:
  124. @example
  125. make authenticate
  126. @end example
  127. The first run takes a couple of minutes, but subsequent runs are faster.
  128. Or, when your configuration for your local Git repository doesn't match
  129. the default one, you can provide the reference for the @code{keyring}
  130. branch through the variable @code{GUIX_GIT_KEYRING}. The following
  131. example assumes that you have a Git remote called @samp{myremote}
  132. pointing to the official repository:
  133. @example
  134. make authenticate GUIX_GIT_KEYRING=myremote/keyring
  135. @end example
  136. @quotation Note
  137. You are advised to run @command{make authenticate} after every
  138. @command{git pull} invocation. This ensures you keep receiving valid
  139. changes to the repository.
  140. @end quotation
  141. After updating the repository, @command{make} might fail with an error
  142. similar to the following example:
  143. @example
  144. error: failed to load 'gnu/packages/dunst.scm':
  145. ice-9/eval.scm:293:34: In procedure abi-check: #<record-type <origin>>: record ABI mismatch; recompilation needed
  146. @end example
  147. This means that one of the record types that Guix defines (in this
  148. example, the @code{origin} record) has changed, and all of guix needs
  149. to be recompiled to take that change into account. To do so, run
  150. @command{make clean-go} followed by @command{make}.
  151. @node Running Guix Before It Is Installed
  152. @section Running Guix Before It Is Installed
  153. In order to keep a sane working environment, you will find it useful to
  154. test the changes made in your local source tree checkout without
  155. actually installing them. So that you can distinguish between your
  156. ``end-user'' hat and your ``motley'' costume.
  157. To that end, all the command-line tools can be used even if you have not
  158. run @code{make install}. To do that, you first need to have an
  159. environment with all the dependencies available (@pxref{Building from
  160. Git}), and then simply prefix each command with @command{./pre-inst-env}
  161. (the @file{pre-inst-env} script lives in the top build tree of Guix; it
  162. is generated by running @command{./bootstrap} followed by
  163. @command{./configure}). As an example, here is how you would build the
  164. @code{hello} package as defined in your working tree (this assumes
  165. @command{guix-daemon} is already running on your system; it's OK if it's
  166. a different version):
  167. @example
  168. $ ./pre-inst-env guix build hello
  169. @end example
  170. @noindent
  171. Similarly, an example for a Guile session using the Guix modules:
  172. @example
  173. $ ./pre-inst-env guile -c '(use-modules (guix utils)) (pk (%current-system))'
  174. ;;; ("x86_64-linux")
  175. @end example
  176. @noindent
  177. @cindex REPL
  178. @cindex read-eval-print loop
  179. @dots{} and for a REPL (@pxref{Using Guile Interactively,,, guile, Guile
  180. Reference Manual}):
  181. @example
  182. $ ./pre-inst-env guile
  183. scheme@@(guile-user)> ,use(guix)
  184. scheme@@(guile-user)> ,use(gnu)
  185. scheme@@(guile-user)> (define snakes
  186. (fold-packages
  187. (lambda (package lst)
  188. (if (string-prefix? "python"
  189. (package-name package))
  190. (cons package lst)
  191. lst))
  192. '()))
  193. scheme@@(guile-user)> (length snakes)
  194. $1 = 361
  195. @end example
  196. If you are hacking on the daemon and its supporting code or if
  197. @command{guix-daemon} is not already running on your system, you can
  198. launch it straight from the build tree@footnote{The @option{-E} flag to
  199. @command{sudo} guarantees that @code{GUILE_LOAD_PATH} is correctly set
  200. such that @command{guix-daemon} and the tools it uses can find the Guile
  201. modules they need.}:
  202. @example
  203. $ sudo -E ./pre-inst-env guix-daemon --build-users-group=guixbuild
  204. @end example
  205. The @command{pre-inst-env} script sets up all the environment variables
  206. necessary to support this, including @env{PATH} and @env{GUILE_LOAD_PATH}.
  207. Note that @command{./pre-inst-env guix pull} does @emph{not} upgrade the
  208. local source tree; it simply updates the @file{~/.config/guix/current}
  209. symlink (@pxref{Invoking guix pull}). Run @command{git pull} instead if
  210. you want to upgrade your local source tree.
  211. Sometimes, especially if you have recently updated your repository,
  212. running @command{./pre-inst-env} will print a message similar to the
  213. following example:
  214. @example
  215. ;;; note: source file /home/user/projects/guix/guix/progress.scm
  216. ;;; newer than compiled /home/user/projects/guix/guix/progress.go
  217. @end example
  218. This is only a note and you can safely ignore it. You can get rid of
  219. the message by running @command{make -j4}. Until you do, Guile will run
  220. slightly slower because it will interpret the code instead of using
  221. prepared Guile object (@file{.go}) files.
  222. You can run @command{make} automatically as you work using
  223. @command{watchexec} from the @code{watchexec} package. For example,
  224. to build again each time you update a package file, you can run
  225. @samp{watchexec -w gnu/packages make -j4}.
  226. @node The Perfect Setup
  227. @section The Perfect Setup
  228. The Perfect Setup to hack on Guix is basically the perfect setup used
  229. for Guile hacking (@pxref{Using Guile in Emacs,,, guile, Guile Reference
  230. Manual}). First, you need more than an editor, you need
  231. @url{https://www.gnu.org/software/emacs, Emacs}, empowered by the
  232. wonderful @url{https://nongnu.org/geiser/, Geiser}. To set that up, run:
  233. @example
  234. guix package -i emacs guile emacs-geiser emacs-geiser-guile
  235. @end example
  236. Geiser allows for interactive and incremental development from within
  237. Emacs: code compilation and evaluation from within buffers, access to
  238. on-line documentation (docstrings), context-sensitive completion,
  239. @kbd{M-.} to jump to an object definition, a REPL to try out your code,
  240. and more (@pxref{Introduction,,, geiser, Geiser User Manual}). For
  241. convenient Guix development, make sure to augment Guile’s load path so
  242. that it finds source files from your checkout:
  243. @lisp
  244. ;; @r{Assuming the Guix checkout is in ~/src/guix.}
  245. (with-eval-after-load 'geiser-guile
  246. (add-to-list 'geiser-guile-load-path "~/src/guix"))
  247. @end lisp
  248. To actually edit the code, Emacs already has a neat Scheme mode. But in
  249. addition to that, you must not miss
  250. @url{https://www.emacswiki.org/emacs/ParEdit, Paredit}. It provides
  251. facilities to directly operate on the syntax tree, such as raising an
  252. s-expression or wrapping it, swallowing or rejecting the following
  253. s-expression, etc.
  254. @cindex code snippets
  255. @cindex templates
  256. @cindex reducing boilerplate
  257. We also provide templates for common git commit messages and package
  258. definitions in the @file{etc/snippets} directory. These templates can
  259. be used with @url{https://joaotavora.github.io/yasnippet/, YASnippet} to
  260. expand short trigger strings to interactive text snippets. You may want
  261. to add the snippets directory to the @var{yas-snippet-dirs} variable in
  262. Emacs.
  263. @lisp
  264. ;; @r{Assuming the Guix checkout is in ~/src/guix.}
  265. (with-eval-after-load 'yasnippet
  266. (add-to-list 'yas-snippet-dirs "~/src/guix/etc/snippets"))
  267. @end lisp
  268. The commit message snippets depend on @url{https://magit.vc/, Magit} to
  269. display staged files. When editing a commit message type @code{add}
  270. followed by @kbd{TAB} to insert a commit message template for adding a
  271. package; type @code{update} followed by @kbd{TAB} to insert a template
  272. for updating a package; type @code{https} followed by @kbd{TAB} to
  273. insert a template for changing the home page URI of a package to HTTPS.
  274. The main snippet for @code{scheme-mode} is triggered by typing
  275. @code{package...} followed by @kbd{TAB}. This snippet also inserts the
  276. trigger string @code{origin...}, which can be expanded further. The
  277. @code{origin} snippet in turn may insert other trigger strings ending on
  278. @code{...}, which also can be expanded further.
  279. @cindex insert or update copyright
  280. @cindex @code{M-x guix-copyright}
  281. @cindex @code{M-x copyright-update}
  282. We additionally provide insertion and automatic update of a copyright in
  283. @file{etc/copyright.el}. You may want to set your full name, mail, and
  284. load a file.
  285. @lisp
  286. (setq user-full-name "Alice Doe")
  287. (setq user-mail-address "alice@@mail.org")
  288. ;; @r{Assuming the Guix checkout is in ~/src/guix.}
  289. (load-file "~/src/guix/etc/copyright.el")
  290. @end lisp
  291. To insert a copyright at the current line invoke @code{M-x guix-copyright}.
  292. To update a copyright you need to specify a @code{copyright-names-regexp}.
  293. @lisp
  294. (setq copyright-names-regexp
  295. (format "%s <%s>" user-full-name user-mail-address))
  296. @end lisp
  297. You can check if your copyright is up to date by evaluating @code{M-x
  298. copyright-update}. If you want to do it automatically after each buffer
  299. save then add @code{(add-hook 'after-save-hook 'copyright-update)} in
  300. Emacs.
  301. @node Packaging Guidelines
  302. @section Packaging Guidelines
  303. @cindex packages, creating
  304. The GNU distribution is nascent and may well lack some of your favorite
  305. packages. This section describes how you can help make the distribution
  306. grow.
  307. Free software packages are usually distributed in the form of
  308. @dfn{source code tarballs}---typically @file{tar.gz} files that contain
  309. all the source files. Adding a package to the distribution means
  310. essentially two things: adding a @dfn{recipe} that describes how to
  311. build the package, including a list of other packages required to build
  312. it, and adding @dfn{package metadata} along with that recipe, such as a
  313. description and licensing information.
  314. In Guix all this information is embodied in @dfn{package definitions}.
  315. Package definitions provide a high-level view of the package. They are
  316. written using the syntax of the Scheme programming language; in fact,
  317. for each package we define a variable bound to the package definition,
  318. and export that variable from a module (@pxref{Package Modules}).
  319. However, in-depth Scheme knowledge is @emph{not} a prerequisite for
  320. creating packages. For more information on package definitions,
  321. @pxref{Defining Packages}.
  322. Once a package definition is in place, stored in a file in the Guix
  323. source tree, it can be tested using the @command{guix build} command
  324. (@pxref{Invoking guix build}). For example, assuming the new package is
  325. called @code{gnew}, you may run this command from the Guix build tree
  326. (@pxref{Running Guix Before It Is Installed}):
  327. @example
  328. ./pre-inst-env guix build gnew --keep-failed
  329. @end example
  330. Using @code{--keep-failed} makes it easier to debug build failures since
  331. it provides access to the failed build tree. Another useful
  332. command-line option when debugging is @code{--log-file}, to access the
  333. build log.
  334. If the package is unknown to the @command{guix} command, it may be that
  335. the source file contains a syntax error, or lacks a @code{define-public}
  336. clause to export the package variable. To figure it out, you may load
  337. the module from Guile to get more information about the actual error:
  338. @example
  339. ./pre-inst-env guile -c '(use-modules (gnu packages gnew))'
  340. @end example
  341. Once your package builds correctly, please send us a patch
  342. (@pxref{Submitting Patches}). Well, if you need help, we will be happy to
  343. help you too. Once the patch is committed in the Guix repository, the
  344. new package automatically gets built on the supported platforms by
  345. @url{https://@value{SUBSTITUTE-SERVER-1}, our continuous integration system}.
  346. @cindex substituter
  347. Users can obtain the new package definition simply by running
  348. @command{guix pull} (@pxref{Invoking guix pull}). When
  349. @code{@value{SUBSTITUTE-SERVER-1}} is done building the package, installing the
  350. package automatically downloads binaries from there
  351. (@pxref{Substitutes}). The only place where human intervention is
  352. needed is to review and apply the patch.
  353. @menu
  354. * Software Freedom:: What may go into the distribution.
  355. * Package Naming:: What's in a name?
  356. * Version Numbers:: When the name is not enough.
  357. * Synopses and Descriptions:: Helping users find the right package.
  358. * Snippets versus Phases:: Whether to use a snippet, or a build phase.
  359. * Emacs Packages:: Your Elisp fix.
  360. * Python Modules:: A touch of British comedy.
  361. * Perl Modules:: Little pearls.
  362. * Java Packages:: Coffee break.
  363. * Rust Crates:: Beware of oxidation.
  364. * Fonts:: Fond of fonts.
  365. @end menu
  366. @node Software Freedom
  367. @subsection Software Freedom
  368. @c Adapted from http://www.gnu.org/philosophy/philosophy.html.
  369. @cindex free software
  370. The GNU operating system has been developed so that users can have
  371. freedom in their computing. GNU is @dfn{free software}, meaning that
  372. users have the @url{https://www.gnu.org/philosophy/free-sw.html,four
  373. essential freedoms}: to run the program, to study and change the program
  374. in source code form, to redistribute exact copies, and to distribute
  375. modified versions. Packages found in the GNU distribution provide only
  376. software that conveys these four freedoms.
  377. In addition, the GNU distribution follow the
  378. @url{https://www.gnu.org/distros/free-system-distribution-guidelines.html,free
  379. software distribution guidelines}. Among other things, these guidelines
  380. reject non-free firmware, recommendations of non-free software, and
  381. discuss ways to deal with trademarks and patents.
  382. Some otherwise free upstream package sources contain a small and optional
  383. subset that violates the above guidelines, for instance because this subset
  384. is itself non-free code. When that happens, the offending items are removed
  385. with appropriate patches or code snippets in the @code{origin} form of the
  386. package (@pxref{Defining Packages}). This way, @code{guix
  387. build --source} returns the ``freed'' source rather than the unmodified
  388. upstream source.
  389. @node Package Naming
  390. @subsection Package Naming
  391. @cindex package name
  392. A package actually has two names associated with it.
  393. First, there is the name of the @emph{Scheme variable}, the one following
  394. @code{define-public}. By this name, the package can be made known in the
  395. Scheme code, for instance as input to another package. Second, there is
  396. the string in the @code{name} field of a package definition. This name
  397. is used by package management commands such as
  398. @command{guix package} and @command{guix build}.
  399. Both are usually the same and correspond to the lowercase conversion of
  400. the project name chosen upstream, with underscores replaced with
  401. hyphens. For instance, GNUnet is available as @code{gnunet}, and
  402. SDL_net as @code{sdl-net}.
  403. A noteworthy exception to this rule is when the project name is only a
  404. single character, or if an older maintained project with the same name
  405. already exists---regardless of whether it has already been packaged for
  406. Guix. Use common sense to make such names unambiguous and meaningful.
  407. For example, Guix's package for the shell called ``s'' upstream is
  408. @code{s-shell} and @emph{not} @code{s}. Feel free to ask your fellow
  409. hackers for inspiration.
  410. We do not add @code{lib} prefixes for library packages, unless these are
  411. already part of the official project name. But @pxref{Python
  412. Modules} and @ref{Perl Modules} for special rules concerning modules for
  413. the Python and Perl languages.
  414. Font package names are handled differently, @pxref{Fonts}.
  415. @node Version Numbers
  416. @subsection Version Numbers
  417. @cindex package version
  418. We usually package only the latest version of a given free software
  419. project. But sometimes, for instance for incompatible library versions,
  420. two (or more) versions of the same package are needed. These require
  421. different Scheme variable names. We use the name as defined
  422. in @ref{Package Naming}
  423. for the most recent version; previous versions use the same name, suffixed
  424. by @code{-} and the smallest prefix of the version number that may
  425. distinguish the two versions.
  426. The name inside the package definition is the same for all versions of a
  427. package and does not contain any version number.
  428. For instance, the versions 2.24.20 and 3.9.12 of GTK+ may be packaged as follows:
  429. @lisp
  430. (define-public gtk+
  431. (package
  432. (name "gtk+")
  433. (version "3.9.12")
  434. ...))
  435. (define-public gtk+-2
  436. (package
  437. (name "gtk+")
  438. (version "2.24.20")
  439. ...))
  440. @end lisp
  441. If we also wanted GTK+ 3.8.2, this would be packaged as
  442. @lisp
  443. (define-public gtk+-3.8
  444. (package
  445. (name "gtk+")
  446. (version "3.8.2")
  447. ...))
  448. @end lisp
  449. @c See <https://lists.gnu.org/archive/html/guix-devel/2016-01/msg00425.html>,
  450. @c for a discussion of what follows.
  451. @cindex version number, for VCS snapshots
  452. Occasionally, we package snapshots of upstream's version control system
  453. (VCS) instead of formal releases. This should remain exceptional,
  454. because it is up to upstream developers to clarify what the stable
  455. release is. Yet, it is sometimes necessary. So, what should we put in
  456. the @code{version} field?
  457. Clearly, we need to make the commit identifier of the VCS snapshot
  458. visible in the version string, but we also need to make sure that the
  459. version string is monotonically increasing so that @command{guix package
  460. --upgrade} can determine which version is newer. Since commit
  461. identifiers, notably with Git, are not monotonically increasing, we add
  462. a revision number that we increase each time we upgrade to a newer
  463. snapshot. The resulting version string looks like this:
  464. @example
  465. 2.0.11-3.cabba9e
  466. ^ ^ ^
  467. | | `-- upstream commit ID
  468. | |
  469. | `--- Guix package revision
  470. |
  471. latest upstream version
  472. @end example
  473. It is a good idea to strip commit identifiers in the @code{version}
  474. field to, say, 7 digits. It avoids an aesthetic annoyance (assuming
  475. aesthetics have a role to play here) as well as problems related to OS
  476. limits such as the maximum shebang length (127 bytes for the Linux
  477. kernel). There are helper functions for doing this for packages using
  478. @code{git-fetch} or @code{hg-fetch} (see below). It is best to use the
  479. full commit identifiers in @code{origin}s, though, to avoid ambiguities.
  480. A typical package definition may look like this:
  481. @lisp
  482. (define my-package
  483. (let ((commit "c3f29bc928d5900971f65965feaae59e1272a3f7")
  484. (revision "1")) ;Guix package revision
  485. (package
  486. (version (git-version "0.9" revision commit))
  487. (source (origin
  488. (method git-fetch)
  489. (uri (git-reference
  490. (url "git://example.org/my-package.git")
  491. (commit commit)))
  492. (sha256 (base32 "1mbikn@dots{}"))
  493. (file-name (git-file-name name version))))
  494. ;; @dots{}
  495. )))
  496. @end lisp
  497. @deffn {Scheme Procedure} git-version @var{VERSION} @var{REVISION} @var{COMMIT}
  498. Return the version string for packages using @code{git-fetch}.
  499. @lisp
  500. (git-version "0.2.3" "0" "93818c936ee7e2f1ba1b315578bde363a7d43d05")
  501. @result{} "0.2.3-0.93818c9"
  502. @end lisp
  503. @end deffn
  504. @deffn {Scheme Procedure} hg-version @var{VERSION} @var{REVISION} @var{CHANGESET}
  505. Return the version string for packages using @code{hg-fetch}. It works
  506. in the same way as @code{git-version}.
  507. @end deffn
  508. @node Synopses and Descriptions
  509. @subsection Synopses and Descriptions
  510. @cindex package description
  511. @cindex package synopsis
  512. As we have seen before, each package in GNU@tie{}Guix includes a
  513. synopsis and a description (@pxref{Defining Packages}). Synopses and
  514. descriptions are important: They are what @command{guix package
  515. --search} searches, and a crucial piece of information to help users
  516. determine whether a given package suits their needs. Consequently,
  517. packagers should pay attention to what goes into them.
  518. Synopses must start with a capital letter and must not end with a
  519. period. They must not start with ``a'' or ``the'', which usually does
  520. not bring anything; for instance, prefer ``File-frobbing tool'' over ``A
  521. tool that frobs files''. The synopsis should say what the package
  522. is---e.g., ``Core GNU utilities (file, text, shell)''---or what it is
  523. used for---e.g., the synopsis for GNU@tie{}grep is ``Print lines
  524. matching a pattern''.
  525. Keep in mind that the synopsis must be meaningful for a very wide
  526. audience. For example, ``Manipulate alignments in the SAM format''
  527. might make sense for a seasoned bioinformatics researcher, but might be
  528. fairly unhelpful or even misleading to a non-specialized audience. It
  529. is a good idea to come up with a synopsis that gives an idea of the
  530. application domain of the package. In this example, this might give
  531. something like ``Manipulate nucleotide sequence alignments'', which
  532. hopefully gives the user a better idea of whether this is what they are
  533. looking for.
  534. Descriptions should take between five and ten lines. Use full
  535. sentences, and avoid using acronyms without first introducing them.
  536. Please avoid marketing phrases such as ``world-leading'',
  537. ``industrial-strength'', and ``next-generation'', and avoid superlatives
  538. like ``the most advanced''---they are not helpful to users looking for a
  539. package and may even sound suspicious. Instead, try to be factual,
  540. mentioning use cases and features.
  541. @cindex Texinfo markup, in package descriptions
  542. Descriptions can include Texinfo markup, which is useful to introduce
  543. ornaments such as @code{@@code} or @code{@@dfn}, bullet lists, or
  544. hyperlinks (@pxref{Overview,,, texinfo, GNU Texinfo}). However you
  545. should be careful when using some characters for example @samp{@@} and
  546. curly braces which are the basic special characters in Texinfo
  547. (@pxref{Special Characters,,, texinfo, GNU Texinfo}). User interfaces
  548. such as @command{guix package --show} take care of rendering it
  549. appropriately.
  550. Synopses and descriptions are translated by volunteers
  551. @uref{https://translate.fedoraproject.org/projects/guix/packages, at
  552. Weblate} so that as many users as possible can read them in
  553. their native language. User interfaces search them and display them in
  554. the language specified by the current locale.
  555. To allow @command{xgettext} to extract them as translatable strings,
  556. synopses and descriptions @emph{must be literal strings}. This means
  557. that you cannot use @code{string-append} or @code{format} to construct
  558. these strings:
  559. @lisp
  560. (package
  561. ;; @dots{}
  562. (synopsis "This is translatable")
  563. (description (string-append "This is " "*not*" " translatable.")))
  564. @end lisp
  565. Translation is a lot of work so, as a packager, please pay even more
  566. attention to your synopses and descriptions as every change may entail
  567. additional work for translators. In order to help them, it is possible
  568. to make recommendations or instructions visible to them by inserting
  569. special comments like this (@pxref{xgettext Invocation,,, gettext, GNU
  570. Gettext}):
  571. @lisp
  572. ;; TRANSLATORS: "X11 resize-and-rotate" should not be translated.
  573. (description "ARandR is designed to provide a simple visual front end
  574. for the X11 resize-and-rotate (RandR) extension. @dots{}")
  575. @end lisp
  576. @node Snippets versus Phases
  577. @subsection Snippets versus Phases
  578. @cindex snippets, when to use
  579. The boundary between using an origin snippet versus a build phase to
  580. modify the sources of a package can be elusive. Origin snippets are
  581. typically used to remove unwanted files such as bundled libraries,
  582. nonfree sources, or to apply simple substitutions. The source derived
  583. from an origin should produce a source that can be used to build the
  584. package on any system that the upstream package supports (i.e., act as
  585. the corresponding source). In particular, origin snippets must not
  586. embed store items in the sources; such patching should rather be done
  587. using build phases. Refer to the @code{origin} record documentation for
  588. more information (@pxref{origin Reference}).
  589. @node Emacs Packages
  590. @subsection Emacs Packages
  591. @cindex emacs, packaging
  592. @cindex elisp, packaging
  593. Emacs packages should preferably use the Emacs build system
  594. (@pxref{emacs-build-system}), for uniformity and the benefits provided
  595. by its build phases, such as the auto-generation of the autoloads file
  596. and the byte compilation of the sources. Because there is no
  597. standardized way to run a test suite for Emacs packages, tests are
  598. disabled by default. When a test suite is available, it should be
  599. enabled by setting the @code{#:tests?} argument to @code{#true}. By
  600. default, the command to run the test is @command{make check}, but any
  601. command can be specified via the @code{#:test-command} argument. The
  602. @code{#:test-command} argument expects a list containing a command and
  603. its arguments, to be invoked during the @code{check} phase.
  604. The Elisp dependencies of Emacs packages are typically provided as
  605. @code{propagated-inputs} when required at run time. As for other
  606. packages, build or test dependencies should be specified as
  607. @code{native-inputs}.
  608. Emacs packages sometimes depend on resources directories that should be
  609. installed along the Elisp files. The @code{#:include} argument can be
  610. used for that purpose, by specifying a list of regexps to match. The
  611. best practice when using the @code{#:include} argument is to extend
  612. rather than override its default value (accessible via the
  613. @code{%default-include} variable). As an example, a yasnippet extension
  614. package typically include a @file{snippets} directory, which could be
  615. copied to the installation directory using:
  616. @lisp
  617. #:include (cons "^snippets/" %default-include)
  618. @end lisp
  619. When encountering problems, it is wise to check for the presence of the
  620. @code{Package-Requires} extension header in the package main source
  621. file, and whether any dependencies and their versions listed therein are
  622. satisfied.
  623. @node Python Modules
  624. @subsection Python Modules
  625. @cindex python
  626. We currently package Python 2 and Python 3, under the Scheme variable names
  627. @code{python-2} and @code{python} as explained in @ref{Version Numbers}.
  628. To avoid confusion and naming clashes with other programming languages, it
  629. seems desirable that the name of a package for a Python module contains
  630. the word @code{python}.
  631. Some modules are compatible with only one version of Python, others with
  632. both. If the package Foo is compiled with Python 3, we name it
  633. @code{python-foo}. If it is compiled with Python 2, we name it
  634. @code{python2-foo}. Packages should be added when they are necessary;
  635. we don't add Python 2 variants of the package unless we are going to use
  636. them.
  637. If a project already contains the word @code{python}, we drop this;
  638. for instance, the module python-dateutil is packaged under the names
  639. @code{python-dateutil} and @code{python2-dateutil}. If the project name
  640. starts with @code{py} (e.g.@: @code{pytz}), we keep it and prefix it as
  641. described above.
  642. @subsubsection Specifying Dependencies
  643. @cindex inputs, for Python packages
  644. Dependency information for Python packages is usually available in the
  645. package source tree, with varying degrees of accuracy: in the
  646. @file{setup.py} file, in @file{requirements.txt}, or in @file{tox.ini}.
  647. Your mission, when writing a recipe for a Python package, is to map
  648. these dependencies to the appropriate type of ``input'' (@pxref{package
  649. Reference, inputs}). Although the @code{pypi} importer normally does a
  650. good job (@pxref{Invoking guix import}), you may want to check the
  651. following check list to determine which dependency goes where.
  652. @itemize
  653. @item
  654. We currently package Python 2 with @code{setuptools} and @code{pip}
  655. installed like Python 3.4 has per default. Thus you don't need to
  656. specify either of these as an input. @command{guix lint} will warn you
  657. if you do.
  658. @item
  659. Python dependencies required at run time go into
  660. @code{propagated-inputs}. They are typically defined with the
  661. @code{install_requires} keyword in @file{setup.py}, or in the
  662. @file{requirements.txt} file.
  663. @item
  664. Python packages required only at build time---e.g., those listed with
  665. the @code{setup_requires} keyword in @file{setup.py}---or only for
  666. testing---e.g., those in @code{tests_require}---go into
  667. @code{native-inputs}. The rationale is that (1) they do not need to be
  668. propagated because they are not needed at run time, and (2) in a
  669. cross-compilation context, it's the ``native'' input that we'd want.
  670. Examples are the @code{pytest}, @code{mock}, and @code{nose} test
  671. frameworks. Of course if any of these packages is also required at
  672. run-time, it needs to go to @code{propagated-inputs}.
  673. @item
  674. Anything that does not fall in the previous categories goes to
  675. @code{inputs}, for example programs or C libraries required for building
  676. Python packages containing C extensions.
  677. @item
  678. If a Python package has optional dependencies (@code{extras_require}),
  679. it is up to you to decide whether to add them or not, based on their
  680. usefulness/overhead ratio (@pxref{Submitting Patches, @command{guix
  681. size}}).
  682. @end itemize
  683. @node Perl Modules
  684. @subsection Perl Modules
  685. @cindex perl
  686. Perl programs standing for themselves are named as any other package,
  687. using the lowercase upstream name.
  688. For Perl packages containing a single class, we use the lowercase class name,
  689. replace all occurrences of @code{::} by dashes and prepend the prefix
  690. @code{perl-}.
  691. So the class @code{XML::Parser} becomes @code{perl-xml-parser}.
  692. Modules containing several classes keep their lowercase upstream name and
  693. are also prepended by @code{perl-}. Such modules tend to have the word
  694. @code{perl} somewhere in their name, which gets dropped in favor of the
  695. prefix. For instance, @code{libwww-perl} becomes @code{perl-libwww}.
  696. @node Java Packages
  697. @subsection Java Packages
  698. @cindex java
  699. Java programs standing for themselves are named as any other package,
  700. using the lowercase upstream name.
  701. To avoid confusion and naming clashes with other programming languages,
  702. it is desirable that the name of a package for a Java package is
  703. prefixed with @code{java-}. If a project already contains the word
  704. @code{java}, we drop this; for instance, the package @code{ngsjava} is
  705. packaged under the name @code{java-ngs}.
  706. For Java packages containing a single class or a small class hierarchy,
  707. we use the lowercase class name, replace all occurrences of @code{.} by
  708. dashes and prepend the prefix @code{java-}. So the class
  709. @code{apache.commons.cli} becomes package
  710. @code{java-apache-commons-cli}.
  711. @node Rust Crates
  712. @subsection Rust Crates
  713. @cindex rust
  714. Rust programs standing for themselves are named as any other package, using the
  715. lowercase upstream name.
  716. To prevent namespace collisions we prefix all other Rust packages with the
  717. @code{rust-} prefix. The name should be changed to lowercase as appropriate and
  718. dashes should remain in place.
  719. In the rust ecosystem it is common for multiple incompatible versions of a
  720. package to be used at any given time, so all package definitions should have a
  721. versioned suffix. The versioned suffix is the left-most non-zero digit (and
  722. any leading zeros, of course). This follows the ``caret'' version scheme
  723. intended by Cargo. Examples@: @code{rust-clap-2}, @code{rust-rand-0.6}.
  724. Because of the difficulty in reusing rust packages as pre-compiled inputs for
  725. other packages the Cargo build system (@pxref{Build Systems,
  726. @code{cargo-build-system}}) presents the @code{#:cargo-inputs} and
  727. @code{cargo-development-inputs} keywords as build system arguments. It would be
  728. helpful to think of these as similar to @code{propagated-inputs} and
  729. @code{native-inputs}. Rust @code{dependencies} and @code{build-dependencies}
  730. should go in @code{#:cargo-inputs}, and @code{dev-dependencies} should go in
  731. @code{#:cargo-development-inputs}. If a Rust package links to other libraries
  732. then the standard placement in @code{inputs} and the like should be used.
  733. Care should be taken to ensure the correct version of dependencies are used; to
  734. this end we try to refrain from skipping the tests or using @code{#:skip-build?}
  735. when possible. Of course this is not always possible, as the package may be
  736. developed for a different Operating System, depend on features from the Nightly
  737. Rust compiler, or the test suite may have atrophied since it was released.
  738. @node Fonts
  739. @subsection Fonts
  740. @cindex fonts
  741. For fonts that are in general not installed by a user for typesetting
  742. purposes, or that are distributed as part of a larger software package,
  743. we rely on the general packaging rules for software; for instance, this
  744. applies to the fonts delivered as part of the X.Org system or fonts that
  745. are part of TeX Live.
  746. To make it easier for a user to search for fonts, names for other packages
  747. containing only fonts are constructed as follows, independently of the
  748. upstream package name.
  749. The name of a package containing only one font family starts with
  750. @code{font-}; it is followed by the foundry name and a dash @code{-}
  751. if the foundry is known, and the font family name, in which spaces are
  752. replaced by dashes (and as usual, all upper case letters are transformed
  753. to lower case).
  754. For example, the Gentium font family by SIL is packaged under the name
  755. @code{font-sil-gentium}.
  756. For a package containing several font families, the name of the collection
  757. is used in the place of the font family name.
  758. For instance, the Liberation fonts consist of three families,
  759. Liberation Sans, Liberation Serif and Liberation Mono.
  760. These could be packaged separately under the names
  761. @code{font-liberation-sans} and so on; but as they are distributed together
  762. under a common name, we prefer to package them together as
  763. @code{font-liberation}.
  764. In the case where several formats of the same font family or font collection
  765. are packaged separately, a short form of the format, prepended by a dash,
  766. is added to the package name. We use @code{-ttf} for TrueType fonts,
  767. @code{-otf} for OpenType fonts and @code{-type1} for PostScript Type 1
  768. fonts.
  769. @node Coding Style
  770. @section Coding Style
  771. In general our code follows the GNU Coding Standards (@pxref{Top,,,
  772. standards, GNU Coding Standards}). However, they do not say much about
  773. Scheme, so here are some additional rules.
  774. @menu
  775. * Programming Paradigm:: How to compose your elements.
  776. * Modules:: Where to store your code?
  777. * Data Types and Pattern Matching:: Implementing data structures.
  778. * Formatting Code:: Writing conventions.
  779. @end menu
  780. @node Programming Paradigm
  781. @subsection Programming Paradigm
  782. Scheme code in Guix is written in a purely functional style. One
  783. exception is code that involves input/output, and procedures that
  784. implement low-level concepts, such as the @code{memoize} procedure.
  785. @node Modules
  786. @subsection Modules
  787. Guile modules that are meant to be used on the builder side must live in
  788. the @code{(guix build @dots{})} name space. They must not refer to
  789. other Guix or GNU modules. However, it is OK for a ``host-side'' module
  790. to use a build-side module.
  791. Modules that deal with the broader GNU system should be in the
  792. @code{(gnu @dots{})} name space rather than @code{(guix @dots{})}.
  793. @node Data Types and Pattern Matching
  794. @subsection Data Types and Pattern Matching
  795. The tendency in classical Lisp is to use lists to represent everything,
  796. and then to browse them ``by hand'' using @code{car}, @code{cdr},
  797. @code{cadr}, and co. There are several problems with that style,
  798. notably the fact that it is hard to read, error-prone, and a hindrance
  799. to proper type error reports.
  800. Guix code should define appropriate data types (for instance, using
  801. @code{define-record-type*}) rather than abuse lists. In addition, it
  802. should use pattern matching, via Guile’s @code{(ice-9 match)} module,
  803. especially when matching lists (@pxref{Pattern Matching,,, guile, GNU
  804. Guile Reference Manual}).
  805. @node Formatting Code
  806. @subsection Formatting Code
  807. @cindex formatting code
  808. @cindex coding style
  809. When writing Scheme code, we follow common wisdom among Scheme
  810. programmers. In general, we follow the
  811. @url{https://mumble.net/~campbell/scheme/style.txt, Riastradh's Lisp
  812. Style Rules}. This document happens to describe the conventions mostly
  813. used in Guile’s code too. It is very thoughtful and well written, so
  814. please do read it.
  815. Some special forms introduced in Guix, such as the @code{substitute*}
  816. macro, have special indentation rules. These are defined in the
  817. @file{.dir-locals.el} file, which Emacs automatically uses. Also note
  818. that Emacs-Guix provides @code{guix-devel-mode} mode that indents and
  819. highlights Guix code properly (@pxref{Development,,, emacs-guix, The
  820. Emacs-Guix Reference Manual}).
  821. @cindex indentation, of code
  822. @cindex formatting, of code
  823. If you do not use Emacs, please make sure to let your editor knows these
  824. rules. To automatically indent a package definition, you can also run:
  825. @example
  826. ./pre-inst-env guix style @var{package}
  827. @end example
  828. @noindent
  829. @xref{Invoking guix style}, for more information.
  830. @cindex Vim, Scheme code editing
  831. If you are editing code with Vim, we recommend that you run @code{:set
  832. autoindent} so that your code is automatically indented as you type.
  833. Additionally,
  834. @uref{https://www.vim.org/scripts/script.php?script_id=3998,
  835. @code{paredit.vim}} may help you deal with all these parentheses.
  836. We require all top-level procedures to carry a docstring. This
  837. requirement can be relaxed for simple private procedures in the
  838. @code{(guix build @dots{})} name space, though.
  839. Procedures should not have more than four positional parameters. Use
  840. keyword parameters for procedures that take more than four parameters.
  841. @node Submitting Patches
  842. @section Submitting Patches
  843. Development is done using the Git distributed version control system.
  844. Thus, access to the repository is not strictly necessary. We welcome
  845. contributions in the form of patches as produced by @code{git
  846. format-patch} sent to the @email{guix-patches@@gnu.org} mailing list
  847. (@pxref{submitting patches,, Submitting patches to a project, git, Git
  848. User Manual}). Contributors are encouraged to take a moment to set some
  849. Git repository options (@pxref{Configuring Git}) first, which can
  850. improve the readability of patches. Seasoned Guix developers may also
  851. want to look at the section on commit access (@pxref{Commit Access}).
  852. This mailing list is backed by a Debbugs instance, which allows us to
  853. keep track of submissions (@pxref{Tracking Bugs and Patches}). Each
  854. message sent to that mailing list gets a new tracking number assigned;
  855. people can then follow up on the submission by sending email to
  856. @code{@var{NNN}@@debbugs.gnu.org}, where @var{NNN} is the tracking
  857. number (@pxref{Sending a Patch Series}).
  858. Please write commit logs in the ChangeLog format (@pxref{Change Logs,,,
  859. standards, GNU Coding Standards}); you can check the commit history for
  860. examples.
  861. Before submitting a patch that adds or modifies a package definition,
  862. please run through this check list:
  863. @enumerate
  864. @cindex @code{git format-patch}
  865. @cindex @code{git-format-patch}
  866. @item
  867. When generating your patches with @code{git format-patch} or @code{git
  868. send-email}, we recommend using the option @code{--base=}, perhaps with
  869. the value @code{auto}. This option adds a note to the patch stating
  870. which commit the patch is based on. This helps reviewers understand how
  871. to apply and review your patches.
  872. @item
  873. If the authors of the packaged software provide a cryptographic
  874. signature for the release tarball, make an effort to verify the
  875. authenticity of the archive. For a detached GPG signature file this
  876. would be done with the @code{gpg --verify} command.
  877. @item
  878. Take some time to provide an adequate synopsis and description for the
  879. package. @xref{Synopses and Descriptions}, for some guidelines.
  880. @item
  881. Run @code{guix lint @var{package}}, where @var{package} is the
  882. name of the new or modified package, and fix any errors it reports
  883. (@pxref{Invoking guix lint}).
  884. @item
  885. Run @code{guix style @var{package}} to format the new package definition
  886. according to the project's conventions (@pxref{Invoking guix style}).
  887. @item
  888. Make sure the package builds on your platform, using @code{guix build
  889. @var{package}}.
  890. @item
  891. We recommend you also try building the package on other supported
  892. platforms. As you may not have access to actual hardware platforms, we
  893. recommend using the @code{qemu-binfmt-service-type} to emulate them. In
  894. order to enable it, add the @code{virtualization} service module and the
  895. following service to the list of services in your @code{operating-system}
  896. configuration:
  897. @lisp
  898. (service qemu-binfmt-service-type
  899. (qemu-binfmt-configuration
  900. (platforms (lookup-qemu-platforms "arm" "aarch64"))))
  901. @end lisp
  902. Then reconfigure your system.
  903. You can then build packages for different platforms by specifying the
  904. @code{--system} option. For example, to build the "hello" package for
  905. the armhf or aarch64 architectures, you would run the following
  906. commands, respectively:
  907. @example
  908. guix build --system=armhf-linux --rounds=2 hello
  909. guix build --system=aarch64-linux --rounds=2 hello
  910. @end example
  911. @item
  912. @cindex bundling
  913. Make sure the package does not use bundled copies of software already
  914. available as separate packages.
  915. Sometimes, packages include copies of the source code of their
  916. dependencies as a convenience for users. However, as a distribution, we
  917. want to make sure that such packages end up using the copy we already
  918. have in the distribution, if there is one. This improves resource usage
  919. (the dependency is built and stored only once), and allows the
  920. distribution to make transverse changes such as applying security
  921. updates for a given software package in a single place and have them
  922. affect the whole system---something that bundled copies prevent.
  923. @item
  924. Take a look at the profile reported by @command{guix size}
  925. (@pxref{Invoking guix size}). This will allow you to notice references
  926. to other packages unwillingly retained. It may also help determine
  927. whether to split the package (@pxref{Packages with Multiple Outputs}),
  928. and which optional dependencies should be used. In particular, avoid adding
  929. @code{texlive} as a dependency: because of its extreme size, use
  930. the @code{texlive-tiny} package or @code{texlive-union} procedure instead.
  931. @item
  932. For important changes, check that dependent packages (if applicable) are
  933. not affected by the change; @code{guix refresh --list-dependent
  934. @var{package}} will help you do that (@pxref{Invoking guix refresh}).
  935. @c See <https://lists.gnu.org/archive/html/guix-devel/2016-10/msg00933.html>.
  936. @cindex branching strategy
  937. @cindex rebuild scheduling strategy
  938. Depending on the number of dependent packages and thus the amount of
  939. rebuilding induced, commits go to different branches, along these lines:
  940. @table @asis
  941. @item 300 dependent packages or less
  942. @code{master} branch (non-disruptive changes).
  943. @item between 300 and 1,800 dependent packages
  944. @code{staging} branch (non-disruptive changes). This branch is intended
  945. to be merged in @code{master} every 6 weeks or so. Topical changes
  946. (e.g., an update of the GNOME stack) can instead go to a specific branch
  947. (say, @code{gnome-updates}). This branch is not expected to be
  948. buildable or usable until late in its development process.
  949. @item more than 1,800 dependent packages
  950. @code{core-updates} branch (may include major and potentially disruptive
  951. changes). This branch is intended to be merged in @code{master} every
  952. 6 months or so. This branch is not expected to be buildable or usable
  953. until late in its development process.
  954. @end table
  955. All these branches are @uref{https://@value{SUBSTITUTE-SERVER-1},
  956. tracked by our build farm} and merged into @code{master} once
  957. everything has been successfully built. This allows us to fix issues
  958. before they hit users, and to reduce the window during which pre-built
  959. binaries are not available.
  960. When we decide to start building the @code{staging} or
  961. @code{core-updates} branches, they will be forked and renamed with the
  962. suffix @code{-frozen}, at which time only bug fixes may be pushed to the
  963. frozen branches. The @code{core-updates} and @code{staging} branches
  964. will remain open to accept patches for the next cycle. Please ask on
  965. the mailing list or IRC if unsure where to place a patch.
  966. @c TODO: It would be good with badges on the website that tracks these
  967. @c branches. Or maybe even a status page.
  968. @item
  969. @cindex determinism, of build processes
  970. @cindex reproducible builds, checking
  971. Check whether the package's build process is deterministic. This
  972. typically means checking whether an independent build of the package
  973. yields the exact same result that you obtained, bit for bit.
  974. A simple way to do that is by building the same package several times in
  975. a row on your machine (@pxref{Invoking guix build}):
  976. @example
  977. guix build --rounds=2 my-package
  978. @end example
  979. This is enough to catch a class of common non-determinism issues, such
  980. as timestamps or randomly-generated output in the build result.
  981. Another option is to use @command{guix challenge} (@pxref{Invoking guix
  982. challenge}). You may run it once the package has been committed and
  983. built by @code{@value{SUBSTITUTE-SERVER-1}} to check whether it obtains the same
  984. result as you did. Better yet: Find another machine that can build it
  985. and run @command{guix publish}. Since the remote build machine is
  986. likely different from yours, this can catch non-determinism issues
  987. related to the hardware---e.g., use of different instruction set
  988. extensions---or to the operating system kernel---e.g., reliance on
  989. @code{uname} or @file{/proc} files.
  990. @item
  991. When writing documentation, please use gender-neutral wording when
  992. referring to people, such as
  993. @uref{https://en.wikipedia.org/wiki/Singular_they, singular
  994. ``they''@comma{} ``their''@comma{} ``them''}, and so forth.
  995. @item
  996. Verify that your patch contains only one set of related changes.
  997. Bundling unrelated changes together makes reviewing harder and slower.
  998. Examples of unrelated changes include the addition of several packages,
  999. or a package update along with fixes to that package.
  1000. @item
  1001. Please follow our code formatting rules, possibly running
  1002. @command{guix style} script to do that automatically for you
  1003. (@pxref{Formatting Code}).
  1004. @item
  1005. When possible, use mirrors in the source URL (@pxref{Invoking guix download}).
  1006. Use reliable URLs, not generated ones. For instance, GitHub archives are not
  1007. necessarily identical from one generation to the next, so in this case it's
  1008. often better to clone the repository. Don't use the @command{name} field in
  1009. the URL: it is not very useful and if the name changes, the URL will probably
  1010. be wrong.
  1011. @item
  1012. Check if Guix builds (@pxref{Building from Git}) and address the
  1013. warnings, especially those about use of undefined symbols.
  1014. @item
  1015. Make sure your changes do not break Guix and simulate a @code{guix pull} with:
  1016. @example
  1017. guix pull --url=/path/to/your/checkout --profile=/tmp/guix.master
  1018. @end example
  1019. @end enumerate
  1020. When posting a patch to the mailing list, use @samp{[PATCH] @dots{}} as
  1021. a subject, if your patch is to be applied on a branch other than
  1022. @code{master}, say @code{core-updates}, specify it in the subject like
  1023. @samp{[PATCH core-updates] @dots{}}. You may use your email client or
  1024. the @command{git send-email} command (@pxref{Sending a Patch Series}).
  1025. We prefer to get patches in plain text messages, either inline or as
  1026. MIME attachments. You are advised to pay attention if your email client
  1027. changes anything like line breaks or indentation which could potentially
  1028. break the patches.
  1029. Expect some delay when you submit your very first patch to
  1030. @email{guix-patches@@gnu.org}. You have to wait until you get an
  1031. acknowledgement with the assigned tracking number. Future acknowledgements
  1032. should not be delayed.
  1033. When a bug is resolved, please close the thread by sending an email to
  1034. @email{@var{NNN}-done@@debbugs.gnu.org}.
  1035. @node Configuring Git
  1036. @subsection Configuring Git
  1037. @cindex git configuration
  1038. @cindex @code{git format-patch}
  1039. @cindex @code{git send-email}
  1040. If you have not done so already, you may wish to set a name and email
  1041. that will be associated with your commits (@pxref{telling git your name,
  1042. , Telling Git your name, git, Git User Manual}). If you wish to use a
  1043. different name or email just for commits in this repository, you can
  1044. use @command{git config --local}, or edit @file{.git/config} in the
  1045. repository instead of @file{~/.gitconfig}.
  1046. We provide some default settings in @file{etc/git/gitconfig} which
  1047. modify how patches are generated, making them easier to read and apply.
  1048. These settings can be applied by manually copying them to
  1049. @file{.git/config} in your checkout, or by telling Git to include the
  1050. whole file:
  1051. @example
  1052. git config --local include.path ../etc/git/gitconfig
  1053. @end example
  1054. From then on, any changes to @file{etc/git/gitconfig} would
  1055. automatically take effect.
  1056. Since the first patch in a series must be sent separately
  1057. (@pxref{Sending a Patch Series}), it can also be helpful to tell
  1058. @command{git format-patch} to handle the e-mail threading instead of
  1059. @command{git send-email}:
  1060. @example
  1061. git config --local format.thread shallow
  1062. git config --local sendemail.thread no
  1063. @end example
  1064. @unnumberedsubsec Sending a Patch Series
  1065. @anchor{Sending a Patch Series}
  1066. @cindex patch series
  1067. @cindex @code{git send-email}
  1068. When sending a patch series (e.g., using @code{git send-email}), please
  1069. first send one message to @email{guix-patches@@gnu.org}, and then send
  1070. subsequent patches to @email{@var{NNN}@@debbugs.gnu.org} to make sure
  1071. they are kept together. See
  1072. @uref{https://debbugs.gnu.org/Advanced.html, the Debbugs documentation}
  1073. for more information. You can install @command{git send-email} with
  1074. @command{guix install git:send-email}.
  1075. @c Debbugs bug: https://debbugs.gnu.org/db/15/15361.html
  1076. @node Tracking Bugs and Patches
  1077. @section Tracking Bugs and Patches
  1078. This section describes how the Guix project tracks its bug reports and
  1079. patch submissions.
  1080. @menu
  1081. * The Issue Tracker:: The official bug and patch tracker.
  1082. * Debbugs User Interfaces:: Ways to interact with Debbugs.
  1083. * Debbugs Usertags:: Tag reports with custom labels.
  1084. @end menu
  1085. @node The Issue Tracker
  1086. @subsection The Issue Tracker
  1087. @cindex bug reports, tracking
  1088. @cindex patch submissions, tracking
  1089. @cindex issue tracking
  1090. @cindex Debbugs, issue tracking system
  1091. Bug reports and patch submissions are currently tracked using the
  1092. Debbugs instance at @uref{https://bugs.gnu.org}. Bug reports are filed
  1093. against the @code{guix} ``package'' (in Debbugs parlance), by sending
  1094. email to @email{bug-guix@@gnu.org}, while patch submissions are filed
  1095. against the @code{guix-patches} package by sending email to
  1096. @email{guix-patches@@gnu.org} (@pxref{Submitting Patches}).
  1097. @node Debbugs User Interfaces
  1098. @subsection Debbugs User Interfaces
  1099. A web interface (actually @emph{two} web interfaces!) are available to
  1100. browse issues:
  1101. @itemize
  1102. @item
  1103. @url{https://issues.guix.gnu.org} provides a pleasant
  1104. interface@footnote{The web interface at
  1105. @url{https://issues.guix.gnu.org} is powered by Mumi, a nice piece of
  1106. software written in Guile, and you can help! See
  1107. @url{https://git.elephly.net/gitweb.cgi?p=software/mumi.git}.} to browse
  1108. bug reports and patches, and to participate in discussions;
  1109. @item
  1110. @url{https://bugs.gnu.org/guix} lists bug reports;
  1111. @item
  1112. @url{https://bugs.gnu.org/guix-patches} lists patch submissions.
  1113. @end itemize
  1114. To view discussions related to issue number @var{n}, go to
  1115. @indicateurl{https://issues.guix.gnu.org/@var{n}} or
  1116. @indicateurl{https://bugs.gnu.org/@var{n}}.
  1117. If you use Emacs, you may find it more convenient to interact with
  1118. issues using @file{debbugs.el}, which you can install with:
  1119. @example
  1120. guix install emacs-debbugs
  1121. @end example
  1122. For example, to list all open issues on @code{guix-patches}, hit:
  1123. @example
  1124. @kbd{C-u} @kbd{M-x} debbugs-gnu @kbd{RET} @kbd{RET} guix-patches @kbd{RET} n y
  1125. @end example
  1126. @xref{Top,,, debbugs-ug, Debbugs User Guide}, for more information on
  1127. this nifty tool!
  1128. @node Debbugs Usertags
  1129. @subsection Debbugs Usertags
  1130. @cindex usertags, for debbugs
  1131. @cindex Debbugs usertags
  1132. Debbugs provides a feature called @dfn{usertags} that allows any user to
  1133. tag any bug with an arbitrary label. Bugs can be searched by usertag,
  1134. so this is a handy way to organize bugs@footnote{The list of usertags is
  1135. public information, and anyone can modify any user's list of usertags,
  1136. so keep that in mind if you choose to use this feature.}.
  1137. For example, to view all the bug reports (or patches, in the case of
  1138. @code{guix-patches}) tagged with the usertag @code{powerpc64le-linux}
  1139. for the user @code{guix}, open a URL like the following in a web
  1140. browser:
  1141. @url{https://debbugs.gnu.org/cgi-bin/pkgreport.cgi?tag=powerpc64le-linux;users=guix}.
  1142. For more information on how to use usertags, please refer to the
  1143. documentation for Debbugs or the documentation for whatever tool you use
  1144. to interact with Debbugs.
  1145. In Guix, we are experimenting with usertags to keep track of
  1146. architecture-specific issues. To facilitate collaboration, all our
  1147. usertags are associated with the single user @code{guix}. The following
  1148. usertags currently exist for that user:
  1149. @table @code
  1150. @item powerpc64le-linux
  1151. The purpose of this usertag is to make it easy to find the issues that
  1152. matter most for the @code{powerpc64le-linux} system type. Please assign
  1153. this usertag to bugs or patches that affect @code{powerpc64le-linux} but
  1154. not other system types. In addition, you may use it to identify issues
  1155. that for some reason are particularly important for the
  1156. @code{powerpc64le-linux} system type, even if the issue affects other
  1157. system types, too.
  1158. @item reproducibility
  1159. For issues related to reproducibility. For example, it would be
  1160. appropriate to assign this usertag to a bug report for a package that
  1161. fails to build reproducibly.
  1162. @end table
  1163. If you're a committer and you want to add a usertag, just start using it
  1164. with the @code{guix} user. If the usertag proves useful to you,
  1165. consider updating this section of the manual so that others will know
  1166. what your usertag means.
  1167. @node Commit Access
  1168. @section Commit Access
  1169. @cindex commit access, for developers
  1170. Everyone can contribute to Guix without having commit access
  1171. (@pxref{Submitting Patches}). However, for frequent contributors,
  1172. having write access to the repository can be convenient. As a rule of
  1173. thumb, a contributor should have accumulated fifty (50) reviewed commits
  1174. to be considered as a committer and have sustained their activity in the
  1175. project for at least 6 months. This ensures enough interactions with
  1176. the contributor, which is essential for mentoring and assessing whether
  1177. they are ready to become a committer. Commit access should not be
  1178. thought of as a ``badge of honor'' but rather as a responsibility a
  1179. contributor is willing to take to help the project.
  1180. The following sections explain how to get commit access, how to be ready
  1181. to push commits, and the policies and community expectations for commits
  1182. pushed upstream.
  1183. @subsection Applying for Commit Access
  1184. When you deem it necessary, consider applying for commit
  1185. access by following these steps:
  1186. @enumerate
  1187. @item
  1188. Find three committers who would vouch for you. You can view the list of
  1189. committers at
  1190. @url{https://savannah.gnu.org/project/memberlist.php?group=guix}. Each
  1191. of them should email a statement to @email{guix-maintainers@@gnu.org} (a
  1192. private alias for the collective of maintainers), signed with their
  1193. OpenPGP key.
  1194. Committers are expected to have had some interactions with you as a
  1195. contributor and to be able to judge whether you are sufficiently
  1196. familiar with the project's practices. It is @emph{not} a judgment on
  1197. the value of your work, so a refusal should rather be interpreted as
  1198. ``let's try again later''.
  1199. @item
  1200. Send @email{guix-maintainers@@gnu.org} a message stating your intent,
  1201. listing the three committers who support your application, signed with
  1202. the OpenPGP key you will use to sign commits, and giving its fingerprint
  1203. (see below). See @uref{https://emailselfdefense.fsf.org/en/}, for an
  1204. introduction to public-key cryptography with GnuPG.
  1205. @c See <https://sha-mbles.github.io/>.
  1206. Set up GnuPG such that it never uses the SHA1 hash algorithm for digital
  1207. signatures, which is known to be unsafe since 2019, for instance by
  1208. adding the following line to @file{~/.gnupg/gpg.conf} (@pxref{GPG
  1209. Esoteric Options,,, gnupg, The GNU Privacy Guard Manual}):
  1210. @example
  1211. digest-algo sha512
  1212. @end example
  1213. @item
  1214. Maintainers ultimately decide whether to grant you commit access,
  1215. usually following your referrals' recommendation.
  1216. @item
  1217. @cindex OpenPGP, signed commits
  1218. If and once you've been given access, please send a message to
  1219. @email{guix-devel@@gnu.org} to say so, again signed with the OpenPGP key
  1220. you will use to sign commits (do that before pushing your first commit).
  1221. That way, everyone can notice and ensure you control that OpenPGP key.
  1222. @quotation Important
  1223. Before you can push for the first time, maintainers must:
  1224. @enumerate
  1225. @item
  1226. add your OpenPGP key to the @code{keyring} branch;
  1227. @item
  1228. add your OpenPGP fingerprint to the @file{.guix-authorizations} file of
  1229. the branch(es) you will commit to.
  1230. @end enumerate
  1231. @end quotation
  1232. @item
  1233. Make sure to read the rest of this section and... profit!
  1234. @end enumerate
  1235. @quotation Note
  1236. Maintainers are happy to give commit access to people who have been
  1237. contributing for some time and have a track record---don't be shy and
  1238. don't underestimate your work!
  1239. However, note that the project is working towards a more automated patch
  1240. review and merging system, which, as a consequence, may lead us to have
  1241. fewer people with commit access to the main repository. Stay tuned!
  1242. @end quotation
  1243. All commits that are pushed to the central repository on Savannah must
  1244. be signed with an OpenPGP key, and the public key should be uploaded to
  1245. your user account on Savannah and to public key servers, such as
  1246. @code{keys.openpgp.org}. To configure Git to automatically sign
  1247. commits, run:
  1248. @example
  1249. git config commit.gpgsign true
  1250. # Substitute the fingerprint of your public PGP key.
  1251. git config user.signingkey CABBA6EA1DC0FF33
  1252. @end example
  1253. You can prevent yourself from accidentally pushing unsigned commits to
  1254. Savannah by using the pre-push Git hook located at
  1255. @file{etc/git/pre-push}:
  1256. @example
  1257. cp etc/git/pre-push .git/hooks/pre-push
  1258. @end example
  1259. @subsection Commit Policy
  1260. If you get commit access, please make sure to follow
  1261. the policy below (discussions of the policy can take place on
  1262. @email{guix-devel@@gnu.org}).
  1263. Non-trivial patches should always be posted to
  1264. @email{guix-patches@@gnu.org} (trivial patches include fixing typos,
  1265. etc.). This mailing list fills the patch-tracking database
  1266. (@pxref{Tracking Bugs and Patches}).
  1267. For patches that just add a new package, and a simple one, it's OK to
  1268. commit, if you're confident (which means you successfully built it in a
  1269. chroot setup, and have done a reasonable copyright and license
  1270. auditing). Likewise for package upgrades, except upgrades that trigger
  1271. a lot of rebuilds (for example, upgrading GnuTLS or GLib). We have a
  1272. mailing list for commit notifications (@email{guix-commits@@gnu.org}),
  1273. so people can notice. Before pushing your changes, make sure to run
  1274. @code{git pull --rebase}.
  1275. When pushing a commit on behalf of somebody else, please add a
  1276. @code{Signed-off-by} line at the end of the commit log message---e.g.,
  1277. with @command{git am --signoff}. This improves tracking of who did
  1278. what.
  1279. When adding channel news entries (@pxref{Channels, Writing Channel
  1280. News}), make sure they are well-formed by running the following command
  1281. right before pushing:
  1282. @example
  1283. make check-channel-news
  1284. @end example
  1285. For anything else, please post to @email{guix-patches@@gnu.org} and
  1286. leave time for a review, without committing anything (@pxref{Submitting
  1287. Patches}). If you didn’t receive any reply after two weeks, and if
  1288. you're confident, it's OK to commit.
  1289. That last part is subject to being adjusted, allowing individuals to commit
  1290. directly on non-controversial changes on parts they’re familiar with.
  1291. @subsection Addressing Issues
  1292. Peer review (@pxref{Submitting Patches}) and tools such as
  1293. @command{guix lint} (@pxref{Invoking guix lint}) and the test suite
  1294. (@pxref{Running the Test Suite}) should catch issues before they are
  1295. pushed. Yet, commits that ``break'' functionality might occasionally
  1296. go through. When that happens, there are two priorities: mitigating
  1297. the impact, and understanding what happened to reduce the chance of
  1298. similar incidents in the future. The responsibility for both these
  1299. things primarily lies with those involved, but like everything this is
  1300. a group effort.
  1301. Some issues can directly affect all users---for instance because they
  1302. make @command{guix pull} fail or break core functionality, because they
  1303. break major packages (at build time or run time), or because they
  1304. introduce known security vulnerabilities.
  1305. @cindex reverting commits
  1306. The people involved in authoring, reviewing, and pushing such
  1307. commit(s) should be at the forefront to mitigate their impact in a
  1308. timely fashion: by pushing a followup commit to fix it (if possible),
  1309. or by reverting it to leave time to come up with a proper fix, and by
  1310. communicating with other developers about the problem.
  1311. If these persons are unavailable to address the issue in time, other
  1312. committers are entitled to revert the commit(s), explaining in the
  1313. commit log and on the mailing list what the problem was, with the goal
  1314. of leaving time to the original committer, reviewer(s), and author(s)
  1315. to propose a way forward.
  1316. Once the problem has been dealt with, it is the responsibility of
  1317. those involved to make sure the situation is understood. If you are
  1318. working to understand what happened, focus on gathering information
  1319. and avoid assigning any blame. Do ask those involved to describe what
  1320. happened, do not ask them to explain the situation---this would
  1321. implicitly blame them, which is unhelpful. Accountability comes from
  1322. a consensus about the problem, learning from it and improving
  1323. processes so that it's less likely to reoccur.
  1324. @subsection Commit Revocation
  1325. In order to reduce the possibility of mistakes, committers will have
  1326. their Savannah account removed from the Guix Savannah project and their
  1327. key removed from @file{.guix-authorizations} after 12 months of
  1328. inactivity; they can ask to regain commit access by emailing the
  1329. maintainers, without going through the vouching process.
  1330. Maintainers@footnote{See @uref{https://guix.gnu.org/en/about} for the
  1331. current list of maintainers. You can email them privately at
  1332. @email{guix-maintainers@@gnu.org}.} may also revoke an individual's
  1333. commit rights, as a last resort, if cooperation with the rest of the
  1334. community has caused too much friction---even within the bounds of the
  1335. project's code of conduct (@pxref{Contributing}). They would only do so
  1336. after public or private discussion with the individual and a clear
  1337. notice. Examples of behavior that hinders cooperation and could lead to
  1338. such a decision include:
  1339. @itemize
  1340. @item repeated violation of the commit policy stated above;
  1341. @item repeated failure to take peer criticism into account;
  1342. @item breaching trust through a series of grave incidents.
  1343. @end itemize
  1344. When maintainers resort to such a decision, they notify developers on
  1345. @email{guix-devel@@gnu.org}; inquiries may be sent to
  1346. @email{guix-maintainers@@gnu.org}. Depending on the situation, the
  1347. individual may still be welcome to contribute.
  1348. @subsection Helping Out
  1349. One last thing: the project keeps moving forward because committers not
  1350. only push their own awesome changes, but also offer some of their time
  1351. @emph{reviewing} and pushing other people's changes. As a committer,
  1352. you're welcome to use your expertise and commit rights to help other
  1353. contributors, too!
  1354. @node Updating the Guix Package
  1355. @section Updating the Guix Package
  1356. @cindex update-guix-package, updating the guix package
  1357. It is sometimes desirable to update the @code{guix} package itself (the
  1358. package defined in @code{(gnu packages package-management)}), for
  1359. example to make new daemon features available for use by the
  1360. @code{guix-service-type} service type. In order to simplify this task,
  1361. the following command can be used:
  1362. @example
  1363. make update-guix-package
  1364. @end example
  1365. The @code{update-guix-package} make target will use the last known
  1366. @emph{commit} corresponding to @code{HEAD} in your Guix checkout,
  1367. compute the hash of the Guix sources corresponding to that commit and
  1368. update the @code{commit}, @code{revision} and hash of the @code{guix}
  1369. package definition.
  1370. To validate that the updated @code{guix} package hashes are correct and
  1371. that it can be built successfully, the following command can be run from
  1372. the directory of your Guix checkout:
  1373. @example
  1374. ./pre-inst-env guix build guix
  1375. @end example
  1376. To guard against accidentally updating the @code{guix} package to a
  1377. commit that others can't refer to, a check is made that the commit used
  1378. has already been pushed to the Savannah-hosted Guix git repository.
  1379. This check can be disabled, @emph{at your own peril}, by setting the
  1380. @code{GUIX_ALLOW_ME_TO_USE_PRIVATE_COMMIT} environment variable. When
  1381. this variable is set, the updated package source is also added to the
  1382. store. This is used as part of the release process of Guix.
  1383. @cindex translation
  1384. @cindex l10n
  1385. @cindex i18n
  1386. @cindex native language support
  1387. @node Translating Guix
  1388. @section Translating Guix
  1389. Writing code and packages is not the only way to provide a meaningful
  1390. contribution to Guix. Translating to a language you speak is another
  1391. example of a valuable contribution you can make. This section is designed
  1392. to describe the translation process. It gives you advice on how you can
  1393. get involved, what can be translated, what mistakes you should avoid and
  1394. what we can do to help you!
  1395. Guix is a big project that has multiple components that can be translated.
  1396. We coordinate the translation effort on a
  1397. @uref{https://translate.fedoraproject.org/projects/guix/,Weblate instance}
  1398. hosted by our friends at Fedora. You will need an account to submit
  1399. translations.
  1400. Some of the software packaged in Guix also contain translations. We do not
  1401. host a translation platform for them. If you want to translate a package
  1402. provided by Guix, you should contact their developers or find the information
  1403. on their website. As an example, you can find the homepage of the
  1404. @code{hello} package by typing @code{guix show hello}. On the ``homepage''
  1405. line, you will see @url{https://www.gnu.org/software/hello/} as the homepage.
  1406. Many GNU and non-GNU packages can be translated on the
  1407. @uref{https://translationproject.org,Translation Project}. Some projects
  1408. with multiple components have their own platform. For instance, GNOME has
  1409. its own platform, @uref{https://l10n.gnome.org/,Damned Lies}.
  1410. Guix has five components hosted on Weblate.
  1411. @itemize
  1412. @item @code{guix} contains all the strings from the Guix software (the
  1413. guided system installer, the package manager, etc), excluding packages.
  1414. @item @code{packages} contains the synopsis (single-sentence description
  1415. of a package) and description (longer description) of packages in Guix.
  1416. @item @code{website} contains the official Guix website, except for
  1417. blog posts and multimedia content.
  1418. @item @code{documentation-manual} corresponds to this manual.
  1419. @item @code{documentation-cookbook} is the component for the cookbook.
  1420. @end itemize
  1421. @subsubheading General Directions
  1422. Once you get an account, you should be able to select a component from
  1423. @uref{https://translate.fedoraproject.org/projects/guix/,the guix project},
  1424. and select a language. If your language does not appear in the list, go
  1425. to the bottom and click on the ``Start new translation'' button. Select
  1426. the language you want to translate to from the list, to start your new
  1427. translation.
  1428. Like lots of other free software packages, Guix uses
  1429. @uref{https://www.gnu.org/software/gettext,GNU Gettext} for its translations,
  1430. with which translatable strings are extracted from the source code to so-called
  1431. PO files.
  1432. Even though PO files are text files, changes should not be made with a text
  1433. editor but with PO editing software. Weblate integrates PO editing
  1434. functionality. Alternatively, translators can use any of various
  1435. free-software tools for filling in translations, of which
  1436. @uref{https://poedit.net/,Poedit} is one example, and (after logging in)
  1437. @uref{https://docs.weblate.org/en/latest/user/files.html,upload} the changed
  1438. file. There is also a special
  1439. @uref{https://www.emacswiki.org/emacs/PoMode,PO editing mode} for users of GNU
  1440. Emacs. Over time translators find out what software they are happy with and
  1441. what features they need.
  1442. On Weblate, you will find various links to the editor, that will show various
  1443. subsets (or all) of the strings. Have a look around and at the
  1444. @uref{https://docs.weblate.org/en/latest/,documentation} to familiarize
  1445. yourself with the platform.
  1446. @subsubheading Translation Components
  1447. In this section, we provide more detailed guidance on the translation
  1448. process, as well as details on what you should or should not do. When in
  1449. doubt, please contact us, we will be happy to help!
  1450. @table @asis
  1451. @item guix
  1452. Guix is written in the Guile programming language, and some strings contain
  1453. special formatting that is interpreted by Guile. These special formatting
  1454. should be highlighted by Weblate. They start with @code{~} followed by one
  1455. or more characters.
  1456. When printing the string, Guile replaces the special formatting symbols with
  1457. actual values. For instance, the string @samp{ambiguous package specification
  1458. `~a'} would be substituted to contain said package specification instead of
  1459. @code{~a}. To properly translate this string, you must keep the formatting
  1460. code in your translation, although you can place it where it makes sense in
  1461. your language. For instance, the French translation says @samp{spécification
  1462. du paquet « ~a » ambiguë} because the adjective needs to be placed in the
  1463. end of the sentence.
  1464. If there are multiple formatting symbols, make sure to respect the order.
  1465. Guile does not know in which order you intended the string to be read, so it
  1466. will substitute the symbols in the same order as the English sentence.
  1467. As an example, you cannot translate @samp{package '~a' has been superseded by
  1468. '~a'} by @samp{'~a' superseeds package '~a'}, because the meaning would be
  1469. reversed. If @var{foo} is superseded by @var{bar}, the translation would read
  1470. @samp{'foo' superseeds package 'bar'}. To work around this problem, it
  1471. is possible to use more advanced formatting to select a given piece of data,
  1472. instead of following the default English order. @xref{Formatted Output,,,
  1473. guile, GNU Guile Reference Manual}, for more information on formatting in Guile.
  1474. @item packages
  1475. Package descriptions occasionally contain Texinfo markup (@pxref{Synopses
  1476. and Descriptions}). Texinfo markup looks like @samp{@@code@{rm -rf@}},
  1477. @samp{@@emph@{important@}}, etc. When translating, please leave markup as is.
  1478. The characters after ``@@'' form the name of the markup, and the text between
  1479. ``@{'' and ``@}'' is its content. In general, you should not translate the
  1480. content of markup like @code{@@code}, as it contains literal code that do not
  1481. change with language. You can translate the content of formatting markup such
  1482. as @code{@@emph}, @code{@@i}, @code{@@itemize}, @code{@@item}. However, do
  1483. not translate the name of the markup, or it will not be recognized. Do
  1484. not translate the word after @code{@@end}, it is the name of the markup that
  1485. is closed at this position (e.g.@: @code{@@itemize ... @@end itemize}).
  1486. @item documentation-manual and documentation-cookbook
  1487. The first step to ensure a successful translation of the manual is to find
  1488. and translate the following strings @emph{first}:
  1489. @itemize
  1490. @item @code{version.texi}: Translate this string as @code{version-xx.texi},
  1491. where @code{xx} is your language code (the one shown in the URL on
  1492. weblate).
  1493. @item @code{contributing.texi}: Translate this string as
  1494. @code{contributing.xx.texi}, where @code{xx} is the same language code.
  1495. @item @code{Top}: Do not translate this string, it is important for Texinfo.
  1496. If you translate it, the document will be empty (missing a Top node).
  1497. Please look for it, and register @code{Top} as its translation.
  1498. @end itemize
  1499. Translating these strings first ensure we can include your translation in
  1500. the guix repository without breaking the make process or the
  1501. @command{guix pull} machinery.
  1502. The manual and the cookbook both use Texinfo. As for @code{packages}, please
  1503. keep Texinfo markup as is. There are more possible markup types in the manual
  1504. than in the package descriptions. In general, do not translate the content
  1505. of @code{@@code}, @code{@@file}, @code{@@var}, @code{@@value}, etc. You
  1506. should translate the content of formatting markup such as @code{@@emph},
  1507. @code{@@i}, etc.
  1508. The manual contains sections that can be referred to by name by @code{@@ref},
  1509. @code{@@xref} and @code{@@pxref}. We have a mechanism in place so you do
  1510. not have to translate their content. If you keep the English title, we will
  1511. automatically replace it with your translation of that title. This ensures
  1512. that Texinfo will always be able to find the node. If you decide to change
  1513. the translation of the title, the references will automatically be updated
  1514. and you will not have to update them all yourself.
  1515. When translating references from the cookbook to the manual, you need to
  1516. replace the name of the manual and the name of the section. For instance,
  1517. to translate @code{@@pxref@{Defining Packages,,, guix, GNU Guix Reference
  1518. Manual@}}, you would replace @code{Defining Packages} with the title of that
  1519. section in the translated manual @emph{only} if that title is translated.
  1520. If the title is not translated in your language yet, do not translate it here,
  1521. or the link will be broken. Replace @code{guix} with @code{guix.xx} where
  1522. @code{xx} is your language code. @code{GNU Guix Reference Manual} is the
  1523. text of the link. You can translate it however you wish.
  1524. @item website
  1525. The website pages are written using SXML, an s-expression version of HTML,
  1526. the basic language of the web. We have a process to extract translatable
  1527. strings from the source, and replace complex s-expressions with a more familiar
  1528. XML markup, where each markup is numbered. Translators can arbitrarily change
  1529. the ordering, as in the following example.
  1530. @example
  1531. #. TRANSLATORS: Defining Packages is a section name
  1532. #. in the English (en) manual.
  1533. #: apps/base/templates/about.scm:64
  1534. msgid "Packages are <1>defined<1.1>en</1.1><1.2>Defining-Packages.html</1.2></1> as native <2>Guile</2> modules."
  1535. msgstr "Pakete werden als reine <2>Guile</2>-Module <1>definiert<1.1>de</1.1><1.2>Pakete-definieren.html</1.2></1>."
  1536. @end example
  1537. Note that you need to include the same markups. You cannot skip any.
  1538. @end table
  1539. In case you make a mistake, the component might fail to build properly with your
  1540. language, or even make guix pull fail. To prevent that, we have a process
  1541. in place to check the content of the files before pushing to our repository.
  1542. We will not be able to update the translation for your language in Guix, so
  1543. we will notify you (through weblate and/or by email) so you get a chance to
  1544. fix the issue.
  1545. @subsubheading Outside of Weblate
  1546. Currently, some parts of Guix cannot be translated on Weblate, help wanted!
  1547. @itemize
  1548. @item @command{guix pull} news can be translated in @file{news.scm}, but is not
  1549. available from Weblate. If you want to provide a translation, you
  1550. can prepare a patch as described above, or simply send us your
  1551. translation with the name of the news entry you translated and your
  1552. language. @xref{Writing Channel News}, for more information about
  1553. channel news.
  1554. @item Guix blog posts cannot currently be translated.
  1555. @item The installer script (for foreign distributions) is entirely in English.
  1556. @item Some of the libraries Guix uses cannot be translated or are translated
  1557. outside of the Guix project. Guile itself is not internationalized.
  1558. @item Other manuals linked from this manual or the cookbook might not be
  1559. translated.
  1560. @end itemize
  1561. @subsubheading Conditions for Inclusion
  1562. There are no conditions for adding new translations of the @code{guix} and
  1563. @code{guix-packages} components, other than they need at least one translated
  1564. string. New languages will be added to Guix as soon as possible. The
  1565. files may be removed if they fall out of sync and have no more translated
  1566. strings.
  1567. Given that the web site is dedicated to new users, we want its translation
  1568. to be as complete as possible before we include it in the language menu.
  1569. For a new language to be included, it needs to reach at least 80% completion.
  1570. When a language is included, it may be removed in the future if it stays
  1571. out of sync and falls below 60% completion.
  1572. The manual and cookbook are automatically added in the default compilation
  1573. target. Everytime we synchronize translations, developers need to
  1574. recompile all the translated manuals and cookbooks. This is useless for what
  1575. is essentially the English manual or cookbook. Therefore, we will only
  1576. include a new language when it reaches 10% completion in the component.
  1577. When a language is included, it may be removed in the future if it stays
  1578. out of sync and falls below 5% completion.
  1579. @subsubheading Translation Infrastructure
  1580. Weblate is backed by a git repository from which it discovers new strings to
  1581. translate and pushes new and updated translations. Normally, it would be
  1582. enough to give it commit access to our repositories. However, we decided
  1583. to use a separate repository for two reasons. First, we would have to give
  1584. Weblate commit access and authorize its signing key, but we do not trust it
  1585. in the same way we trust guix developers, especially since we do not manage
  1586. the instance ourselves. Second, if translators mess something up, it can
  1587. break the generation of the website and/or guix pull for all our users,
  1588. independently of their language.
  1589. For these reasons, we use a dedicated repository to host translations, and we
  1590. synchronize it with our guix and artworks repositories after checking no issue
  1591. was introduced in the translation.
  1592. Developers can download the latest PO files from weblate in the Guix
  1593. repository by running the @command{make download-po} command. It will
  1594. automatically download the latest files from weblate, reformat them to a
  1595. canonical form, and check they do not contain issues. The manual needs to be
  1596. built again to check for additional issues that might crash Texinfo.
  1597. Before pushing new translation files, developers should add them to the
  1598. make machinery so the translations are actually available. The process
  1599. differs for the various components.
  1600. @itemize
  1601. @item New po files for the @code{guix} and @code{packages} components must
  1602. be registered by adding the new language to @file{po/guix/LINGUAS} or
  1603. @file{po/packages/LINGUAS}.
  1604. @item New po files for the @code{documentation-manual} component must be
  1605. registered by adding the file name to @code{DOC_PO_FILES} in
  1606. @file{po/doc/local.mk}, the generated @file{%D%/guix.xx.texi} manual to
  1607. @code{info_TEXINFOS} in @file{doc/local.mk} and the generated
  1608. @file{%D%/guix.xx.texi} and @file{%D%/contributing.xx.texi} to
  1609. @code{TRANSLATED_INFO} also in @file{doc/local.mk}.
  1610. @item New po files for the @code{documentation-cookbook} component must be
  1611. registered by adding the file name to @code{DOC_COOKBOOK_PO_FILES} in
  1612. @file{po/doc/local.mk}, the generated @file{%D%/guix-cookbook.xx.texi}
  1613. manual to @code{info_TEXINFOS} in @file{doc/local.mk} and the generated
  1614. @file{%D%/guix-cookbook.xx.texi} to @code{TRANSLATED_INFO} also
  1615. in @file{doc/local.mk}.
  1616. @item New po files for the @code{website} component must be added to the
  1617. @code{guix-artwork} repository, in @file{website/po/}.
  1618. @file{website/po/LINGUAS} and @file{website/po/ietf-tags.scm} must
  1619. be updated accordingly (see @file{website/i18n-howto.txt} for more
  1620. information on the process).
  1621. @end itemize