contributing.texi 58 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432
  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 && make check} to build Guix and
  105. run the tests (@pxref{Running the Test Suite}). If anything fails, take
  106. a look at installation instructions (@pxref{Installation}) or send a
  107. 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 actually has 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. A noteworthy exception to this rule is when the project name is only a
  365. single character, or if an older maintained project with the same name
  366. already exists---regardless of whether it has already been packaged for
  367. Guix. Use common sense to make such names unambiguous and meaningful.
  368. For example, Guix's package for the shell called ``s'' upstream is
  369. @code{s-shell} and @emph{not} @code{s}. Feel free to ask your fellow
  370. hackers for inspiration.
  371. We do not add @code{lib} prefixes for library packages, unless these are
  372. already part of the official project name. But @pxref{Python
  373. Modules} and @ref{Perl Modules} for special rules concerning modules for
  374. the Python and Perl languages.
  375. Font package names are handled differently, @pxref{Fonts}.
  376. @node Version Numbers
  377. @subsection Version Numbers
  378. @cindex package version
  379. We usually package only the latest version of a given free software
  380. project. But sometimes, for instance for incompatible library versions,
  381. two (or more) versions of the same package are needed. These require
  382. different Scheme variable names. We use the name as defined
  383. in @ref{Package Naming}
  384. for the most recent version; previous versions use the same name, suffixed
  385. by @code{-} and the smallest prefix of the version number that may
  386. distinguish the two versions.
  387. The name inside the package definition is the same for all versions of a
  388. package and does not contain any version number.
  389. For instance, the versions 2.24.20 and 3.9.12 of GTK+ may be packaged as follows:
  390. @lisp
  391. (define-public gtk+
  392. (package
  393. (name "gtk+")
  394. (version "3.9.12")
  395. ...))
  396. (define-public gtk+-2
  397. (package
  398. (name "gtk+")
  399. (version "2.24.20")
  400. ...))
  401. @end lisp
  402. If we also wanted GTK+ 3.8.2, this would be packaged as
  403. @lisp
  404. (define-public gtk+-3.8
  405. (package
  406. (name "gtk+")
  407. (version "3.8.2")
  408. ...))
  409. @end lisp
  410. @c See <https://lists.gnu.org/archive/html/guix-devel/2016-01/msg00425.html>,
  411. @c for a discussion of what follows.
  412. @cindex version number, for VCS snapshots
  413. Occasionally, we package snapshots of upstream's version control system
  414. (VCS) instead of formal releases. This should remain exceptional,
  415. because it is up to upstream developers to clarify what the stable
  416. release is. Yet, it is sometimes necessary. So, what should we put in
  417. the @code{version} field?
  418. Clearly, we need to make the commit identifier of the VCS snapshot
  419. visible in the version string, but we also need to make sure that the
  420. version string is monotonically increasing so that @command{guix package
  421. --upgrade} can determine which version is newer. Since commit
  422. identifiers, notably with Git, are not monotonically increasing, we add
  423. a revision number that we increase each time we upgrade to a newer
  424. snapshot. The resulting version string looks like this:
  425. @example
  426. 2.0.11-3.cabba9e
  427. ^ ^ ^
  428. | | `-- upstream commit ID
  429. | |
  430. | `--- Guix package revision
  431. |
  432. latest upstream version
  433. @end example
  434. It is a good idea to strip commit identifiers in the @code{version}
  435. field to, say, 7 digits. It avoids an aesthetic annoyance (assuming
  436. aesthetics have a role to play here) as well as problems related to OS
  437. limits such as the maximum shebang length (127 bytes for the Linux
  438. kernel). It is best to use the full commit identifiers in
  439. @code{origin}s, though, to avoid ambiguities. A typical package
  440. definition may look like this:
  441. @lisp
  442. (define my-package
  443. (let ((commit "c3f29bc928d5900971f65965feaae59e1272a3f7")
  444. (revision "1")) ;Guix package revision
  445. (package
  446. (version (git-version "0.9" revision commit))
  447. (source (origin
  448. (method git-fetch)
  449. (uri (git-reference
  450. (url "git://example.org/my-package.git")
  451. (commit commit)))
  452. (sha256 (base32 "1mbikn@dots{}"))
  453. (file-name (git-file-name name version))))
  454. ;; @dots{}
  455. )))
  456. @end lisp
  457. @node Synopses and Descriptions
  458. @subsection Synopses and Descriptions
  459. @cindex package description
  460. @cindex package synopsis
  461. As we have seen before, each package in GNU@tie{}Guix includes a
  462. synopsis and a description (@pxref{Defining Packages}). Synopses and
  463. descriptions are important: They are what @command{guix package
  464. --search} searches, and a crucial piece of information to help users
  465. determine whether a given package suits their needs. Consequently,
  466. packagers should pay attention to what goes into them.
  467. Synopses must start with a capital letter and must not end with a
  468. period. They must not start with ``a'' or ``the'', which usually does
  469. not bring anything; for instance, prefer ``File-frobbing tool'' over ``A
  470. tool that frobs files''. The synopsis should say what the package
  471. is---e.g., ``Core GNU utilities (file, text, shell)''---or what it is
  472. used for---e.g., the synopsis for GNU@tie{}grep is ``Print lines
  473. matching a pattern''.
  474. Keep in mind that the synopsis must be meaningful for a very wide
  475. audience. For example, ``Manipulate alignments in the SAM format''
  476. might make sense for a seasoned bioinformatics researcher, but might be
  477. fairly unhelpful or even misleading to a non-specialized audience. It
  478. is a good idea to come up with a synopsis that gives an idea of the
  479. application domain of the package. In this example, this might give
  480. something like ``Manipulate nucleotide sequence alignments'', which
  481. hopefully gives the user a better idea of whether this is what they are
  482. looking for.
  483. Descriptions should take between five and ten lines. Use full
  484. sentences, and avoid using acronyms without first introducing them.
  485. Please avoid marketing phrases such as ``world-leading'',
  486. ``industrial-strength'', and ``next-generation'', and avoid superlatives
  487. like ``the most advanced''---they are not helpful to users looking for a
  488. package and may even sound suspicious. Instead, try to be factual,
  489. mentioning use cases and features.
  490. @cindex Texinfo markup, in package descriptions
  491. Descriptions can include Texinfo markup, which is useful to introduce
  492. ornaments such as @code{@@code} or @code{@@dfn}, bullet lists, or
  493. hyperlinks (@pxref{Overview,,, texinfo, GNU Texinfo}). However you
  494. should be careful when using some characters for example @samp{@@} and
  495. curly braces which are the basic special characters in Texinfo
  496. (@pxref{Special Characters,,, texinfo, GNU Texinfo}). User interfaces
  497. such as @command{guix package --show} take care of rendering it
  498. appropriately.
  499. Synopses and descriptions are translated by volunteers
  500. @uref{https://translate.fedoraproject.org/projects/guix/packages, at
  501. Weblate} so that as many users as possible can read them in
  502. their native language. User interfaces search them and display them in
  503. the language specified by the current locale.
  504. To allow @command{xgettext} to extract them as translatable strings,
  505. synopses and descriptions @emph{must be literal strings}. This means
  506. that you cannot use @code{string-append} or @code{format} to construct
  507. these strings:
  508. @lisp
  509. (package
  510. ;; @dots{}
  511. (synopsis "This is translatable")
  512. (description (string-append "This is " "*not*" " translatable.")))
  513. @end lisp
  514. Translation is a lot of work so, as a packager, please pay even more
  515. attention to your synopses and descriptions as every change may entail
  516. additional work for translators. In order to help them, it is possible
  517. to make recommendations or instructions visible to them by inserting
  518. special comments like this (@pxref{xgettext Invocation,,, gettext, GNU
  519. Gettext}):
  520. @lisp
  521. ;; TRANSLATORS: "X11 resize-and-rotate" should not be translated.
  522. (description "ARandR is designed to provide a simple visual front end
  523. for the X11 resize-and-rotate (RandR) extension. @dots{}")
  524. @end lisp
  525. @node Snippets versus Phases
  526. @subsection Snippets versus Phases
  527. @cindex snippets, when to use
  528. The boundary between using an origin snippet versus a build phase to
  529. modify the sources of a package can be elusive. Origin snippets are
  530. typically used to remove unwanted files such as bundled libraries,
  531. nonfree sources, or to apply simple substitutions. The source derived
  532. from an origin should produce a source that can be used to build the
  533. package on any system that the upstream package supports (i.e., act as
  534. the corresponding source). In particular, origin snippets must not
  535. embed store items in the sources; such patching should rather be done
  536. using build phases. Refer to the @code{origin} record documentation for
  537. more information (@pxref{origin Reference}).
  538. @node Emacs Packages
  539. @subsection Emacs Packages
  540. @cindex emacs, packaging
  541. @cindex elisp, packaging
  542. Emacs packages should preferably use the Emacs build system
  543. (@pxref{emacs-build-system}), for uniformity and the benefits provided
  544. by its build phases, such as the auto-generation of the autoloads file
  545. and the byte compilation of the sources. Because there is no
  546. standardized way to run a test suite for Emacs packages, tests are
  547. disabled by default. When a test suite is available, it should be
  548. enabled by setting the @code{#:tests?} argument to @code{#true}. By
  549. default, the command to run the test is @command{make check}, but any
  550. command can be specified via the @code{#:test-command} argument. The
  551. @code{#:test-command} argument expects a list containing a command and
  552. its arguments, to be invoked during the @code{check} phase.
  553. The Elisp dependencies of Emacs packages are typically provided as
  554. @code{propagated-inputs} when required at run time. As for other
  555. packages, build or test dependencies should be specified as
  556. @code{native-inputs}.
  557. Emacs packages sometimes depend on resources directories that should be
  558. installed along the Elisp files. The @code{#:include} argument can be
  559. used for that purpose, by specifying a list of regexps to match. The
  560. best practice when using the @code{#:include} argument is to extend
  561. rather than override its default value (accessible via the
  562. @code{%default-include} variable). As an example, a yasnippet extension
  563. package typically include a @file{snippets} directory, which could be
  564. copied to the installation directory using:
  565. @lisp
  566. #:include (cons "^snippets/" %default-include))
  567. @end lisp
  568. When encountering problems, it is wise to check for the presence of the
  569. @code{Package-Requires} extension header in the package main source
  570. file, and whether any dependencies and their versions listed therein are
  571. satisfied.
  572. @node Python Modules
  573. @subsection Python Modules
  574. @cindex python
  575. We currently package Python 2 and Python 3, under the Scheme variable names
  576. @code{python-2} and @code{python} as explained in @ref{Version Numbers}.
  577. To avoid confusion and naming clashes with other programming languages, it
  578. seems desirable that the name of a package for a Python module contains
  579. the word @code{python}.
  580. Some modules are compatible with only one version of Python, others with
  581. both. If the package Foo is compiled with Python 3, we name it
  582. @code{python-foo}. If it is compiled with Python 2, we name it
  583. @code{python2-foo}. Packages should be added when they are necessary;
  584. we don't add Python 2 variants of the package unless we are going to use
  585. them.
  586. If a project already contains the word @code{python}, we drop this;
  587. for instance, the module python-dateutil is packaged under the names
  588. @code{python-dateutil} and @code{python2-dateutil}. If the project name
  589. starts with @code{py} (e.g.@: @code{pytz}), we keep it and prefix it as
  590. described above.
  591. @subsubsection Specifying Dependencies
  592. @cindex inputs, for Python packages
  593. Dependency information for Python packages is usually available in the
  594. package source tree, with varying degrees of accuracy: in the
  595. @file{setup.py} file, in @file{requirements.txt}, or in @file{tox.ini}.
  596. Your mission, when writing a recipe for a Python package, is to map
  597. these dependencies to the appropriate type of ``input'' (@pxref{package
  598. Reference, inputs}). Although the @code{pypi} importer normally does a
  599. good job (@pxref{Invoking guix import}), you may want to check the
  600. following check list to determine which dependency goes where.
  601. @itemize
  602. @item
  603. We currently package Python 2 with @code{setuptools} and @code{pip}
  604. installed like Python 3.4 has per default. Thus you don't need to
  605. specify either of these as an input. @command{guix lint} will warn you
  606. if you do.
  607. @item
  608. Python dependencies required at run time go into
  609. @code{propagated-inputs}. They are typically defined with the
  610. @code{install_requires} keyword in @file{setup.py}, or in the
  611. @file{requirements.txt} file.
  612. @item
  613. Python packages required only at build time---e.g., those listed with
  614. the @code{setup_requires} keyword in @file{setup.py}---or only for
  615. testing---e.g., those in @code{tests_require}---go into
  616. @code{native-inputs}. The rationale is that (1) they do not need to be
  617. propagated because they are not needed at run time, and (2) in a
  618. cross-compilation context, it's the ``native'' input that we'd want.
  619. Examples are the @code{pytest}, @code{mock}, and @code{nose} test
  620. frameworks. Of course if any of these packages is also required at
  621. run-time, it needs to go to @code{propagated-inputs}.
  622. @item
  623. Anything that does not fall in the previous categories goes to
  624. @code{inputs}, for example programs or C libraries required for building
  625. Python packages containing C extensions.
  626. @item
  627. If a Python package has optional dependencies (@code{extras_require}),
  628. it is up to you to decide whether to add them or not, based on their
  629. usefulness/overhead ratio (@pxref{Submitting Patches, @command{guix
  630. size}}).
  631. @end itemize
  632. @node Perl Modules
  633. @subsection Perl Modules
  634. @cindex perl
  635. Perl programs standing for themselves are named as any other package,
  636. using the lowercase upstream name.
  637. For Perl packages containing a single class, we use the lowercase class name,
  638. replace all occurrences of @code{::} by dashes and prepend the prefix
  639. @code{perl-}.
  640. So the class @code{XML::Parser} becomes @code{perl-xml-parser}.
  641. Modules containing several classes keep their lowercase upstream name and
  642. are also prepended by @code{perl-}. Such modules tend to have the word
  643. @code{perl} somewhere in their name, which gets dropped in favor of the
  644. prefix. For instance, @code{libwww-perl} becomes @code{perl-libwww}.
  645. @node Java Packages
  646. @subsection Java Packages
  647. @cindex java
  648. Java programs standing for themselves are named as any other package,
  649. using the lowercase upstream name.
  650. To avoid confusion and naming clashes with other programming languages,
  651. it is desirable that the name of a package for a Java package is
  652. prefixed with @code{java-}. If a project already contains the word
  653. @code{java}, we drop this; for instance, the package @code{ngsjava} is
  654. packaged under the name @code{java-ngs}.
  655. For Java packages containing a single class or a small class hierarchy,
  656. we use the lowercase class name, replace all occurrences of @code{.} by
  657. dashes and prepend the prefix @code{java-}. So the class
  658. @code{apache.commons.cli} becomes package
  659. @code{java-apache-commons-cli}.
  660. @node Rust Crates
  661. @subsection Rust Crates
  662. @cindex rust
  663. Rust programs standing for themselves are named as any other package, using the
  664. lowercase upstream name.
  665. To prevent namespace collisions we prefix all other Rust packages with the
  666. @code{rust-} prefix. The name should be changed to lowercase as appropriate and
  667. dashes should remain in place.
  668. In the rust ecosystem it is common for multiple incompatible versions of a
  669. package to be used at any given time, so all package definitions should have a
  670. versioned suffix. The versioned suffix is the left-most non-zero digit (and
  671. any leading zeros, of course). This follows the ``caret'' version scheme
  672. intended by Cargo. Examples@: @code{rust-clap-2}, @code{rust-rand-0.6}.
  673. Because of the difficulty in reusing rust packages as pre-compiled inputs for
  674. other packages the Cargo build system (@pxref{Build Systems,
  675. @code{cargo-build-system}}) presents the @code{#:cargo-inputs} and
  676. @code{cargo-development-inputs} keywords as build system arguments. It would be
  677. helpful to think of these as similar to @code{propagated-inputs} and
  678. @code{native-inputs}. Rust @code{dependencies} and @code{build-dependencies}
  679. should go in @code{#:cargo-inputs}, and @code{dev-dependencies} should go in
  680. @code{#:cargo-development-inputs}. If a Rust package links to other libraries
  681. then the standard placement in @code{inputs} and the like should be used.
  682. Care should be taken to ensure the correct version of dependencies are used; to
  683. this end we try to refrain from skipping the tests or using @code{#:skip-build?}
  684. when possible. Of course this is not always possible, as the package may be
  685. developed for a different Operating System, depend on features from the Nightly
  686. Rust compiler, or the test suite may have atrophied since it was released.
  687. @node Fonts
  688. @subsection Fonts
  689. @cindex fonts
  690. For fonts that are in general not installed by a user for typesetting
  691. purposes, or that are distributed as part of a larger software package,
  692. we rely on the general packaging rules for software; for instance, this
  693. applies to the fonts delivered as part of the X.Org system or fonts that
  694. are part of TeX Live.
  695. To make it easier for a user to search for fonts, names for other packages
  696. containing only fonts are constructed as follows, independently of the
  697. upstream package name.
  698. The name of a package containing only one font family starts with
  699. @code{font-}; it is followed by the foundry name and a dash @code{-}
  700. if the foundry is known, and the font family name, in which spaces are
  701. replaced by dashes (and as usual, all upper case letters are transformed
  702. to lower case).
  703. For example, the Gentium font family by SIL is packaged under the name
  704. @code{font-sil-gentium}.
  705. For a package containing several font families, the name of the collection
  706. is used in the place of the font family name.
  707. For instance, the Liberation fonts consist of three families,
  708. Liberation Sans, Liberation Serif and Liberation Mono.
  709. These could be packaged separately under the names
  710. @code{font-liberation-sans} and so on; but as they are distributed together
  711. under a common name, we prefer to package them together as
  712. @code{font-liberation}.
  713. In the case where several formats of the same font family or font collection
  714. are packaged separately, a short form of the format, prepended by a dash,
  715. is added to the package name. We use @code{-ttf} for TrueType fonts,
  716. @code{-otf} for OpenType fonts and @code{-type1} for PostScript Type 1
  717. fonts.
  718. @node Coding Style
  719. @section Coding Style
  720. In general our code follows the GNU Coding Standards (@pxref{Top,,,
  721. standards, GNU Coding Standards}). However, they do not say much about
  722. Scheme, so here are some additional rules.
  723. @menu
  724. * Programming Paradigm:: How to compose your elements.
  725. * Modules:: Where to store your code?
  726. * Data Types and Pattern Matching:: Implementing data structures.
  727. * Formatting Code:: Writing conventions.
  728. @end menu
  729. @node Programming Paradigm
  730. @subsection Programming Paradigm
  731. Scheme code in Guix is written in a purely functional style. One
  732. exception is code that involves input/output, and procedures that
  733. implement low-level concepts, such as the @code{memoize} procedure.
  734. @node Modules
  735. @subsection Modules
  736. Guile modules that are meant to be used on the builder side must live in
  737. the @code{(guix build @dots{})} name space. They must not refer to
  738. other Guix or GNU modules. However, it is OK for a ``host-side'' module
  739. to use a build-side module.
  740. Modules that deal with the broader GNU system should be in the
  741. @code{(gnu @dots{})} name space rather than @code{(guix @dots{})}.
  742. @node Data Types and Pattern Matching
  743. @subsection Data Types and Pattern Matching
  744. The tendency in classical Lisp is to use lists to represent everything,
  745. and then to browse them ``by hand'' using @code{car}, @code{cdr},
  746. @code{cadr}, and co. There are several problems with that style,
  747. notably the fact that it is hard to read, error-prone, and a hindrance
  748. to proper type error reports.
  749. Guix code should define appropriate data types (for instance, using
  750. @code{define-record-type*}) rather than abuse lists. In addition, it
  751. should use pattern matching, via Guile’s @code{(ice-9 match)} module,
  752. especially when matching lists (@pxref{Pattern Matching,,, guile, GNU
  753. Guile Reference Manual}).
  754. @node Formatting Code
  755. @subsection Formatting Code
  756. @cindex formatting code
  757. @cindex coding style
  758. When writing Scheme code, we follow common wisdom among Scheme
  759. programmers. In general, we follow the
  760. @url{https://mumble.net/~campbell/scheme/style.txt, Riastradh's Lisp
  761. Style Rules}. This document happens to describe the conventions mostly
  762. used in Guile’s code too. It is very thoughtful and well written, so
  763. please do read it.
  764. Some special forms introduced in Guix, such as the @code{substitute*}
  765. macro, have special indentation rules. These are defined in the
  766. @file{.dir-locals.el} file, which Emacs automatically uses. Also note
  767. that Emacs-Guix provides @code{guix-devel-mode} mode that indents and
  768. highlights Guix code properly (@pxref{Development,,, emacs-guix, The
  769. Emacs-Guix Reference Manual}).
  770. @cindex indentation, of code
  771. @cindex formatting, of code
  772. If you do not use Emacs, please make sure to let your editor knows these
  773. rules. To automatically indent a package definition, you can also run:
  774. @example
  775. ./etc/indent-code.el gnu/packages/@var{file}.scm @var{package}
  776. @end example
  777. @noindent
  778. This automatically indents the definition of @var{package} in
  779. @file{gnu/packages/@var{file}.scm} by running Emacs in batch mode. To
  780. indent a whole file, omit the second argument:
  781. @example
  782. ./etc/indent-code.el gnu/services/@var{file}.scm
  783. @end example
  784. @cindex Vim, Scheme code editing
  785. If you are editing code with Vim, we recommend that you run @code{:set
  786. autoindent} so that your code is automatically indented as you type.
  787. Additionally,
  788. @uref{https://www.vim.org/scripts/script.php?script_id=3998,
  789. @code{paredit.vim}} may help you deal with all these parentheses.
  790. We require all top-level procedures to carry a docstring. This
  791. requirement can be relaxed for simple private procedures in the
  792. @code{(guix build @dots{})} name space, though.
  793. Procedures should not have more than four positional parameters. Use
  794. keyword parameters for procedures that take more than four parameters.
  795. @node Submitting Patches
  796. @section Submitting Patches
  797. Development is done using the Git distributed version control system.
  798. Thus, access to the repository is not strictly necessary. We welcome
  799. contributions in the form of patches as produced by @code{git
  800. format-patch} sent to the @email{guix-patches@@gnu.org} mailing list.
  801. Seasoned Guix developers may also want to look at the section on commit
  802. access (@pxref{Commit Access}).
  803. This mailing list is backed by a Debbugs instance, which allows us to
  804. keep track of submissions (@pxref{Tracking Bugs and Patches}). Each
  805. message sent to that mailing list gets a new tracking number assigned;
  806. people can then follow up on the submission by sending email to
  807. @code{@var{NNN}@@debbugs.gnu.org}, where @var{NNN} is the tracking
  808. number (@pxref{Sending a Patch Series}).
  809. Please write commit logs in the ChangeLog format (@pxref{Change Logs,,,
  810. standards, GNU Coding Standards}); you can check the commit history for
  811. examples.
  812. Before submitting a patch that adds or modifies a package definition,
  813. please run through this check list:
  814. @enumerate
  815. @item
  816. If the authors of the packaged software provide a cryptographic
  817. signature for the release tarball, make an effort to verify the
  818. authenticity of the archive. For a detached GPG signature file this
  819. would be done with the @code{gpg --verify} command.
  820. @item
  821. Take some time to provide an adequate synopsis and description for the
  822. package. @xref{Synopses and Descriptions}, for some guidelines.
  823. @item
  824. Run @code{guix lint @var{package}}, where @var{package} is the
  825. name of the new or modified package, and fix any errors it reports
  826. (@pxref{Invoking guix lint}).
  827. @item
  828. Make sure the package builds on your platform, using @code{guix build
  829. @var{package}}.
  830. @item
  831. We recommend you also try building the package on other supported
  832. platforms. As you may not have access to actual hardware platforms, we
  833. recommend using the @code{qemu-binfmt-service-type} to emulate them. In
  834. order to enable it, add the following service to the list of services in
  835. your @code{operating-system} configuration:
  836. @lisp
  837. (service qemu-binfmt-service-type
  838. (qemu-binfmt-configuration
  839. (platforms (lookup-qemu-platforms "arm" "aarch64"))
  840. @end lisp
  841. Then reconfigure your system.
  842. You can then build packages for different platforms by specifying the
  843. @code{--system} option. For example, to build the "hello" package for
  844. the armhf, aarch64, or mips64 architectures, you would run the following
  845. commands, respectively:
  846. @example
  847. guix build --system=armhf-linux --rounds=2 hello
  848. guix build --system=aarch64-linux --rounds=2 hello
  849. @end example
  850. @item
  851. @cindex bundling
  852. Make sure the package does not use bundled copies of software already
  853. available as separate packages.
  854. Sometimes, packages include copies of the source code of their
  855. dependencies as a convenience for users. However, as a distribution, we
  856. want to make sure that such packages end up using the copy we already
  857. have in the distribution, if there is one. This improves resource usage
  858. (the dependency is built and stored only once), and allows the
  859. distribution to make transverse changes such as applying security
  860. updates for a given software package in a single place and have them
  861. affect the whole system---something that bundled copies prevent.
  862. @item
  863. Take a look at the profile reported by @command{guix size}
  864. (@pxref{Invoking guix size}). This will allow you to notice references
  865. to other packages unwillingly retained. It may also help determine
  866. whether to split the package (@pxref{Packages with Multiple Outputs}),
  867. and which optional dependencies should be used. In particular, avoid adding
  868. @code{texlive} as a dependency: because of its extreme size, use
  869. the @code{texlive-tiny} package or @code{texlive-union} procedure instead.
  870. @item
  871. For important changes, check that dependent package (if applicable) are
  872. not affected by the change; @code{guix refresh --list-dependent
  873. @var{package}} will help you do that (@pxref{Invoking guix refresh}).
  874. @c See <https://lists.gnu.org/archive/html/guix-devel/2016-10/msg00933.html>.
  875. @cindex branching strategy
  876. @cindex rebuild scheduling strategy
  877. Depending on the number of dependent packages and thus the amount of
  878. rebuilding induced, commits go to different branches, along these lines:
  879. @table @asis
  880. @item 300 dependent packages or less
  881. @code{master} branch (non-disruptive changes).
  882. @item between 300 and 1,800 dependent packages
  883. @code{staging} branch (non-disruptive changes). This branch is intended
  884. to be merged in @code{master} every 6 weeks or so. Topical changes
  885. (e.g., an update of the GNOME stack) can instead go to a specific branch
  886. (say, @code{gnome-updates}).
  887. @item more than 1,800 dependent packages
  888. @code{core-updates} branch (may include major and potentially disruptive
  889. changes). This branch is intended to be merged in @code{master} every
  890. 6 months or so.
  891. @end table
  892. All these branches are @uref{@value{SUBSTITUTE-URL},
  893. tracked by our build farm} and merged into @code{master} once
  894. everything has been successfully built. This allows us to fix issues
  895. before they hit users, and to reduce the window during which pre-built
  896. binaries are not available.
  897. When we decide to start building the @code{staging} or
  898. @code{core-updates} branches, they will be forked and renamed with the
  899. suffix @code{-frozen}, at which time only bug fixes may be pushed to the
  900. frozen branches. The @code{core-updates} and @code{staging} branches
  901. will remain open to accept patches for the next cycle. Please ask on
  902. the mailing list or IRC if unsure where to place a patch.
  903. @c TODO: It would be good with badges on the website that tracks these
  904. @c branches. Or maybe even a status page.
  905. @item
  906. @cindex determinism, of build processes
  907. @cindex reproducible builds, checking
  908. Check whether the package's build process is deterministic. This
  909. typically means checking whether an independent build of the package
  910. yields the exact same result that you obtained, bit for bit.
  911. A simple way to do that is by building the same package several times in
  912. a row on your machine (@pxref{Invoking guix build}):
  913. @example
  914. guix build --rounds=2 my-package
  915. @end example
  916. This is enough to catch a class of common non-determinism issues, such
  917. as timestamps or randomly-generated output in the build result.
  918. Another option is to use @command{guix challenge} (@pxref{Invoking guix
  919. challenge}). You may run it once the package has been committed and
  920. built by @code{@value{SUBSTITUTE-SERVER}} to check whether it obtains the same
  921. result as you did. Better yet: Find another machine that can build it
  922. and run @command{guix publish}. Since the remote build machine is
  923. likely different from yours, this can catch non-determinism issues
  924. related to the hardware---e.g., use of different instruction set
  925. extensions---or to the operating system kernel---e.g., reliance on
  926. @code{uname} or @file{/proc} files.
  927. @item
  928. When writing documentation, please use gender-neutral wording when
  929. referring to people, such as
  930. @uref{https://en.wikipedia.org/wiki/Singular_they, singular
  931. ``they''@comma{} ``their''@comma{} ``them''}, and so forth.
  932. @item
  933. Verify that your patch contains only one set of related changes.
  934. Bundling unrelated changes together makes reviewing harder and slower.
  935. Examples of unrelated changes include the addition of several packages,
  936. or a package update along with fixes to that package.
  937. @item
  938. Please follow our code formatting rules, possibly running the
  939. @command{etc/indent-code.el} script to do that automatically for you
  940. (@pxref{Formatting Code}).
  941. @item
  942. When possible, use mirrors in the source URL (@pxref{Invoking guix download}).
  943. Use reliable URLs, not generated ones. For instance, GitHub archives are not
  944. necessarily identical from one generation to the next, so in this case it's
  945. often better to clone the repository. Don't use the @command{name} field in
  946. the URL: it is not very useful and if the name changes, the URL will probably
  947. be wrong.
  948. @item
  949. Check if Guix builds (@pxref{Building from Git}) and address the
  950. warnings, especially those about use of undefined symbols.
  951. @item
  952. Make sure your changes do not break Guix and simulate a @code{guix pull} with:
  953. @example
  954. guix pull --url=/path/to/your/checkout --profile=/tmp/guix.master
  955. @end example
  956. @end enumerate
  957. When posting a patch to the mailing list, use @samp{[PATCH] @dots{}} as
  958. a subject, if your patch is to be applied on a branch other than
  959. @code{master}, say @code{core-updates}, specify it in the subject like
  960. @samp{[PATCH core-updates] @dots{}}. You may use your email client or
  961. the @command{git send-email} command (@pxref{Sending a Patch Series}).
  962. We prefer to get patches in plain text messages, either inline or as
  963. MIME attachments. You are advised to pay attention if your email client
  964. changes anything like line breaks or indentation which could potentially
  965. break the patches.
  966. When a bug is resolved, please close the thread by sending an email to
  967. @email{@var{NNN}-done@@debbugs.gnu.org}.
  968. @unnumberedsubsec Sending a Patch Series
  969. @anchor{Sending a Patch Series}
  970. @cindex patch series
  971. @cindex @code{git send-email}
  972. @cindex @code{git-send-email}
  973. When sending a patch series (e.g., using @code{git send-email}), please
  974. first send one message to @email{guix-patches@@gnu.org}, and then send
  975. subsequent patches to @email{@var{NNN}@@debbugs.gnu.org} to make sure
  976. they are kept together. See
  977. @uref{https://debbugs.gnu.org/Advanced.html, the Debbugs documentation}
  978. for more information. You can install @command{git send-email} with
  979. @command{guix install git:send-email}.
  980. @c Debbugs bug: https://debbugs.gnu.org/db/15/15361.html
  981. @node Tracking Bugs and Patches
  982. @section Tracking Bugs and Patches
  983. @cindex bug reports, tracking
  984. @cindex patch submissions, tracking
  985. @cindex issue tracking
  986. @cindex Debbugs, issue tracking system
  987. Bug reports and patch submissions are currently tracked using the
  988. Debbugs instance at @uref{https://bugs.gnu.org}. Bug reports are filed
  989. against the @code{guix} ``package'' (in Debbugs parlance), by sending
  990. email to @email{bug-guix@@gnu.org}, while patch submissions are filed
  991. against the @code{guix-patches} package by sending email to
  992. @email{guix-patches@@gnu.org} (@pxref{Submitting Patches}).
  993. A web interface (actually @emph{two} web interfaces!) are available to
  994. browse issues:
  995. @itemize
  996. @item
  997. @url{https://issues.guix.gnu.org} provides a pleasant
  998. interface@footnote{The web interface at
  999. @url{https://issues.guix.gnu.org} is powered by Mumi, a nice piece of
  1000. software written in Guile, and you can help! See
  1001. @url{https://git.elephly.net/gitweb.cgi?p=software/mumi.git}.} to browse
  1002. bug reports and patches, and to participate in discussions;
  1003. @item
  1004. @url{https://bugs.gnu.org/guix} lists bug reports;
  1005. @item
  1006. @url{https://bugs.gnu.org/guix-patches} lists patch submissions.
  1007. @end itemize
  1008. To view discussions related to issue number @var{n}, go to
  1009. @indicateurl{https://issues.guix.gnu.org/@var{n}} or
  1010. @indicateurl{https://bugs.gnu.org/@var{n}}.
  1011. If you use Emacs, you may find it more convenient to interact with
  1012. issues using @file{debbugs.el}, which you can install with:
  1013. @example
  1014. guix install emacs-debbugs
  1015. @end example
  1016. For example, to list all open issues on @code{guix-patches}, hit:
  1017. @example
  1018. @kbd{C-u} @kbd{M-x} debbugs-gnu @kbd{RET} @kbd{RET} guix-patches @kbd{RET} n y
  1019. @end example
  1020. @xref{Top,,, debbugs-ug, Debbugs User Guide}, for more information on
  1021. this nifty tool!
  1022. @node Commit Access
  1023. @section Commit Access
  1024. @cindex commit access, for developers
  1025. For frequent contributors, having write access to the repository is
  1026. convenient. When you deem it necessary, consider applying for commit
  1027. access by following these steps:
  1028. @enumerate
  1029. @item
  1030. Find three committers who would vouch for you. You can view the list of
  1031. committers at
  1032. @url{https://savannah.gnu.org/project/memberlist.php?group=guix}. Each
  1033. of them should email a statement to @email{guix-maintainers@@gnu.org} (a
  1034. private alias for the collective of maintainers), signed with their
  1035. OpenPGP key.
  1036. Committers are expected to have had some interactions with you as a
  1037. contributor and to be able to judge whether you are sufficiently
  1038. familiar with the project's practices. It is @emph{not} a judgment on
  1039. the value of your work, so a refusal should rather be interpreted as
  1040. ``let's try again later''.
  1041. @item
  1042. Send @email{guix-maintainers@@gnu.org} a message stating your intent,
  1043. listing the three committers who support your application, signed with
  1044. the OpenPGP key you will use to sign commits, and giving its fingerprint
  1045. (see below). See @uref{https://emailselfdefense.fsf.org/en/}, for an
  1046. introduction to public-key cryptography with GnuPG.
  1047. @c See <https://sha-mbles.github.io/>.
  1048. Set up GnuPG such that it never uses the SHA1 hash algorithm for digital
  1049. signatures, which is known to be unsafe since 2019, for instance by
  1050. adding the following line to @file{~/.gnupg/gpg.conf} (@pxref{GPG
  1051. Esoteric Options,,, gnupg, The GNU Privacy Guard Manual}):
  1052. @example
  1053. digest-algo sha512
  1054. @end example
  1055. @item
  1056. Maintainers ultimately decide whether to grant you commit access,
  1057. usually following your referrals' recommendation.
  1058. @item
  1059. @cindex OpenPGP, signed commits
  1060. If and once you've been given access, please send a message to
  1061. @email{guix-devel@@gnu.org} to say so, again signed with the OpenPGP key
  1062. you will use to sign commits (do that before pushing your first commit).
  1063. That way, everyone can notice and ensure you control that OpenPGP key.
  1064. @quotation Important
  1065. Before you can push for the first time, maintainers must:
  1066. @enumerate
  1067. @item
  1068. add your OpenPGP key to the @code{keyring} branch;
  1069. @item
  1070. add your OpenPGP fingerprint to the @file{.guix-authorizations} file of
  1071. the branch(es) you will commit to.
  1072. @end enumerate
  1073. @end quotation
  1074. @item
  1075. Make sure to read the rest of this section and... profit!
  1076. @end enumerate
  1077. @quotation Note
  1078. Maintainers are happy to give commit access to people who have been
  1079. contributing for some time and have a track record---don't be shy and
  1080. don't underestimate your work!
  1081. However, note that the project is working towards a more automated patch
  1082. review and merging system, which, as a consequence, may lead us to have
  1083. fewer people with commit access to the main repository. Stay tuned!
  1084. @end quotation
  1085. If you get commit access, please make sure to follow
  1086. the policy below (discussions of the policy can take place on
  1087. @email{guix-devel@@gnu.org}).
  1088. Non-trivial patches should always be posted to
  1089. @email{guix-patches@@gnu.org} (trivial patches include fixing typos,
  1090. etc.). This mailing list fills the patch-tracking database
  1091. (@pxref{Tracking Bugs and Patches}).
  1092. For patches that just add a new package, and a simple one, it's OK to
  1093. commit, if you're confident (which means you successfully built it in a
  1094. chroot setup, and have done a reasonable copyright and license
  1095. auditing). Likewise for package upgrades, except upgrades that trigger
  1096. a lot of rebuilds (for example, upgrading GnuTLS or GLib). We have a
  1097. mailing list for commit notifications (@email{guix-commits@@gnu.org}),
  1098. so people can notice. Before pushing your changes, make sure to run
  1099. @code{git pull --rebase}.
  1100. All commits that are pushed to the central repository on Savannah must
  1101. be signed with an OpenPGP key, and the public key should be uploaded to
  1102. your user account on Savannah and to public key servers, such as
  1103. @code{keys.openpgp.org}. To configure Git to automatically sign
  1104. commits, run:
  1105. @example
  1106. git config commit.gpgsign true
  1107. git config user.signingkey CABBA6EA1DC0FF33
  1108. @end example
  1109. You can prevent yourself from accidentally pushing unsigned commits to
  1110. Savannah by using the pre-push Git hook called located at
  1111. @file{etc/git/pre-push}:
  1112. @example
  1113. cp etc/git/pre-push .git/hooks/pre-push
  1114. @end example
  1115. When pushing a commit on behalf of somebody else, please add a
  1116. @code{Signed-off-by} line at the end of the commit log message---e.g.,
  1117. with @command{git am --signoff}. This improves tracking of who did
  1118. what.
  1119. When adding channel news entries (@pxref{Channels, Writing Channel
  1120. News}), make sure they are well-formed by running the following command
  1121. right before pushing:
  1122. @example
  1123. make check-channel-news
  1124. @end example
  1125. For anything else, please post to @email{guix-patches@@gnu.org} and
  1126. leave time for a review, without committing anything (@pxref{Submitting
  1127. Patches}). If you didn’t receive any reply after two weeks, and if
  1128. you're confident, it's OK to commit.
  1129. That last part is subject to being adjusted, allowing individuals to commit
  1130. directly on non-controversial changes on parts they’re familiar with.
  1131. In order to reduce the possibility of mistakes, committers will have
  1132. their Savannah account removed from the Guix Savannah project and their
  1133. key removed from @file{.guix-authorizations} after 12 months of
  1134. inactivity; they can ask to regain commit access by emailing the
  1135. maintainers, without going through the vouching process.
  1136. One last thing: the project keeps moving forward because committers not
  1137. only push their own awesome changes, but also offer some of their time
  1138. @emph{reviewing} and pushing other people's changes. As a committer,
  1139. you're welcome to use your expertise and commit rights to help other
  1140. contributors, too!
  1141. @node Updating the Guix Package
  1142. @section Updating the Guix Package
  1143. @cindex update-guix-package, updating the guix package
  1144. It is sometimes desirable to update the @code{guix} package itself (the
  1145. package defined in @code{(gnu packages package-management)}), for
  1146. example to make new daemon features available for use by the
  1147. @code{guix-service-type} service type. In order to simplify this task,
  1148. the following command can be used:
  1149. @example
  1150. make update-guix-package
  1151. @end example
  1152. The @code{update-guix-package} make target will use the last known
  1153. @emph{commit} corresponding to @code{HEAD} in your Guix checkout,
  1154. compute the hash of the Guix sources corresponding to that commit and
  1155. update the @code{commit}, @code{revision} and hash of the @code{guix}
  1156. package definition.
  1157. To validate that the updated @code{guix} package hashes are correct and
  1158. that it can be built successfully, the following command can be run from
  1159. the directory of your Guix checkout:
  1160. @example
  1161. ./pre-inst-env guix build guix
  1162. @end example
  1163. To guard against accidentally updating the @code{guix} package to a
  1164. commit that others can't refer to, a check is made that the commit used
  1165. has already been pushed to the Savannah-hosted Guix git repository.
  1166. This check can be disabled, @emph{at your own peril}, by setting the
  1167. @code{GUIX_ALLOW_ME_TO_USE_PRIVATE_COMMIT} environment variable. When
  1168. this variable is set, the updated package source is also added to the
  1169. store. This is used as part of the release process of Guix.