contributing.texi 57 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424
  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 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. 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 package definitions should have a
  663. versioned suffix. The versioned suffix is the left-most non-zero digit (and
  664. any leading zeros, of course). This follows the ``caret'' version scheme
  665. intended by Cargo. Examples@: @code{rust-clap-2}, @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. @end lisp
  834. Then reconfigure your system.
  835. You can then build packages for different platforms by specifying the
  836. @code{--system} option. For example, to build the "hello" package for
  837. the armhf, aarch64, or mips64 architectures, you would run the following
  838. commands, respectively:
  839. @example
  840. guix build --system=armhf-linux --rounds=2 hello
  841. guix build --system=aarch64-linux --rounds=2 hello
  842. @end example
  843. @item
  844. @cindex bundling
  845. Make sure the package does not use bundled copies of software already
  846. available as separate packages.
  847. Sometimes, packages include copies of the source code of their
  848. dependencies as a convenience for users. However, as a distribution, we
  849. want to make sure that such packages end up using the copy we already
  850. have in the distribution, if there is one. This improves resource usage
  851. (the dependency is built and stored only once), and allows the
  852. distribution to make transverse changes such as applying security
  853. updates for a given software package in a single place and have them
  854. affect the whole system---something that bundled copies prevent.
  855. @item
  856. Take a look at the profile reported by @command{guix size}
  857. (@pxref{Invoking guix size}). This will allow you to notice references
  858. to other packages unwillingly retained. It may also help determine
  859. whether to split the package (@pxref{Packages with Multiple Outputs}),
  860. and which optional dependencies should be used. In particular, avoid adding
  861. @code{texlive} as a dependency: because of its extreme size, use
  862. the @code{texlive-tiny} package or @code{texlive-union} procedure instead.
  863. @item
  864. For important changes, check that dependent package (if applicable) are
  865. not affected by the change; @code{guix refresh --list-dependent
  866. @var{package}} will help you do that (@pxref{Invoking guix refresh}).
  867. @c See <https://lists.gnu.org/archive/html/guix-devel/2016-10/msg00933.html>.
  868. @cindex branching strategy
  869. @cindex rebuild scheduling strategy
  870. Depending on the number of dependent packages and thus the amount of
  871. rebuilding induced, commits go to different branches, along these lines:
  872. @table @asis
  873. @item 300 dependent packages or less
  874. @code{master} branch (non-disruptive changes).
  875. @item between 300 and 1,800 dependent packages
  876. @code{staging} branch (non-disruptive changes). This branch is intended
  877. to be merged in @code{master} every 6 weeks or so. Topical changes
  878. (e.g., an update of the GNOME stack) can instead go to a specific branch
  879. (say, @code{gnome-updates}).
  880. @item more than 1,800 dependent packages
  881. @code{core-updates} branch (may include major and potentially disruptive
  882. changes). This branch is intended to be merged in @code{master} every
  883. 6 months or so.
  884. @end table
  885. All these branches are @uref{@value{SUBSTITUTE-URL},
  886. tracked by our build farm} and merged into @code{master} once
  887. everything has been successfully built. This allows us to fix issues
  888. before they hit users, and to reduce the window during which pre-built
  889. binaries are not available.
  890. When we decide to start building the @code{staging} or
  891. @code{core-updates} branches, they will be forked and renamed with the
  892. suffix @code{-frozen}, at which time only bug fixes may be pushed to the
  893. frozen branches. The @code{core-updates} and @code{staging} branches
  894. will remain open to accept patches for the next cycle. Please ask on
  895. the mailing list or IRC if unsure where to place a patch.
  896. @c TODO: It would be good with badges on the website that tracks these
  897. @c branches. Or maybe even a status page.
  898. @item
  899. @cindex determinism, of build processes
  900. @cindex reproducible builds, checking
  901. Check whether the package's build process is deterministic. This
  902. typically means checking whether an independent build of the package
  903. yields the exact same result that you obtained, bit for bit.
  904. A simple way to do that is by building the same package several times in
  905. a row on your machine (@pxref{Invoking guix build}):
  906. @example
  907. guix build --rounds=2 my-package
  908. @end example
  909. This is enough to catch a class of common non-determinism issues, such
  910. as timestamps or randomly-generated output in the build result.
  911. Another option is to use @command{guix challenge} (@pxref{Invoking guix
  912. challenge}). You may run it once the package has been committed and
  913. built by @code{@value{SUBSTITUTE-SERVER}} to check whether it obtains the same
  914. result as you did. Better yet: Find another machine that can build it
  915. and run @command{guix publish}. Since the remote build machine is
  916. likely different from yours, this can catch non-determinism issues
  917. related to the hardware---e.g., use of different instruction set
  918. extensions---or to the operating system kernel---e.g., reliance on
  919. @code{uname} or @file{/proc} files.
  920. @item
  921. When writing documentation, please use gender-neutral wording when
  922. referring to people, such as
  923. @uref{https://en.wikipedia.org/wiki/Singular_they, singular
  924. ``they''@comma{} ``their''@comma{} ``them''}, and so forth.
  925. @item
  926. Verify that your patch contains only one set of related changes.
  927. Bundling unrelated changes together makes reviewing harder and slower.
  928. Examples of unrelated changes include the addition of several packages,
  929. or a package update along with fixes to that package.
  930. @item
  931. Please follow our code formatting rules, possibly running the
  932. @command{etc/indent-code.el} script to do that automatically for you
  933. (@pxref{Formatting Code}).
  934. @item
  935. When possible, use mirrors in the source URL (@pxref{Invoking guix download}).
  936. Use reliable URLs, not generated ones. For instance, GitHub archives are not
  937. necessarily identical from one generation to the next, so in this case it's
  938. often better to clone the repository. Don't use the @command{name} field in
  939. the URL: it is not very useful and if the name changes, the URL will probably
  940. be wrong.
  941. @item
  942. Check if Guix builds (@pxref{Building from Git}) and address the
  943. warnings, especially those about use of undefined symbols.
  944. @item
  945. Make sure your changes do not break Guix and simulate a @code{guix pull} with:
  946. @example
  947. guix pull --url=/path/to/your/checkout --profile=/tmp/guix.master
  948. @end example
  949. @end enumerate
  950. When posting a patch to the mailing list, use @samp{[PATCH] @dots{}} as
  951. a subject, if your patch is to be applied on a branch other than
  952. @code{master}, say @code{core-updates}, specify it in the subject like
  953. @samp{[PATCH core-updates] @dots{}}. You may use your email client or
  954. the @command{git send-email} command (@pxref{Sending a Patch Series}).
  955. We prefer to get patches in plain text messages, either inline or as
  956. MIME attachments. You are advised to pay attention if your email client
  957. changes anything like line breaks or indentation which could potentially
  958. break the patches.
  959. When a bug is resolved, please close the thread by sending an email to
  960. @email{@var{NNN}-done@@debbugs.gnu.org}.
  961. @unnumberedsubsec Sending a Patch Series
  962. @anchor{Sending a Patch Series}
  963. @cindex patch series
  964. @cindex @code{git send-email}
  965. @cindex @code{git-send-email}
  966. When sending a patch series (e.g., using @code{git send-email}), please
  967. first send one message to @email{guix-patches@@gnu.org}, and then send
  968. subsequent patches to @email{@var{NNN}@@debbugs.gnu.org} to make sure
  969. they are kept together. See
  970. @uref{https://debbugs.gnu.org/Advanced.html, the Debbugs documentation}
  971. for more information. You can install @command{git send-email} with
  972. @command{guix install git:send-email}.
  973. @c Debbugs bug: https://debbugs.gnu.org/db/15/15361.html
  974. @node Tracking Bugs and Patches
  975. @section Tracking Bugs and Patches
  976. @cindex bug reports, tracking
  977. @cindex patch submissions, tracking
  978. @cindex issue tracking
  979. @cindex Debbugs, issue tracking system
  980. Bug reports and patch submissions are currently tracked using the
  981. Debbugs instance at @uref{https://bugs.gnu.org}. Bug reports are filed
  982. against the @code{guix} ``package'' (in Debbugs parlance), by sending
  983. email to @email{bug-guix@@gnu.org}, while patch submissions are filed
  984. against the @code{guix-patches} package by sending email to
  985. @email{guix-patches@@gnu.org} (@pxref{Submitting Patches}).
  986. A web interface (actually @emph{two} web interfaces!) are available to
  987. browse issues:
  988. @itemize
  989. @item
  990. @url{https://issues.guix.gnu.org} provides a pleasant
  991. interface@footnote{The web interface at
  992. @url{https://issues.guix.gnu.org} is powered by Mumi, a nice piece of
  993. software written in Guile, and you can help! See
  994. @url{https://git.elephly.net/gitweb.cgi?p=software/mumi.git}.} to browse
  995. bug reports and patches, and to participate in discussions;
  996. @item
  997. @url{https://bugs.gnu.org/guix} lists bug reports;
  998. @item
  999. @url{https://bugs.gnu.org/guix-patches} lists patch submissions.
  1000. @end itemize
  1001. To view discussions related to issue number @var{n}, go to
  1002. @indicateurl{https://issues.guix.gnu.org/@var{n}} or
  1003. @indicateurl{https://bugs.gnu.org/@var{n}}.
  1004. If you use Emacs, you may find it more convenient to interact with
  1005. issues using @file{debbugs.el}, which you can install with:
  1006. @example
  1007. guix install emacs-debbugs
  1008. @end example
  1009. For example, to list all open issues on @code{guix-patches}, hit:
  1010. @example
  1011. @kbd{C-u} @kbd{M-x} debbugs-gnu @kbd{RET} @kbd{RET} guix-patches @kbd{RET} n y
  1012. @end example
  1013. @xref{Top,,, debbugs-ug, Debbugs User Guide}, for more information on
  1014. this nifty tool!
  1015. @node Commit Access
  1016. @section Commit Access
  1017. @cindex commit access, for developers
  1018. For frequent contributors, having write access to the repository is
  1019. convenient. When you deem it necessary, consider applying for commit
  1020. access by following these steps:
  1021. @enumerate
  1022. @item
  1023. Find three committers who would vouch for you. You can view the list of
  1024. committers at
  1025. @url{https://savannah.gnu.org/project/memberlist.php?group=guix}. Each
  1026. of them should email a statement to @email{guix-maintainers@@gnu.org} (a
  1027. private alias for the collective of maintainers), signed with their
  1028. OpenPGP key.
  1029. Committers are expected to have had some interactions with you as a
  1030. contributor and to be able to judge whether you are sufficiently
  1031. familiar with the project's practices. It is @emph{not} a judgment on
  1032. the value of your work, so a refusal should rather be interpreted as
  1033. ``let's try again later''.
  1034. @item
  1035. Send @email{guix-maintainers@@gnu.org} a message stating your intent,
  1036. listing the three committers who support your application, signed with
  1037. the OpenPGP key you will use to sign commits, and giving its fingerprint
  1038. (see below). See @uref{https://emailselfdefense.fsf.org/en/}, for an
  1039. introduction to public-key cryptography with GnuPG.
  1040. @c See <https://sha-mbles.github.io/>.
  1041. Set up GnuPG such that it never uses the SHA1 hash algorithm for digital
  1042. signatures, which is known to be unsafe since 2019, for instance by
  1043. adding the following line to @file{~/.gnupg/gpg.conf} (@pxref{GPG
  1044. Esoteric Options,,, gnupg, The GNU Privacy Guard Manual}):
  1045. @example
  1046. digest-algo sha512
  1047. @end example
  1048. @item
  1049. Maintainers ultimately decide whether to grant you commit access,
  1050. usually following your referrals' recommendation.
  1051. @item
  1052. @cindex OpenPGP, signed commits
  1053. If and once you've been given access, please send a message to
  1054. @email{guix-devel@@gnu.org} to say so, again signed with the OpenPGP key
  1055. you will use to sign commits (do that before pushing your first commit).
  1056. That way, everyone can notice and ensure you control that OpenPGP key.
  1057. @quotation Important
  1058. Before you can push for the first time, maintainers must:
  1059. @enumerate
  1060. @item
  1061. add your OpenPGP key to the @code{keyring} branch;
  1062. @item
  1063. add your OpenPGP fingerprint to the @file{.guix-authorizations} file of
  1064. the branch(es) you will commit to.
  1065. @end enumerate
  1066. @end quotation
  1067. @item
  1068. Make sure to read the rest of this section and... profit!
  1069. @end enumerate
  1070. @quotation Note
  1071. Maintainers are happy to give commit access to people who have been
  1072. contributing for some time and have a track record---don't be shy and
  1073. don't underestimate your work!
  1074. However, note that the project is working towards a more automated patch
  1075. review and merging system, which, as a consequence, may lead us to have
  1076. fewer people with commit access to the main repository. Stay tuned!
  1077. @end quotation
  1078. If you get commit access, please make sure to follow
  1079. the policy below (discussions of the policy can take place on
  1080. @email{guix-devel@@gnu.org}).
  1081. Non-trivial patches should always be posted to
  1082. @email{guix-patches@@gnu.org} (trivial patches include fixing typos,
  1083. etc.). This mailing list fills the patch-tracking database
  1084. (@pxref{Tracking Bugs and Patches}).
  1085. For patches that just add a new package, and a simple one, it's OK to
  1086. commit, if you're confident (which means you successfully built it in a
  1087. chroot setup, and have done a reasonable copyright and license
  1088. auditing). Likewise for package upgrades, except upgrades that trigger
  1089. a lot of rebuilds (for example, upgrading GnuTLS or GLib). We have a
  1090. mailing list for commit notifications (@email{guix-commits@@gnu.org}),
  1091. so people can notice. Before pushing your changes, make sure to run
  1092. @code{git pull --rebase}.
  1093. All commits that are pushed to the central repository on Savannah must
  1094. be signed with an OpenPGP key, and the public key should be uploaded to
  1095. your user account on Savannah and to public key servers, such as
  1096. @code{keys.openpgp.org}. To configure Git to automatically sign
  1097. commits, run:
  1098. @example
  1099. git config commit.gpgsign true
  1100. git config user.signingkey CABBA6EA1DC0FF33
  1101. @end example
  1102. You can prevent yourself from accidentally pushing unsigned commits to
  1103. Savannah by using the pre-push Git hook called located at
  1104. @file{etc/git/pre-push}:
  1105. @example
  1106. cp etc/git/pre-push .git/hooks/pre-push
  1107. @end example
  1108. When pushing a commit on behalf of somebody else, please add a
  1109. @code{Signed-off-by} line at the end of the commit log message---e.g.,
  1110. with @command{git am --signoff}. This improves tracking of who did
  1111. what.
  1112. When adding channel news entries (@pxref{Channels, Writing Channel
  1113. News}), make sure they are well-formed by running the following command
  1114. right before pushing:
  1115. @example
  1116. make check-channel-news
  1117. @end example
  1118. For anything else, please post to @email{guix-patches@@gnu.org} and
  1119. leave time for a review, without committing anything (@pxref{Submitting
  1120. Patches}). If you didn’t receive any reply after two weeks, and if
  1121. you're confident, it's OK to commit.
  1122. That last part is subject to being adjusted, allowing individuals to commit
  1123. directly on non-controversial changes on parts they’re familiar with.
  1124. In order to reduce the possibility of mistakes, committers will have
  1125. their Savannah account removed from the Guix Savannah project and their
  1126. key removed from @file{.guix-authorizations} after 12 months of
  1127. inactivity; they can ask to regain commit access by emailing the
  1128. maintainers, without going through the vouching process.
  1129. One last thing: the project keeps moving forward because committers not
  1130. only push their own awesome changes, but also offer some of their time
  1131. @emph{reviewing} and pushing other people's changes. As a committer,
  1132. you're welcome to use your expertise and commit rights to help other
  1133. contributors, too!
  1134. @node Updating the Guix Package
  1135. @section Updating the Guix Package
  1136. @cindex update-guix-package, updating the guix package
  1137. It is sometimes desirable to update the @code{guix} package itself (the
  1138. package defined in @code{(gnu packages package-management)}), for
  1139. example to make new daemon features available for use by the
  1140. @code{guix-service-type} service type. In order to simplify this task,
  1141. the following command can be used:
  1142. @example
  1143. make update-guix-package
  1144. @end example
  1145. The @code{update-guix-package} make target will use the last known
  1146. @emph{commit} corresponding to @code{HEAD} in your Guix checkout,
  1147. compute the hash of the Guix sources corresponding to that commit and
  1148. update the @code{commit}, @code{revision} and hash of the @code{guix}
  1149. package definition.
  1150. To validate that the updated @code{guix} package hashes are correct and
  1151. that it can be built successfully, the following command can be run from
  1152. the directory of your Guix checkout:
  1153. @example
  1154. ./pre-inst-env guix build guix
  1155. @end example
  1156. To guard against accidentally updating the @code{guix} package to a
  1157. commit that others can't refer to, a check is made that the commit used
  1158. has already been pushed to the Savannah-hosted Guix git repository.
  1159. This check can be disabled, @emph{at your own peril}, by setting the
  1160. @code{GUIX_ALLOW_ME_TO_USE_PRIVATE_COMMIT} environment variable. When
  1161. this variable is set, the updated package source is also added to the
  1162. store. This is used as part of the release process of Guix.