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