contributing.texi 89 KB

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