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