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