contributing.texi 78 KB

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