contributing.texi 81 KB

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