contributing.texi 82 KB

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