contributing.texi 79 KB

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