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