contributing.texi 57 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417
  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 Freenode 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:: Using Debbugs.
  26. * Commit Access:: Pushing to the official repository.
  27. * Updating the Guix Package:: Updating the Guix package definition.
  28. @end menu
  29. @node Building from Git
  30. @section Building from Git
  31. If you want to hack Guix itself, it is recommended to use the latest
  32. version from the Git repository:
  33. @example
  34. git clone https://git.savannah.gnu.org/git/guix.git
  35. @end example
  36. @cindex authentication, of a Guix checkout
  37. How do you ensure that you obtained a genuine copy of the repository?
  38. To do that, run @command{guix git authenticate}, passing it the commit
  39. and OpenPGP fingerprint of the @dfn{channel introduction}
  40. (@pxref{Invoking guix git authenticate}):
  41. @c The commit and fingerprint below must match those of the channel
  42. @c introduction in '%default-channels'.
  43. @example
  44. git fetch origin keyring:keyring
  45. guix git authenticate 9edb3f66fd807b096b48283debdcddccfea34bad \
  46. "BBB0 2DDF 2CEA F6A8 0D1D E643 A2A0 6DF2 A33A 54FA"
  47. @end example
  48. @noindent
  49. This command completes with exit code zero on success; it prints an
  50. error message and exits with a non-zero code otherwise.
  51. As you can see, there is a chicken-and-egg problem: you first need to
  52. have Guix installed. Typically you would install Guix System
  53. (@pxref{System Installation}) or Guix on top of another distro
  54. (@pxref{Binary Installation}); in either case, you would verify the
  55. OpenPGP signature on the installation medium. This ``bootstraps'' the
  56. trust chain.
  57. The easiest way to set up a development environment for Guix is, of
  58. course, by using Guix! The following command starts a new shell where
  59. all the dependencies and appropriate environment variables are set up to
  60. hack on Guix:
  61. @example
  62. guix environment guix --pure
  63. @end example
  64. @xref{Invoking guix environment}, for more information on that command.
  65. If you are unable to use Guix when building Guix from a checkout, the
  66. following are the required packages in addition to those mentioned in the
  67. installation instructions (@pxref{Requirements}).
  68. @itemize
  69. @item @url{https://gnu.org/software/autoconf/, GNU Autoconf};
  70. @item @url{https://gnu.org/software/automake/, GNU Automake};
  71. @item @url{https://gnu.org/software/gettext/, GNU Gettext};
  72. @item @url{https://gnu.org/software/texinfo/, GNU Texinfo};
  73. @item @url{https://www.graphviz.org/, Graphviz};
  74. @item @url{https://www.gnu.org/software/help2man/, GNU Help2man (optional)}.
  75. @end itemize
  76. On Guix, extra dependencies can be added by instead running @command{guix
  77. environment} with @option{--ad-hoc}:
  78. @example
  79. guix environment guix --pure --ad-hoc help2man git strace
  80. @end example
  81. Run @command{./bootstrap} to generate the build system infrastructure
  82. using Autoconf and Automake. If you get an error like this one:
  83. @example
  84. configure.ac:46: error: possibly undefined macro: PKG_CHECK_MODULES
  85. @end example
  86. @noindent
  87. it probably means that Autoconf couldn’t find @file{pkg.m4}, which is
  88. provided by pkg-config. Make sure that @file{pkg.m4} is available. The
  89. same holds for the @file{guile.m4} set of macros provided by Guile. For
  90. instance, if you installed Automake in @file{/usr/local}, it wouldn’t
  91. look for @file{.m4} files in @file{/usr/share}. In that case, you have
  92. to invoke the following command:
  93. @example
  94. export ACLOCAL_PATH=/usr/share/aclocal
  95. @end example
  96. @xref{Macro Search Path,,, automake, The GNU Automake Manual}, for
  97. more information.
  98. Then, run @command{./configure} as usual. Make sure to pass
  99. @code{--localstatedir=@var{directory}} where @var{directory} is the
  100. @code{localstatedir} value used by your current installation (@pxref{The
  101. Store}, for information about this), usually @file{/var}. Note that you
  102. will probably not run @command{make install} at the end (you don't have
  103. to) but it's still important to pass the right @code{localstatedir}.
  104. Finally, you have to invoke @code{make check} to run tests
  105. (@pxref{Running the Test Suite}). If anything
  106. fails, take a look at installation instructions (@pxref{Installation})
  107. or send a message to the @email{guix-devel@@gnu.org, mailing list}.
  108. From there on, you can authenticate all the commits included in your
  109. checkout by running:
  110. @example
  111. make authenticate
  112. @end example
  113. The first run takes a couple of minutes, but subsequent runs are faster.
  114. Or, when your configuration for your local Git repository doesn't match
  115. the default one, you can provide the reference for the @code{keyring}
  116. branch through the variable @code{GUIX_GIT_KEYRING}. The following
  117. example assumes that you have a Git remote called @samp{myremote}
  118. pointing to the official repository:
  119. @example
  120. make authenticate GUIX_GIT_KEYRING=myremote/keyring
  121. @end example
  122. @quotation Note
  123. You are advised to run @command{make authenticate} after every
  124. @command{git pull} invocation. This ensures you keep receiving valid
  125. changes to the repository.
  126. @end quotation
  127. @node Running Guix Before It Is Installed
  128. @section Running Guix Before It Is Installed
  129. In order to keep a sane working environment, you will find it useful to
  130. test the changes made in your local source tree checkout without
  131. actually installing them. So that you can distinguish between your
  132. ``end-user'' hat and your ``motley'' costume.
  133. To that end, all the command-line tools can be used even if you have not
  134. run @code{make install}. To do that, you first need to have an
  135. environment with all the dependencies available (@pxref{Building from
  136. Git}), and then simply prefix each command with @command{./pre-inst-env}
  137. (the @file{pre-inst-env} script lives in the top build tree of Guix; it
  138. is generated by running @command{./bootstrap} followed by
  139. @command{./configure}). As an example, here is how you would build the
  140. @code{hello} package as defined in your working tree (this assumes
  141. @command{guix-daemon} is already running on your system; it's OK if it's
  142. a different version):
  143. @example
  144. $ ./pre-inst-env guix build hello
  145. @end example
  146. @noindent
  147. Similarly, an example for a Guile session using the Guix modules:
  148. @example
  149. $ ./pre-inst-env guile -c '(use-modules (guix utils)) (pk (%current-system))'
  150. ;;; ("x86_64-linux")
  151. @end example
  152. @noindent
  153. @cindex REPL
  154. @cindex read-eval-print loop
  155. @dots{} and for a REPL (@pxref{Using Guile Interactively,,, guile, Guile
  156. Reference Manual}):
  157. @example
  158. $ ./pre-inst-env guile
  159. scheme@@(guile-user)> ,use(guix)
  160. scheme@@(guile-user)> ,use(gnu)
  161. scheme@@(guile-user)> (define snakes
  162. (fold-packages
  163. (lambda (package lst)
  164. (if (string-prefix? "python"
  165. (package-name package))
  166. (cons package lst)
  167. lst))
  168. '()))
  169. scheme@@(guile-user)> (length snakes)
  170. $1 = 361
  171. @end example
  172. If you are hacking on the daemon and its supporting code or if
  173. @command{guix-daemon} is not already running on your system, you can
  174. launch it straight from the build tree@footnote{The @option{-E} flag to
  175. @command{sudo} guarantees that @code{GUILE_LOAD_PATH} is correctly set
  176. such that @command{guix-daemon} and the tools it uses can find the Guile
  177. modules they need.}:
  178. @example
  179. $ sudo -E ./pre-inst-env guix-daemon --build-users-group=guixbuild
  180. @end example
  181. The @command{pre-inst-env} script sets up all the environment variables
  182. necessary to support this, including @env{PATH} and @env{GUILE_LOAD_PATH}.
  183. Note that @command{./pre-inst-env guix pull} does @emph{not} upgrade the
  184. local source tree; it simply updates the @file{~/.config/guix/current}
  185. symlink (@pxref{Invoking guix pull}). Run @command{git pull} instead if
  186. you want to upgrade your local source tree.
  187. @node The Perfect Setup
  188. @section The Perfect Setup
  189. The Perfect Setup to hack on Guix is basically the perfect setup used
  190. for Guile hacking (@pxref{Using Guile in Emacs,,, guile, Guile Reference
  191. Manual}). First, you need more than an editor, you need
  192. @url{https://www.gnu.org/software/emacs, Emacs}, empowered by the
  193. wonderful @url{https://nongnu.org/geiser/, Geiser}. To set that up, run:
  194. @example
  195. guix package -i emacs guile emacs-geiser
  196. @end example
  197. Geiser allows for interactive and incremental development from within
  198. Emacs: code compilation and evaluation from within buffers, access to
  199. on-line documentation (docstrings), context-sensitive completion,
  200. @kbd{M-.} to jump to an object definition, a REPL to try out your code,
  201. and more (@pxref{Introduction,,, geiser, Geiser User Manual}). For
  202. convenient Guix development, make sure to augment Guile’s load path so
  203. that it finds source files from your checkout:
  204. @lisp
  205. ;; @r{Assuming the Guix checkout is in ~/src/guix.}
  206. (with-eval-after-load 'geiser-guile
  207. (add-to-list 'geiser-guile-load-path "~/src/guix"))
  208. @end lisp
  209. To actually edit the code, Emacs already has a neat Scheme mode. But in
  210. addition to that, you must not miss
  211. @url{https://www.emacswiki.org/emacs/ParEdit, Paredit}. It provides
  212. facilities to directly operate on the syntax tree, such as raising an
  213. s-expression or wrapping it, swallowing or rejecting the following
  214. s-expression, etc.
  215. @cindex code snippets
  216. @cindex templates
  217. @cindex reducing boilerplate
  218. We also provide templates for common git commit messages and package
  219. definitions in the @file{etc/snippets} directory. These templates can
  220. be used with @url{https://joaotavora.github.io/yasnippet/, YASnippet} to
  221. expand short trigger strings to interactive text snippets. You may want
  222. to add the snippets directory to the @var{yas-snippet-dirs} variable in
  223. Emacs.
  224. @lisp
  225. ;; @r{Assuming the Guix checkout is in ~/src/guix.}
  226. (with-eval-after-load 'yasnippet
  227. (add-to-list 'yas-snippet-dirs "~/src/guix/etc/snippets"))
  228. @end lisp
  229. The commit message snippets depend on @url{https://magit.vc/, Magit} to
  230. display staged files. When editing a commit message type @code{add}
  231. followed by @kbd{TAB} to insert a commit message template for adding a
  232. package; type @code{update} followed by @kbd{TAB} to insert a template
  233. for updating a package; type @code{https} followed by @kbd{TAB} to
  234. insert a template for changing the home page URI of a package to HTTPS.
  235. The main snippet for @code{scheme-mode} is triggered by typing
  236. @code{package...} followed by @kbd{TAB}. This snippet also inserts the
  237. trigger string @code{origin...}, which can be expanded further. The
  238. @code{origin} snippet in turn may insert other trigger strings ending on
  239. @code{...}, which also can be expanded further.
  240. @cindex insert or update copyright
  241. @cindex @code{M-x guix-copyright}
  242. @cindex @code{M-x copyright-update}
  243. We additionally provide insertion and automatic update of a copyright in
  244. @file{etc/copyright.el}. You may want to set your full name, mail, and
  245. load a file.
  246. @lisp
  247. (setq user-full-name "Alice Doe")
  248. (setq user-mail-address "alice@@mail.org")
  249. ;; @r{Assuming the Guix checkout is in ~/src/guix.}
  250. (load-file "~/src/guix/etc/copyright.el")
  251. @end lisp
  252. To insert a copyright at the current line invoke @code{M-x guix-copyright}.
  253. To update a copyright you need to specify a @code{copyright-names-regexp}.
  254. @lisp
  255. (setq copyright-names-regexp
  256. (format "%s <%s>" user-full-name user-mail-address))
  257. @end lisp
  258. You can check if your copyright is up to date by evaluating @code{M-x
  259. copyright-update}. If you want to do it automatically after each buffer
  260. save then add @code{(add-hook 'after-save-hook 'copyright-update)} in
  261. Emacs.
  262. @node Packaging Guidelines
  263. @section Packaging Guidelines
  264. @cindex packages, creating
  265. The GNU distribution is nascent and may well lack some of your favorite
  266. packages. This section describes how you can help make the distribution
  267. grow.
  268. Free software packages are usually distributed in the form of
  269. @dfn{source code tarballs}---typically @file{tar.gz} files that contain
  270. all the source files. Adding a package to the distribution means
  271. essentially two things: adding a @dfn{recipe} that describes how to
  272. build the package, including a list of other packages required to build
  273. it, and adding @dfn{package metadata} along with that recipe, such as a
  274. description and licensing information.
  275. In Guix all this information is embodied in @dfn{package definitions}.
  276. Package definitions provide a high-level view of the package. They are
  277. written using the syntax of the Scheme programming language; in fact,
  278. for each package we define a variable bound to the package definition,
  279. and export that variable from a module (@pxref{Package Modules}).
  280. However, in-depth Scheme knowledge is @emph{not} a prerequisite for
  281. creating packages. For more information on package definitions,
  282. @pxref{Defining Packages}.
  283. Once a package definition is in place, stored in a file in the Guix
  284. source tree, it can be tested using the @command{guix build} command
  285. (@pxref{Invoking guix build}). For example, assuming the new package is
  286. called @code{gnew}, you may run this command from the Guix build tree
  287. (@pxref{Running Guix Before It Is Installed}):
  288. @example
  289. ./pre-inst-env guix build gnew --keep-failed
  290. @end example
  291. Using @code{--keep-failed} makes it easier to debug build failures since
  292. it provides access to the failed build tree. Another useful
  293. command-line option when debugging is @code{--log-file}, to access the
  294. build log.
  295. If the package is unknown to the @command{guix} command, it may be that
  296. the source file contains a syntax error, or lacks a @code{define-public}
  297. clause to export the package variable. To figure it out, you may load
  298. the module from Guile to get more information about the actual error:
  299. @example
  300. ./pre-inst-env guile -c '(use-modules (gnu packages gnew))'
  301. @end example
  302. Once your package builds correctly, please send us a patch
  303. (@pxref{Submitting Patches}). Well, if you need help, we will be happy to
  304. help you too. Once the patch is committed in the Guix repository, the
  305. new package automatically gets built on the supported platforms by
  306. @url{@value{SUBSTITUTE-URL}, our continuous integration system}.
  307. @cindex substituter
  308. Users can obtain the new package definition simply by running
  309. @command{guix pull} (@pxref{Invoking guix pull}). When
  310. @code{@value{SUBSTITUTE-SERVER}} is done building the package, installing the
  311. package automatically downloads binaries from there
  312. (@pxref{Substitutes}). The only place where human intervention is
  313. needed is to review and apply the patch.
  314. @menu
  315. * Software Freedom:: What may go into the distribution.
  316. * Package Naming:: What's in a name?
  317. * Version Numbers:: When the name is not enough.
  318. * Synopses and Descriptions:: Helping users find the right package.
  319. * Snippets versus Phases:: Whether to use a snippet, or a build phase.
  320. * Emacs Packages:: Your Elisp fix.
  321. * Python Modules:: A touch of British comedy.
  322. * Perl Modules:: Little pearls.
  323. * Java Packages:: Coffee break.
  324. * Rust Crates:: Beware of oxidation.
  325. * Fonts:: Fond of fonts.
  326. @end menu
  327. @node Software Freedom
  328. @subsection Software Freedom
  329. @c Adapted from http://www.gnu.org/philosophy/philosophy.html.
  330. @cindex free software
  331. The GNU operating system has been developed so that users can have
  332. freedom in their computing. GNU is @dfn{free software}, meaning that
  333. users have the @url{https://www.gnu.org/philosophy/free-sw.html,four
  334. essential freedoms}: to run the program, to study and change the program
  335. in source code form, to redistribute exact copies, and to distribute
  336. modified versions. Packages found in the GNU distribution provide only
  337. software that conveys these four freedoms.
  338. In addition, the GNU distribution follow the
  339. @url{https://www.gnu.org/distros/free-system-distribution-guidelines.html,free
  340. software distribution guidelines}. Among other things, these guidelines
  341. reject non-free firmware, recommendations of non-free software, and
  342. discuss ways to deal with trademarks and patents.
  343. Some otherwise free upstream package sources contain a small and optional
  344. subset that violates the above guidelines, for instance because this subset
  345. is itself non-free code. When that happens, the offending items are removed
  346. with appropriate patches or code snippets in the @code{origin} form of the
  347. package (@pxref{Defining Packages}). This way, @code{guix
  348. build --source} returns the ``freed'' source rather than the unmodified
  349. upstream source.
  350. @node Package Naming
  351. @subsection Package Naming
  352. @cindex package name
  353. A package has actually two names associated with it:
  354. First, there is the name of the @emph{Scheme variable}, the one following
  355. @code{define-public}. By this name, the package can be made known in the
  356. Scheme code, for instance as input to another package. Second, there is
  357. the string in the @code{name} field of a package definition. This name
  358. is used by package management commands such as
  359. @command{guix package} and @command{guix build}.
  360. Both are usually the same and correspond to the lowercase conversion of
  361. the project name chosen upstream, with underscores replaced with
  362. hyphens. For instance, GNUnet is available as @code{gnunet}, and
  363. SDL_net as @code{sdl-net}.
  364. We do not add @code{lib} prefixes for library packages, unless these are
  365. already part of the official project name. But @pxref{Python
  366. Modules} and @ref{Perl Modules} for special rules concerning modules for
  367. the Python and Perl languages.
  368. Font package names are handled differently, @pxref{Fonts}.
  369. @node Version Numbers
  370. @subsection Version Numbers
  371. @cindex package version
  372. We usually package only the latest version of a given free software
  373. project. But sometimes, for instance for incompatible library versions,
  374. two (or more) versions of the same package are needed. These require
  375. different Scheme variable names. We use the name as defined
  376. in @ref{Package Naming}
  377. for the most recent version; previous versions use the same name, suffixed
  378. by @code{-} and the smallest prefix of the version number that may
  379. distinguish the two versions.
  380. The name inside the package definition is the same for all versions of a
  381. package and does not contain any version number.
  382. For instance, the versions 2.24.20 and 3.9.12 of GTK+ may be packaged as follows:
  383. @lisp
  384. (define-public gtk+
  385. (package
  386. (name "gtk+")
  387. (version "3.9.12")
  388. ...))
  389. (define-public gtk+-2
  390. (package
  391. (name "gtk+")
  392. (version "2.24.20")
  393. ...))
  394. @end lisp
  395. If we also wanted GTK+ 3.8.2, this would be packaged as
  396. @lisp
  397. (define-public gtk+-3.8
  398. (package
  399. (name "gtk+")
  400. (version "3.8.2")
  401. ...))
  402. @end lisp
  403. @c See <https://lists.gnu.org/archive/html/guix-devel/2016-01/msg00425.html>,
  404. @c for a discussion of what follows.
  405. @cindex version number, for VCS snapshots
  406. Occasionally, we package snapshots of upstream's version control system
  407. (VCS) instead of formal releases. This should remain exceptional,
  408. because it is up to upstream developers to clarify what the stable
  409. release is. Yet, it is sometimes necessary. So, what should we put in
  410. the @code{version} field?
  411. Clearly, we need to make the commit identifier of the VCS snapshot
  412. visible in the version string, but we also need to make sure that the
  413. version string is monotonically increasing so that @command{guix package
  414. --upgrade} can determine which version is newer. Since commit
  415. identifiers, notably with Git, are not monotonically increasing, we add
  416. a revision number that we increase each time we upgrade to a newer
  417. snapshot. The resulting version string looks like this:
  418. @example
  419. 2.0.11-3.cabba9e
  420. ^ ^ ^
  421. | | `-- upstream commit ID
  422. | |
  423. | `--- Guix package revision
  424. |
  425. latest upstream version
  426. @end example
  427. It is a good idea to strip commit identifiers in the @code{version}
  428. field to, say, 7 digits. It avoids an aesthetic annoyance (assuming
  429. aesthetics have a role to play here) as well as problems related to OS
  430. limits such as the maximum shebang length (127 bytes for the Linux
  431. kernel). It is best to use the full commit identifiers in
  432. @code{origin}s, though, to avoid ambiguities. A typical package
  433. definition may look like this:
  434. @lisp
  435. (define my-package
  436. (let ((commit "c3f29bc928d5900971f65965feaae59e1272a3f7")
  437. (revision "1")) ;Guix package revision
  438. (package
  439. (version (git-version "0.9" revision commit))
  440. (source (origin
  441. (method git-fetch)
  442. (uri (git-reference
  443. (url "git://example.org/my-package.git")
  444. (commit commit)))
  445. (sha256 (base32 "1mbikn@dots{}"))
  446. (file-name (git-file-name name version))))
  447. ;; @dots{}
  448. )))
  449. @end lisp
  450. @node Synopses and Descriptions
  451. @subsection Synopses and Descriptions
  452. @cindex package description
  453. @cindex package synopsis
  454. As we have seen before, each package in GNU@tie{}Guix includes a
  455. synopsis and a description (@pxref{Defining Packages}). Synopses and
  456. descriptions are important: They are what @command{guix package
  457. --search} searches, and a crucial piece of information to help users
  458. determine whether a given package suits their needs. Consequently,
  459. packagers should pay attention to what goes into them.
  460. Synopses must start with a capital letter and must not end with a
  461. period. They must not start with ``a'' or ``the'', which usually does
  462. not bring anything; for instance, prefer ``File-frobbing tool'' over ``A
  463. tool that frobs files''. The synopsis should say what the package
  464. is---e.g., ``Core GNU utilities (file, text, shell)''---or what it is
  465. used for---e.g., the synopsis for GNU@tie{}grep is ``Print lines
  466. matching a pattern''.
  467. Keep in mind that the synopsis must be meaningful for a very wide
  468. audience. For example, ``Manipulate alignments in the SAM format''
  469. might make sense for a seasoned bioinformatics researcher, but might be
  470. fairly unhelpful or even misleading to a non-specialized audience. It
  471. is a good idea to come up with a synopsis that gives an idea of the
  472. application domain of the package. In this example, this might give
  473. something like ``Manipulate nucleotide sequence alignments'', which
  474. hopefully gives the user a better idea of whether this is what they are
  475. looking for.
  476. Descriptions should take between five and ten lines. Use full
  477. sentences, and avoid using acronyms without first introducing them.
  478. Please avoid marketing phrases such as ``world-leading'',
  479. ``industrial-strength'', and ``next-generation'', and avoid superlatives
  480. like ``the most advanced''---they are not helpful to users looking for a
  481. package and may even sound suspicious. Instead, try to be factual,
  482. mentioning use cases and features.
  483. @cindex Texinfo markup, in package descriptions
  484. Descriptions can include Texinfo markup, which is useful to introduce
  485. ornaments such as @code{@@code} or @code{@@dfn}, bullet lists, or
  486. hyperlinks (@pxref{Overview,,, texinfo, GNU Texinfo}). However you
  487. should be careful when using some characters for example @samp{@@} and
  488. curly braces which are the basic special characters in Texinfo
  489. (@pxref{Special Characters,,, texinfo, GNU Texinfo}). User interfaces
  490. such as @command{guix package --show} take care of rendering it
  491. appropriately.
  492. Synopses and descriptions are translated by volunteers
  493. @uref{https://translate.fedoraproject.org/projects/guix/packages, at
  494. Weblate} so that as many users as possible can read them in
  495. their native language. User interfaces search them and display them in
  496. the language specified by the current locale.
  497. To allow @command{xgettext} to extract them as translatable strings,
  498. synopses and descriptions @emph{must be literal strings}. This means
  499. that you cannot use @code{string-append} or @code{format} to construct
  500. these strings:
  501. @lisp
  502. (package
  503. ;; @dots{}
  504. (synopsis "This is translatable")
  505. (description (string-append "This is " "*not*" " translatable.")))
  506. @end lisp
  507. Translation is a lot of work so, as a packager, please pay even more
  508. attention to your synopses and descriptions as every change may entail
  509. additional work for translators. In order to help them, it is possible
  510. to make recommendations or instructions visible to them by inserting
  511. special comments like this (@pxref{xgettext Invocation,,, gettext, GNU
  512. Gettext}):
  513. @lisp
  514. ;; TRANSLATORS: "X11 resize-and-rotate" should not be translated.
  515. (description "ARandR is designed to provide a simple visual front end
  516. for the X11 resize-and-rotate (RandR) extension. @dots{}")
  517. @end lisp
  518. @node Snippets versus Phases
  519. @subsection Snippets versus Phases
  520. @cindex snippets, when to use
  521. The boundary between using an origin snippet versus a build phase to
  522. modify the sources of a package can be elusive. Origin snippets are
  523. typically used to remove unwanted files such as bundled libraries,
  524. nonfree sources, or to apply simple substitutions. The source derived
  525. from an origin should produce a source that can be used to build the
  526. package on any system that the upstream package supports (i.e., act as
  527. the corresponding source). In particular, origin snippets must not
  528. embed store items in the sources; such patching should rather be done
  529. using build phases. Refer to the @code{origin} record documentation for
  530. more information (@pxref{origin Reference}).
  531. @node Emacs Packages
  532. @subsection Emacs Packages
  533. @cindex emacs, packaging
  534. @cindex elisp, packaging
  535. Emacs packages should preferably use the Emacs build system
  536. (@pxref{emacs-build-system}), for uniformity and the benefits provided
  537. by its build phases, such as the auto-generation of the autoloads file
  538. and the byte compilation of the sources. Because there is no
  539. standardized way to run a test suite for Emacs packages, tests are
  540. disabled by default. When a test suite is available, it should be
  541. enabled by setting the @code{#:tests?} argument to @code{#true}. By
  542. default, the command to run the test is @command{make check}, but any
  543. command can be specified via the @code{#:test-command} argument. The
  544. @code{#:test-command} argument expects a list containing a command and
  545. its arguments, to be invoked during the @code{check} phase.
  546. The Elisp dependencies of Emacs packages are typically provided as
  547. @code{propagated-inputs} when required at run time. As for other
  548. packages, build or test dependencies should be specified as
  549. @code{native-inputs}.
  550. Emacs packages sometimes depend on resources directories that should be
  551. installed along the Elisp files. The @code{#:include} argument can be
  552. used for that purpose, by specifying a list of regexps to match. The
  553. best practice when using the @code{#:include} argument is to extend
  554. rather than override its default value (accessible via the
  555. @code{%default-include} variable). As an example, a yasnippet extension
  556. package typically include a @file{snippets} directory, which could be
  557. copied to the installation directory using:
  558. @lisp
  559. #:include (cons "^snippets/" %default-include))
  560. @end lisp
  561. When encountering problems, it is wise to check for the presence of the
  562. @code{Package-Requires} extension header in the package main source
  563. file, and whether any dependencies and their versions listed therein are
  564. satisfied.
  565. @node Python Modules
  566. @subsection Python Modules
  567. @cindex python
  568. We currently package Python 2 and Python 3, under the Scheme variable names
  569. @code{python-2} and @code{python} as explained in @ref{Version Numbers}.
  570. To avoid confusion and naming clashes with other programming languages, it
  571. seems desirable that the name of a package for a Python module contains
  572. the word @code{python}.
  573. Some modules are compatible with only one version of Python, others with
  574. both. If the package Foo is compiled with Python 3, we name it
  575. @code{python-foo}. If it is compiled with Python 2, we name it
  576. @code{python2-foo}. Packages should be added when they are necessary;
  577. we don't add Python 2 variants of the package unless we are going to use
  578. them.
  579. If a project already contains the word @code{python}, we drop this;
  580. for instance, the module python-dateutil is packaged under the names
  581. @code{python-dateutil} and @code{python2-dateutil}. If the project name
  582. starts with @code{py} (e.g.@: @code{pytz}), we keep it and prefix it as
  583. described above.
  584. @subsubsection Specifying Dependencies
  585. @cindex inputs, for Python packages
  586. Dependency information for Python packages is usually available in the
  587. package source tree, with varying degrees of accuracy: in the
  588. @file{setup.py} file, in @file{requirements.txt}, or in @file{tox.ini}.
  589. Your mission, when writing a recipe for a Python package, is to map
  590. these dependencies to the appropriate type of ``input'' (@pxref{package
  591. Reference, inputs}). Although the @code{pypi} importer normally does a
  592. good job (@pxref{Invoking guix import}), you may want to check the
  593. following check list to determine which dependency goes where.
  594. @itemize
  595. @item
  596. We currently package Python 2 with @code{setuptools} and @code{pip}
  597. installed like Python 3.4 has per default. Thus you don't need to
  598. specify either of these as an input. @command{guix lint} will warn you
  599. if you do.
  600. @item
  601. Python dependencies required at run time go into
  602. @code{propagated-inputs}. They are typically defined with the
  603. @code{install_requires} keyword in @file{setup.py}, or in the
  604. @file{requirements.txt} file.
  605. @item
  606. Python packages required only at build time---e.g., those listed with
  607. the @code{setup_requires} keyword in @file{setup.py}---or only for
  608. testing---e.g., those in @code{tests_require}---go into
  609. @code{native-inputs}. The rationale is that (1) they do not need to be
  610. propagated because they are not needed at run time, and (2) in a
  611. cross-compilation context, it's the ``native'' input that we'd want.
  612. Examples are the @code{pytest}, @code{mock}, and @code{nose} test
  613. frameworks. Of course if any of these packages is also required at
  614. run-time, it needs to go to @code{propagated-inputs}.
  615. @item
  616. Anything that does not fall in the previous categories goes to
  617. @code{inputs}, for example programs or C libraries required for building
  618. Python packages containing C extensions.
  619. @item
  620. If a Python package has optional dependencies (@code{extras_require}),
  621. it is up to you to decide whether to add them or not, based on their
  622. usefulness/overhead ratio (@pxref{Submitting Patches, @command{guix
  623. size}}).
  624. @end itemize
  625. @node Perl Modules
  626. @subsection Perl Modules
  627. @cindex perl
  628. Perl programs standing for themselves are named as any other package,
  629. using the lowercase upstream name.
  630. For Perl packages containing a single class, we use the lowercase class name,
  631. replace all occurrences of @code{::} by dashes and prepend the prefix
  632. @code{perl-}.
  633. So the class @code{XML::Parser} becomes @code{perl-xml-parser}.
  634. Modules containing several classes keep their lowercase upstream name and
  635. are also prepended by @code{perl-}. Such modules tend to have the word
  636. @code{perl} somewhere in their name, which gets dropped in favor of the
  637. prefix. For instance, @code{libwww-perl} becomes @code{perl-libwww}.
  638. @node Java Packages
  639. @subsection Java Packages
  640. @cindex java
  641. Java programs standing for themselves are named as any other package,
  642. using the lowercase upstream name.
  643. To avoid confusion and naming clashes with other programming languages,
  644. it is desirable that the name of a package for a Java package is
  645. prefixed with @code{java-}. If a project already contains the word
  646. @code{java}, we drop this; for instance, the package @code{ngsjava} is
  647. packaged under the name @code{java-ngs}.
  648. For Java packages containing a single class or a small class hierarchy,
  649. we use the lowercase class name, replace all occurrences of @code{.} by
  650. dashes and prepend the prefix @code{java-}. So the class
  651. @code{apache.commons.cli} becomes package
  652. @code{java-apache-commons-cli}.
  653. @node Rust Crates
  654. @subsection Rust Crates
  655. @cindex rust
  656. Rust programs standing for themselves are named as any other package, using the
  657. lowercase upstream name.
  658. To prevent namespace collisions we prefix all other Rust packages with the
  659. @code{rust-} prefix. The name should be changed to lowercase as appropriate and
  660. dashes should remain in place.
  661. In the rust ecosystem it is common for multiple incompatible versions of a
  662. package to be used at any given time, so all packages should have a versioned
  663. suffix. If a package has passed version 1.0.0 then just the major version
  664. number is sufficient (e.g.@: @code{rust-clap-2}), otherwise the version suffix
  665. should contain both the major and minor version (e.g.@: @code{rust-rand-0.6}).
  666. Because of the difficulty in reusing rust packages as pre-compiled inputs for
  667. other packages the Cargo build system (@pxref{Build Systems,
  668. @code{cargo-build-system}}) presents the @code{#:cargo-inputs} and
  669. @code{cargo-development-inputs} keywords as build system arguments. It would be
  670. helpful to think of these as similar to @code{propagated-inputs} and
  671. @code{native-inputs}. Rust @code{dependencies} and @code{build-dependencies}
  672. should go in @code{#:cargo-inputs}, and @code{dev-dependencies} should go in
  673. @code{#:cargo-development-inputs}. If a Rust package links to other libraries
  674. then the standard placement in @code{inputs} and the like should be used.
  675. Care should be taken to ensure the correct version of dependencies are used; to
  676. this end we try to refrain from skipping the tests or using @code{#:skip-build?}
  677. when possible. Of course this is not always possible, as the package may be
  678. developed for a different Operating System, depend on features from the Nightly
  679. Rust compiler, or the test suite may have atrophied since it was released.
  680. @node Fonts
  681. @subsection Fonts
  682. @cindex fonts
  683. For fonts that are in general not installed by a user for typesetting
  684. purposes, or that are distributed as part of a larger software package,
  685. we rely on the general packaging rules for software; for instance, this
  686. applies to the fonts delivered as part of the X.Org system or fonts that
  687. are part of TeX Live.
  688. To make it easier for a user to search for fonts, names for other packages
  689. containing only fonts are constructed as follows, independently of the
  690. upstream package name.
  691. The name of a package containing only one font family starts with
  692. @code{font-}; it is followed by the foundry name and a dash @code{-}
  693. if the foundry is known, and the font family name, in which spaces are
  694. replaced by dashes (and as usual, all upper case letters are transformed
  695. to lower case).
  696. For example, the Gentium font family by SIL is packaged under the name
  697. @code{font-sil-gentium}.
  698. For a package containing several font families, the name of the collection
  699. is used in the place of the font family name.
  700. For instance, the Liberation fonts consist of three families,
  701. Liberation Sans, Liberation Serif and Liberation Mono.
  702. These could be packaged separately under the names
  703. @code{font-liberation-sans} and so on; but as they are distributed together
  704. under a common name, we prefer to package them together as
  705. @code{font-liberation}.
  706. In the case where several formats of the same font family or font collection
  707. are packaged separately, a short form of the format, prepended by a dash,
  708. is added to the package name. We use @code{-ttf} for TrueType fonts,
  709. @code{-otf} for OpenType fonts and @code{-type1} for PostScript Type 1
  710. fonts.
  711. @node Coding Style
  712. @section Coding Style
  713. In general our code follows the GNU Coding Standards (@pxref{Top,,,
  714. standards, GNU Coding Standards}). However, they do not say much about
  715. Scheme, so here are some additional rules.
  716. @menu
  717. * Programming Paradigm:: How to compose your elements.
  718. * Modules:: Where to store your code?
  719. * Data Types and Pattern Matching:: Implementing data structures.
  720. * Formatting Code:: Writing conventions.
  721. @end menu
  722. @node Programming Paradigm
  723. @subsection Programming Paradigm
  724. Scheme code in Guix is written in a purely functional style. One
  725. exception is code that involves input/output, and procedures that
  726. implement low-level concepts, such as the @code{memoize} procedure.
  727. @node Modules
  728. @subsection Modules
  729. Guile modules that are meant to be used on the builder side must live in
  730. the @code{(guix build @dots{})} name space. They must not refer to
  731. other Guix or GNU modules. However, it is OK for a ``host-side'' module
  732. to use a build-side module.
  733. Modules that deal with the broader GNU system should be in the
  734. @code{(gnu @dots{})} name space rather than @code{(guix @dots{})}.
  735. @node Data Types and Pattern Matching
  736. @subsection Data Types and Pattern Matching
  737. The tendency in classical Lisp is to use lists to represent everything,
  738. and then to browse them ``by hand'' using @code{car}, @code{cdr},
  739. @code{cadr}, and co. There are several problems with that style,
  740. notably the fact that it is hard to read, error-prone, and a hindrance
  741. to proper type error reports.
  742. Guix code should define appropriate data types (for instance, using
  743. @code{define-record-type*}) rather than abuse lists. In addition, it
  744. should use pattern matching, via Guile’s @code{(ice-9 match)} module,
  745. especially when matching lists (@pxref{Pattern Matching,,, guile, GNU
  746. Guile Reference Manual}).
  747. @node Formatting Code
  748. @subsection Formatting Code
  749. @cindex formatting code
  750. @cindex coding style
  751. When writing Scheme code, we follow common wisdom among Scheme
  752. programmers. In general, we follow the
  753. @url{https://mumble.net/~campbell/scheme/style.txt, Riastradh's Lisp
  754. Style Rules}. This document happens to describe the conventions mostly
  755. used in Guile’s code too. It is very thoughtful and well written, so
  756. please do read it.
  757. Some special forms introduced in Guix, such as the @code{substitute*}
  758. macro, have special indentation rules. These are defined in the
  759. @file{.dir-locals.el} file, which Emacs automatically uses. Also note
  760. that Emacs-Guix provides @code{guix-devel-mode} mode that indents and
  761. highlights Guix code properly (@pxref{Development,,, emacs-guix, The
  762. Emacs-Guix Reference Manual}).
  763. @cindex indentation, of code
  764. @cindex formatting, of code
  765. If you do not use Emacs, please make sure to let your editor knows these
  766. rules. To automatically indent a package definition, you can also run:
  767. @example
  768. ./etc/indent-code.el gnu/packages/@var{file}.scm @var{package}
  769. @end example
  770. @noindent
  771. This automatically indents the definition of @var{package} in
  772. @file{gnu/packages/@var{file}.scm} by running Emacs in batch mode. To
  773. indent a whole file, omit the second argument:
  774. @example
  775. ./etc/indent-code.el gnu/services/@var{file}.scm
  776. @end example
  777. @cindex Vim, Scheme code editing
  778. If you are editing code with Vim, we recommend that you run @code{:set
  779. autoindent} so that your code is automatically indented as you type.
  780. Additionally,
  781. @uref{https://www.vim.org/scripts/script.php?script_id=3998,
  782. @code{paredit.vim}} may help you deal with all these parentheses.
  783. We require all top-level procedures to carry a docstring. This
  784. requirement can be relaxed for simple private procedures in the
  785. @code{(guix build @dots{})} name space, though.
  786. Procedures should not have more than four positional parameters. Use
  787. keyword parameters for procedures that take more than four parameters.
  788. @node Submitting Patches
  789. @section Submitting Patches
  790. Development is done using the Git distributed version control system.
  791. Thus, access to the repository is not strictly necessary. We welcome
  792. contributions in the form of patches as produced by @code{git
  793. format-patch} sent to the @email{guix-patches@@gnu.org} mailing list.
  794. Seasoned Guix developers may also want to look at the section on commit
  795. access (@pxref{Commit Access}).
  796. This mailing list is backed by a Debbugs instance, which allows us to
  797. keep track of submissions (@pxref{Tracking Bugs and Patches}). Each
  798. message sent to that mailing list gets a new tracking number assigned;
  799. people can then follow up on the submission by sending email to
  800. @code{@var{NNN}@@debbugs.gnu.org}, where @var{NNN} is the tracking
  801. number (@pxref{Sending a Patch Series}).
  802. Please write commit logs in the ChangeLog format (@pxref{Change Logs,,,
  803. standards, GNU Coding Standards}); you can check the commit history for
  804. examples.
  805. Before submitting a patch that adds or modifies a package definition,
  806. please run through this check list:
  807. @enumerate
  808. @item
  809. If the authors of the packaged software provide a cryptographic
  810. signature for the release tarball, make an effort to verify the
  811. authenticity of the archive. For a detached GPG signature file this
  812. would be done with the @code{gpg --verify} command.
  813. @item
  814. Take some time to provide an adequate synopsis and description for the
  815. package. @xref{Synopses and Descriptions}, for some guidelines.
  816. @item
  817. Run @code{guix lint @var{package}}, where @var{package} is the
  818. name of the new or modified package, and fix any errors it reports
  819. (@pxref{Invoking guix lint}).
  820. @item
  821. Make sure the package builds on your platform, using @code{guix build
  822. @var{package}}.
  823. @item
  824. We recommend you also try building the package on other supported
  825. platforms. As you may not have access to actual hardware platforms, we
  826. recommend using the @code{qemu-binfmt-service-type} to emulate them. In
  827. order to enable it, add the following service to the list of services in
  828. your @code{operating-system} configuration:
  829. @lisp
  830. (service qemu-binfmt-service-type
  831. (qemu-binfmt-configuration
  832. (platforms (lookup-qemu-platforms "arm" "aarch64"))
  833. (guix-support? #t)))
  834. @end lisp
  835. Then reconfigure your system.
  836. You can then build packages for different platforms by specifying the
  837. @code{--system} option. For example, to build the "hello" package for
  838. the armhf, aarch64, or mips64 architectures, you would run the following
  839. commands, respectively:
  840. @example
  841. guix build --system=armhf-linux --rounds=2 hello
  842. guix build --system=aarch64-linux --rounds=2 hello
  843. @end example
  844. @item
  845. @cindex bundling
  846. Make sure the package does not use bundled copies of software already
  847. available as separate packages.
  848. Sometimes, packages include copies of the source code of their
  849. dependencies as a convenience for users. However, as a distribution, we
  850. want to make sure that such packages end up using the copy we already
  851. have in the distribution, if there is one. This improves resource usage
  852. (the dependency is built and stored only once), and allows the
  853. distribution to make transverse changes such as applying security
  854. updates for a given software package in a single place and have them
  855. affect the whole system---something that bundled copies prevent.
  856. @item
  857. Take a look at the profile reported by @command{guix size}
  858. (@pxref{Invoking guix size}). This will allow you to notice references
  859. to other packages unwillingly retained. It may also help determine
  860. whether to split the package (@pxref{Packages with Multiple Outputs}),
  861. and which optional dependencies should be used. In particular, avoid adding
  862. @code{texlive} as a dependency: because of its extreme size, use
  863. the @code{texlive-tiny} package or @code{texlive-union} procedure instead.
  864. @item
  865. For important changes, check that dependent package (if applicable) are
  866. not affected by the change; @code{guix refresh --list-dependent
  867. @var{package}} will help you do that (@pxref{Invoking guix refresh}).
  868. @c See <https://lists.gnu.org/archive/html/guix-devel/2016-10/msg00933.html>.
  869. @cindex branching strategy
  870. @cindex rebuild scheduling strategy
  871. Depending on the number of dependent packages and thus the amount of
  872. rebuilding induced, commits go to different branches, along these lines:
  873. @table @asis
  874. @item 300 dependent packages or less
  875. @code{master} branch (non-disruptive changes).
  876. @item between 300 and 1,800 dependent packages
  877. @code{staging} branch (non-disruptive changes). This branch is intended
  878. to be merged in @code{master} every 6 weeks or so. Topical changes
  879. (e.g., an update of the GNOME stack) can instead go to a specific branch
  880. (say, @code{gnome-updates}).
  881. @item more than 1,800 dependent packages
  882. @code{core-updates} branch (may include major and potentially disruptive
  883. changes). This branch is intended to be merged in @code{master} every
  884. 6 months or so.
  885. @end table
  886. All these branches are @uref{@value{SUBSTITUTE-URL},
  887. tracked by our build farm} and merged into @code{master} once
  888. everything has been successfully built. This allows us to fix issues
  889. before they hit users, and to reduce the window during which pre-built
  890. binaries are not available.
  891. Generally, branches other than @code{master} are considered
  892. @emph{frozen} if there has been a recent evaluation, or there is a
  893. corresponding @code{-next} branch. Please ask on the mailing list or
  894. IRC if unsure where to place a patch.
  895. @c TODO: It would be good with badges on the website that tracks these
  896. @c branches. Or maybe even a status page.
  897. @item
  898. @cindex determinism, of build processes
  899. @cindex reproducible builds, checking
  900. Check whether the package's build process is deterministic. This
  901. typically means checking whether an independent build of the package
  902. yields the exact same result that you obtained, bit for bit.
  903. A simple way to do that is by building the same package several times in
  904. a row on your machine (@pxref{Invoking guix build}):
  905. @example
  906. guix build --rounds=2 my-package
  907. @end example
  908. This is enough to catch a class of common non-determinism issues, such
  909. as timestamps or randomly-generated output in the build result.
  910. Another option is to use @command{guix challenge} (@pxref{Invoking guix
  911. challenge}). You may run it once the package has been committed and
  912. built by @code{@value{SUBSTITUTE-SERVER}} to check whether it obtains the same
  913. result as you did. Better yet: Find another machine that can build it
  914. and run @command{guix publish}. Since the remote build machine is
  915. likely different from yours, this can catch non-determinism issues
  916. related to the hardware---e.g., use of different instruction set
  917. extensions---or to the operating system kernel---e.g., reliance on
  918. @code{uname} or @file{/proc} files.
  919. @item
  920. When writing documentation, please use gender-neutral wording when
  921. referring to people, such as
  922. @uref{https://en.wikipedia.org/wiki/Singular_they, singular
  923. ``they''@comma{} ``their''@comma{} ``them''}, and so forth.
  924. @item
  925. Verify that your patch contains only one set of related changes.
  926. Bundling unrelated changes together makes reviewing harder and slower.
  927. Examples of unrelated changes include the addition of several packages,
  928. or a package update along with fixes to that package.
  929. @item
  930. Please follow our code formatting rules, possibly running the
  931. @command{etc/indent-code.el} script to do that automatically for you
  932. (@pxref{Formatting Code}).
  933. @item
  934. When possible, use mirrors in the source URL (@pxref{Invoking guix download}).
  935. Use reliable URLs, not generated ones. For instance, GitHub archives are not
  936. necessarily identical from one generation to the next, so in this case it's
  937. often better to clone the repository. Don't use the @command{name} field in
  938. the URL: it is not very useful and if the name changes, the URL will probably
  939. be wrong.
  940. @item
  941. Check if Guix builds (@pxref{Building from Git}) and address the
  942. warnings, especially those about use of undefined symbols.
  943. @item
  944. Make sure your changes do not break Guix and simulate a @code{guix pull} with:
  945. @example
  946. guix pull --url=/path/to/your/checkout --profile=/tmp/guix.master
  947. @end example
  948. @end enumerate
  949. When posting a patch to the mailing list, use @samp{[PATCH] @dots{}} as
  950. a subject, if your patch is to be applied on a branch other than
  951. @code{master}, say @code{core-updates}, specify it in the subject like
  952. @samp{[PATCH core-updates] @dots{}}. You may use your email client or
  953. the @command{git send-email} command (@pxref{Sending a Patch Series}).
  954. We prefer to get patches in plain text messages, either inline or as
  955. MIME attachments. You are advised to pay attention if your email client
  956. changes anything like line breaks or indentation which could potentially
  957. break the patches.
  958. When a bug is resolved, please close the thread by sending an email to
  959. @email{@var{NNN}-done@@debbugs.gnu.org}.
  960. @unnumberedsubsec Sending a Patch Series
  961. @anchor{Sending a Patch Series}
  962. @cindex patch series
  963. @cindex @code{git send-email}
  964. @cindex @code{git-send-email}
  965. When sending a patch series (e.g., using @code{git send-email}), please
  966. first send one message to @email{guix-patches@@gnu.org}, and then send
  967. subsequent patches to @email{@var{NNN}@@debbugs.gnu.org} to make sure
  968. they are kept together. See
  969. @uref{https://debbugs.gnu.org/Advanced.html, the Debbugs documentation}
  970. for more information. You can install @command{git send-email} with
  971. @command{guix install git:send-email}.
  972. @c Debbugs bug: https://debbugs.gnu.org/db/15/15361.html
  973. @node Tracking Bugs and Patches
  974. @section Tracking Bugs and Patches
  975. @cindex bug reports, tracking
  976. @cindex patch submissions, tracking
  977. @cindex issue tracking
  978. @cindex Debbugs, issue tracking system
  979. Bug reports and patch submissions are currently tracked using the
  980. Debbugs instance at @uref{https://bugs.gnu.org}. Bug reports are filed
  981. against the @code{guix} ``package'' (in Debbugs parlance), by sending
  982. email to @email{bug-guix@@gnu.org}, while patch submissions are filed
  983. against the @code{guix-patches} package by sending email to
  984. @email{guix-patches@@gnu.org} (@pxref{Submitting Patches}).
  985. A web interface (actually @emph{two} web interfaces!) are available to
  986. browse issues:
  987. @itemize
  988. @item
  989. @url{https://issues.guix.gnu.org} provides a pleasant
  990. interface@footnote{The web interface at
  991. @url{https://issues.guix.gnu.org} is powered by Mumi, a nice piece of
  992. software written in Guile, and you can help! See
  993. @url{https://git.elephly.net/gitweb.cgi?p=software/mumi.git}.} to browse
  994. bug reports and patches, and to participate in discussions;
  995. @item
  996. @url{https://bugs.gnu.org/guix} lists bug reports;
  997. @item
  998. @url{https://bugs.gnu.org/guix-patches} lists patch submissions.
  999. @end itemize
  1000. To view discussions related to issue number @var{n}, go to
  1001. @indicateurl{https://issues.guix.gnu.org/@var{n}} or
  1002. @indicateurl{https://bugs.gnu.org/@var{n}}.
  1003. If you use Emacs, you may find it more convenient to interact with
  1004. issues using @file{debbugs.el}, which you can install with:
  1005. @example
  1006. guix install emacs-debbugs
  1007. @end example
  1008. For example, to list all open issues on @code{guix-patches}, hit:
  1009. @example
  1010. @kbd{C-u} @kbd{M-x} debbugs-gnu @kbd{RET} @kbd{RET} guix-patches @kbd{RET} n y
  1011. @end example
  1012. @xref{Top,,, debbugs-ug, Debbugs User Guide}, for more information on
  1013. this nifty tool!
  1014. @node Commit Access
  1015. @section Commit Access
  1016. @cindex commit access, for developers
  1017. For frequent contributors, having write access to the repository is
  1018. convenient. When you deem it necessary, consider applying for commit
  1019. access by following these steps:
  1020. @enumerate
  1021. @item
  1022. Find three committers who would vouch for you. You can view the list of
  1023. committers at
  1024. @url{https://savannah.gnu.org/project/memberlist.php?group=guix}. Each
  1025. of them should email a statement to @email{guix-maintainers@@gnu.org} (a
  1026. private alias for the collective of maintainers), signed with their
  1027. OpenPGP key.
  1028. Committers are expected to have had some interactions with you as a
  1029. contributor and to be able to judge whether you are sufficiently
  1030. familiar with the project's practices. It is @emph{not} a judgment on
  1031. the value of your work, so a refusal should rather be interpreted as
  1032. ``let's try again later''.
  1033. @item
  1034. Send @email{guix-maintainers@@gnu.org} a message stating your intent,
  1035. listing the three committers who support your application, signed with
  1036. the OpenPGP key you will use to sign commits, and giving its fingerprint
  1037. (see below). See @uref{https://emailselfdefense.fsf.org/en/}, for an
  1038. introduction to public-key cryptography with GnuPG.
  1039. @c See <https://sha-mbles.github.io/>.
  1040. Set up GnuPG such that it never uses the SHA1 hash algorithm for digital
  1041. signatures, which is known to be unsafe since 2019, for instance by
  1042. adding the following line to @file{~/.gnupg/gpg.conf} (@pxref{GPG
  1043. Esoteric Options,,, gnupg, The GNU Privacy Guard Manual}):
  1044. @example
  1045. digest-algo sha512
  1046. @end example
  1047. @item
  1048. Maintainers ultimately decide whether to grant you commit access,
  1049. usually following your referrals' recommendation.
  1050. @item
  1051. @cindex OpenPGP, signed commits
  1052. If and once you've been given access, please send a message to
  1053. @email{guix-devel@@gnu.org} to say so, again signed with the OpenPGP key
  1054. you will use to sign commits (do that before pushing your first commit).
  1055. That way, everyone can notice and ensure you control that OpenPGP key.
  1056. @quotation Important
  1057. Before you can push for the first time, maintainers must:
  1058. @enumerate
  1059. @item
  1060. add your OpenPGP key to the @code{keyring} branch;
  1061. @item
  1062. add your OpenPGP fingerprint to the @file{.guix-authorizations} file of
  1063. the branch(es) you will commit to.
  1064. @end enumerate
  1065. @end quotation
  1066. @item
  1067. Make sure to read the rest of this section and... profit!
  1068. @end enumerate
  1069. @quotation Note
  1070. Maintainers are happy to give commit access to people who have been
  1071. contributing for some time and have a track record---don't be shy and
  1072. don't underestimate your work!
  1073. However, note that the project is working towards a more automated patch
  1074. review and merging system, which, as a consequence, may lead us to have
  1075. fewer people with commit access to the main repository. Stay tuned!
  1076. @end quotation
  1077. If you get commit access, please make sure to follow
  1078. the policy below (discussions of the policy can take place on
  1079. @email{guix-devel@@gnu.org}).
  1080. Non-trivial patches should always be posted to
  1081. @email{guix-patches@@gnu.org} (trivial patches include fixing typos,
  1082. etc.). This mailing list fills the patch-tracking database
  1083. (@pxref{Tracking Bugs and Patches}).
  1084. For patches that just add a new package, and a simple one, it's OK to
  1085. commit, if you're confident (which means you successfully built it in a
  1086. chroot setup, and have done a reasonable copyright and license
  1087. auditing). Likewise for package upgrades, except upgrades that trigger
  1088. a lot of rebuilds (for example, upgrading GnuTLS or GLib). We have a
  1089. mailing list for commit notifications (@email{guix-commits@@gnu.org}),
  1090. so people can notice. Before pushing your changes, make sure to run
  1091. @code{git pull --rebase}.
  1092. All commits that are pushed to the central repository on Savannah must
  1093. be signed with an OpenPGP key, and the public key should be uploaded to
  1094. your user account on Savannah and to public key servers, such as
  1095. @code{keys.openpgp.org}. To configure Git to automatically sign
  1096. commits, run:
  1097. @example
  1098. git config commit.gpgsign true
  1099. git config user.signingkey CABBA6EA1DC0FF33
  1100. @end example
  1101. You can prevent yourself from accidentally pushing unsigned commits to
  1102. Savannah by using the pre-push Git hook called located at
  1103. @file{etc/git/pre-push}:
  1104. @example
  1105. cp etc/git/pre-push .git/hooks/pre-push
  1106. @end example
  1107. When pushing a commit on behalf of somebody else, please add a
  1108. @code{Signed-off-by} line at the end of the commit log message---e.g.,
  1109. with @command{git am --signoff}. This improves tracking of who did
  1110. what.
  1111. When adding channel news entries (@pxref{Channels, Writing Channel
  1112. News}), make sure they are well-formed by running the following command
  1113. right before pushing:
  1114. @example
  1115. make check-channel-news
  1116. @end example
  1117. For anything else, please post to @email{guix-patches@@gnu.org} and
  1118. leave time for a review, without committing anything (@pxref{Submitting
  1119. Patches}). If you didn’t receive any reply after two weeks, and if
  1120. you're confident, it's OK to commit.
  1121. That last part is subject to being adjusted, allowing individuals to commit
  1122. directly on non-controversial changes on parts they’re familiar with.
  1123. One last thing: the project keeps moving forward because committers not
  1124. only push their own awesome changes, but also offer some of their time
  1125. @emph{reviewing} and pushing other people's changes. As a committer,
  1126. you're welcome to use your expertise and commit rights to help other
  1127. contributors, too!
  1128. @node Updating the Guix Package
  1129. @section Updating the Guix Package
  1130. @cindex update-guix-package, updating the guix package
  1131. It is sometimes desirable to update the @code{guix} package itself (the
  1132. package defined in @code{(gnu packages package-management)}), for
  1133. example to make new daemon features available for use by the
  1134. @code{guix-service-type} service type. In order to simplify this task,
  1135. the following command can be used:
  1136. @example
  1137. make update-guix-package
  1138. @end example
  1139. The @code{update-guix-package} make target will use the last known
  1140. @emph{commit} corresponding to @code{HEAD} in your Guix checkout,
  1141. compute the hash of the Guix sources corresponding to that commit and
  1142. update the @code{commit}, @code{revision} and hash of the @code{guix}
  1143. package definition.
  1144. To validate that the updated @code{guix} package hashes are correct and
  1145. that it can be built successfully, the following command can be run from
  1146. the directory of your Guix checkout:
  1147. @example
  1148. ./pre-inst-env guix build guix
  1149. @end example
  1150. To guard against accidentally updating the @code{guix} package to a
  1151. commit that others can't refer to, a check is made that the commit used
  1152. has already been pushed to the Savannah-hosted Guix git repository.
  1153. This check can be disabled, @emph{at your own peril}, by setting the
  1154. @code{GUIX_ALLOW_ME_TO_USE_PRIVATE_COMMIT} environment variable. When
  1155. this variable is set, the updated package source is also added to the
  1156. store. This is used as part of the release process of Guix.