contributing.texi 80 KB

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