import: json: Accept '#:http-fetch' in 'json-fetch'.
[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
c0087d33 6@code{#guix} on the Libera Chat IRC network. We welcome ideas, bug
8c01b9d0
ML
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.
3c86372e 29* Tracking Bugs and Patches:: Keeping it all organized.
2d315cd4 30* Commit Access:: Pushing to the official repository.
5800d2aa 31* Updating the Guix Package:: Updating the Guix package definition.
1897a6ef 32* Translating Guix:: Make Guix speak your native language.
8c01b9d0
ML
33@end menu
34
35@node Building from Git
36@section Building from Git
37
38If you want to hack Guix itself, it is recommended to use the latest
dbfcadfc
LC
39version from the Git repository:
40
41@example
42git clone https://git.savannah.gnu.org/git/guix.git
43@end example
44
b3011dbb
LC
45@cindex authentication, of a Guix checkout
46How do you ensure that you obtained a genuine copy of the repository?
3e9c6ee1 47To do that, run @command{guix git authenticate}, passing it the commit
63c799c1
LC
48and OpenPGP fingerprint of the @dfn{channel introduction}
49(@pxref{Invoking guix git authenticate}):
b3011dbb 50
63c799c1
LC
51@c The commit and fingerprint below must match those of the channel
52@c introduction in '%default-channels'.
b3011dbb 53@example
3e9c6ee1 54git fetch origin keyring:keyring
63c799c1
LC
55guix git authenticate 9edb3f66fd807b096b48283debdcddccfea34bad \
56 "BBB0 2DDF 2CEA F6A8 0D1D E643 A2A0 6DF2 A33A 54FA"
b3011dbb
LC
57@end example
58
59@noindent
63c799c1
LC
60This command completes with exit code zero on success; it prints an
61error message and exits with a non-zero code otherwise.
62
63As you can see, there is a chicken-and-egg problem: you first need to
64have Guix installed. Typically you would install Guix System
65(@pxref{System Installation}) or Guix on top of another distro
66(@pxref{Binary Installation}); in either case, you would verify the
67OpenPGP signature on the installation medium. This ``bootstraps'' the
68trust chain.
b3011dbb 69
5fb95cc5
LC
70The easiest way to set up a development environment for Guix is, of
71course, by using Guix! The following command starts a new shell where
72all the dependencies and appropriate environment variables are set up to
73hack on Guix:
8c01b9d0 74
5fb95cc5 75@example
80edb7df 76guix shell -D guix --pure
5fb95cc5
LC
77@end example
78
80edb7df 79@xref{Invoking guix shell}, for more information on that command.
0636742b
FP
80
81If you are unable to use Guix when building Guix from a checkout, the
82following are the required packages in addition to those mentioned in the
83installation instructions (@pxref{Requirements}).
84
85@itemize
21656ffa
VS
86@item @url{https://gnu.org/software/autoconf/, GNU Autoconf};
87@item @url{https://gnu.org/software/automake/, GNU Automake};
88@item @url{https://gnu.org/software/gettext/, GNU Gettext};
89@item @url{https://gnu.org/software/texinfo/, GNU Texinfo};
90@item @url{https://www.graphviz.org/, Graphviz};
91@item @url{https://www.gnu.org/software/help2man/, GNU Help2man (optional)}.
0636742b
FP
92@end itemize
93
94On Guix, extra dependencies can be added by instead running @command{guix
80edb7df 95shell}:
5fb95cc5
LC
96
97@example
80edb7df 98guix shell -D guix help2man git strace --pure
5fb95cc5
LC
99@end example
100
8d472e93
LC
101From there you can generate the build system infrastructure
102using Autoconf and Automake:
103
104@example
105./bootstrap
106@end example
107
108If you get an error like this one:
8c01b9d0
ML
109
110@example
111configure.ac:46: error: possibly undefined macro: PKG_CHECK_MODULES
112@end example
113
5fb95cc5 114@noindent
8c01b9d0 115it probably means that Autoconf couldn’t find @file{pkg.m4}, which is
5fb95cc5
LC
116provided by pkg-config. Make sure that @file{pkg.m4} is available. The
117same holds for the @file{guile.m4} set of macros provided by Guile. For
118instance, if you installed Automake in @file{/usr/local}, it wouldn’t
119look for @file{.m4} files in @file{/usr/share}. In that case, you have
120to invoke the following command:
8c01b9d0
ML
121
122@example
123export ACLOCAL_PATH=/usr/share/aclocal
124@end example
125
aabe6d38 126@xref{Macro Search Path,,, automake, The GNU Automake Manual}, for
8c01b9d0
ML
127more information.
128
8d472e93
LC
129Then, run:
130
131@example
132./configure --localstatedir=/var
133@end example
134
135@noindent
136... where @file{/var} is the normal @code{localstatedir} value
137(@pxref{The Store}, for information about this). Note that you will
138probably not run @command{make install} at the end (you don't have to)
139but it's still important to pass the right @code{localstatedir}.
140
141Finally, you can build Guix and, if you feel so inclined, run the tests
142(@pxref{Running the Test Suite}):
143
144@example
145make
146make check
147@end example
148
149@noindent
150If anything fails, take a look at installation instructions
151(@pxref{Installation}) or send a message to the
152@email{guix-devel@@gnu.org, mailing list}.
8c01b9d0 153
33391ee5
LC
154From there on, you can authenticate all the commits included in your
155checkout by running:
156
157@example
158make authenticate
159@end example
160
161The first run takes a couple of minutes, but subsequent runs are faster.
162
ef6596a2
MÁAV
163Or, when your configuration for your local Git repository doesn't match
164the default one, you can provide the reference for the @code{keyring}
165branch through the variable @code{GUIX_GIT_KEYRING}. The following
166example assumes that you have a Git remote called @samp{myremote}
167pointing to the official repository:
168
169@example
170make authenticate GUIX_GIT_KEYRING=myremote/keyring
171@end example
172
33391ee5
LC
173@quotation Note
174You are advised to run @command{make authenticate} after every
175@command{git pull} invocation. This ensures you keep receiving valid
176changes to the repository.
177@end quotation
178
087ad097
GT
179After updating the repository, @command{make} might fail with an error
180similar to the following example:
181
182@example
183error: failed to load 'gnu/packages/dunst.scm':
184ice-9/eval.scm:293:34: In procedure abi-check: #<record-type <origin>>: record ABI mismatch; recompilation needed
185@end example
186
187This means that one of the record types that Guix defines (in this
188example, the @code{origin} record) has changed, and all of guix needs
189to be recompiled to take that change into account. To do so, run
190@command{make clean-go} followed by @command{make}.
8c01b9d0
ML
191
192@node Running Guix Before It Is Installed
193@section Running Guix Before It Is Installed
194
195In order to keep a sane working environment, you will find it useful to
196test the changes made in your local source tree checkout without
197actually installing them. So that you can distinguish between your
198``end-user'' hat and your ``motley'' costume.
199
200To that end, all the command-line tools can be used even if you have not
ad911c83
RL
201run @code{make install}. To do that, you first need to have an
202environment with all the dependencies available (@pxref{Building from
203Git}), and then simply prefix each command with @command{./pre-inst-env}
204(the @file{pre-inst-env} script lives in the top build tree of Guix; it
205is generated by running @command{./bootstrap} followed by
206@command{./configure}). As an example, here is how you would build the
207@code{hello} package as defined in your working tree (this assumes
208@command{guix-daemon} is already running on your system; it's OK if it's
209a different version):
8c01b9d0
ML
210
211@example
8c01b9d0
ML
212$ ./pre-inst-env guix build hello
213@end example
214
215@noindent
0636742b 216Similarly, an example for a Guile session using the Guix modules:
8c01b9d0
ML
217
218@example
219$ ./pre-inst-env guile -c '(use-modules (guix utils)) (pk (%current-system))'
96856613
LC
220
221;;; ("x86_64-linux")
222@end example
223
224@noindent
225@cindex REPL
226@cindex read-eval-print loop
227@dots{} and for a REPL (@pxref{Using Guile Interactively,,, guile, Guile
228Reference Manual}):
229
230@example
231$ ./pre-inst-env guile
232scheme@@(guile-user)> ,use(guix)
233scheme@@(guile-user)> ,use(gnu)
234scheme@@(guile-user)> (define snakes
235 (fold-packages
236 (lambda (package lst)
237 (if (string-prefix? "python"
238 (package-name package))
239 (cons package lst)
240 lst))
241 '()))
242scheme@@(guile-user)> (length snakes)
243$1 = 361
8c01b9d0
ML
244@end example
245
9022861d
LC
246If you are hacking on the daemon and its supporting code or if
247@command{guix-daemon} is not already running on your system, you can
248launch it straight from the build tree@footnote{The @option{-E} flag to
249@command{sudo} guarantees that @code{GUILE_LOAD_PATH} is correctly set
250such that @command{guix-daemon} and the tools it uses can find the Guile
251modules they need.}:
252
253@example
254$ sudo -E ./pre-inst-env guix-daemon --build-users-group=guixbuild
255@end example
256
8c01b9d0
ML
257The @command{pre-inst-env} script sets up all the environment variables
258necessary to support this, including @env{PATH} and @env{GUILE_LOAD_PATH}.
259
ef54b61d 260Note that @command{./pre-inst-env guix pull} does @emph{not} upgrade the
75e24d7b 261local source tree; it simply updates the @file{~/.config/guix/current}
ef54b61d 262symlink (@pxref{Invoking guix pull}). Run @command{git pull} instead if
75e24d7b 263you want to upgrade your local source tree.
ef54b61d 264
2f219318
GT
265Sometimes, especially if you have recently updated your repository,
266running @command{./pre-inst-env} will print a message similar to the
267following example:
268
269@example
270;;; note: source file /home/user/projects/guix/guix/progress.scm
271;;; newer than compiled /home/user/projects/guix/guix/progress.go
272@end example
273
274This is only a note and you can safely ignore it. You can get rid of
275the message by running @command{make -j4}. Until you do, Guile will run
276slightly slower because it will interpret the code instead of using
277prepared Guile object (@file{.go}) files.
278
279You can run @command{make} automatically as you work using
280@command{watchexec} from the @code{watchexec} package. For example,
281to build again each time you update a package file, you can run
282@samp{watchexec -w gnu/packages make -j4}.
8c01b9d0
ML
283
284@node The Perfect Setup
285@section The Perfect Setup
286
287The Perfect Setup to hack on Guix is basically the perfect setup used
288for Guile hacking (@pxref{Using Guile in Emacs,,, guile, Guile Reference
289Manual}). First, you need more than an editor, you need
21656ffa
VS
290@url{https://www.gnu.org/software/emacs, Emacs}, empowered by the
291wonderful @url{https://nongnu.org/geiser/, Geiser}. To set that up, run:
f73ab814
LC
292
293@example
bcdb8e98 294guix package -i emacs guile emacs-geiser emacs-geiser-guile
f73ab814 295@end example
8c01b9d0
ML
296
297Geiser allows for interactive and incremental development from within
298Emacs: code compilation and evaluation from within buffers, access to
299on-line documentation (docstrings), context-sensitive completion,
300@kbd{M-.} to jump to an object definition, a REPL to try out your code,
301and more (@pxref{Introduction,,, geiser, Geiser User Manual}). For
302convenient Guix development, make sure to augment Guile’s load path so
303that it finds source files from your checkout:
304
305@lisp
306;; @r{Assuming the Guix checkout is in ~/src/guix.}
bb38ece4
AK
307(with-eval-after-load 'geiser-guile
308 (add-to-list 'geiser-guile-load-path "~/src/guix"))
8c01b9d0
ML
309@end lisp
310
311To actually edit the code, Emacs already has a neat Scheme mode. But in
312addition to that, you must not miss
c2c73f58 313@url{https://www.emacswiki.org/emacs/ParEdit, Paredit}. It provides
8c01b9d0
ML
314facilities to directly operate on the syntax tree, such as raising an
315s-expression or wrapping it, swallowing or rejecting the following
316s-expression, etc.
317
42cdcdff
RW
318@cindex code snippets
319@cindex templates
320@cindex reducing boilerplate
321We also provide templates for common git commit messages and package
322definitions in the @file{etc/snippets} directory. These templates can
21656ffa 323be used with @url{https://joaotavora.github.io/yasnippet/, YASnippet} to
42cdcdff
RW
324expand short trigger strings to interactive text snippets. You may want
325to add the snippets directory to the @var{yas-snippet-dirs} variable in
326Emacs.
327
328@lisp
329;; @r{Assuming the Guix checkout is in ~/src/guix.}
330(with-eval-after-load 'yasnippet
331 (add-to-list 'yas-snippet-dirs "~/src/guix/etc/snippets"))
332@end lisp
333
334The commit message snippets depend on @url{https://magit.vc/, Magit} to
335display staged files. When editing a commit message type @code{add}
336followed by @kbd{TAB} to insert a commit message template for adding a
337package; type @code{update} followed by @kbd{TAB} to insert a template
9286c295
AI
338for updating a package; type @code{https} followed by @kbd{TAB} to
339insert a template for changing the home page URI of a package to HTTPS.
42cdcdff
RW
340
341The main snippet for @code{scheme-mode} is triggered by typing
342@code{package...} followed by @kbd{TAB}. This snippet also inserts the
343trigger string @code{origin...}, which can be expanded further. The
344@code{origin} snippet in turn may insert other trigger strings ending on
345@code{...}, which also can be expanded further.
346
9a397114
OP
347@cindex insert or update copyright
348@cindex @code{M-x guix-copyright}
349@cindex @code{M-x copyright-update}
4f4fb215 350We additionally provide insertion and automatic update of a copyright in
9a397114
OP
351@file{etc/copyright.el}. You may want to set your full name, mail, and
352load a file.
353
354@lisp
355(setq user-full-name "Alice Doe")
356(setq user-mail-address "alice@@mail.org")
357;; @r{Assuming the Guix checkout is in ~/src/guix.}
358(load-file "~/src/guix/etc/copyright.el")
359@end lisp
360
361To insert a copyright at the current line invoke @code{M-x guix-copyright}.
362
363To update a copyright you need to specify a @code{copyright-names-regexp}.
364
365@lisp
366(setq copyright-names-regexp
367 (format "%s <%s>" user-full-name user-mail-address))
368@end lisp
369
370You can check if your copyright is up to date by evaluating @code{M-x
371copyright-update}. If you want to do it automatically after each buffer
372save then add @code{(add-hook 'after-save-hook 'copyright-update)} in
373Emacs.
8c01b9d0 374
afe7408e
LC
375@node Packaging Guidelines
376@section Packaging Guidelines
377
378@cindex packages, creating
379The GNU distribution is nascent and may well lack some of your favorite
380packages. This section describes how you can help make the distribution
381grow.
382
383Free software packages are usually distributed in the form of
384@dfn{source code tarballs}---typically @file{tar.gz} files that contain
385all the source files. Adding a package to the distribution means
386essentially two things: adding a @dfn{recipe} that describes how to
387build the package, including a list of other packages required to build
388it, and adding @dfn{package metadata} along with that recipe, such as a
389description and licensing information.
390
391In Guix all this information is embodied in @dfn{package definitions}.
392Package definitions provide a high-level view of the package. They are
393written using the syntax of the Scheme programming language; in fact,
394for each package we define a variable bound to the package definition,
395and export that variable from a module (@pxref{Package Modules}).
396However, in-depth Scheme knowledge is @emph{not} a prerequisite for
397creating packages. For more information on package definitions,
398@pxref{Defining Packages}.
399
400Once a package definition is in place, stored in a file in the Guix
401source tree, it can be tested using the @command{guix build} command
402(@pxref{Invoking guix build}). For example, assuming the new package is
403called @code{gnew}, you may run this command from the Guix build tree
404(@pxref{Running Guix Before It Is Installed}):
405
406@example
407./pre-inst-env guix build gnew --keep-failed
408@end example
409
410Using @code{--keep-failed} makes it easier to debug build failures since
411it provides access to the failed build tree. Another useful
412command-line option when debugging is @code{--log-file}, to access the
413build log.
414
415If the package is unknown to the @command{guix} command, it may be that
416the source file contains a syntax error, or lacks a @code{define-public}
417clause to export the package variable. To figure it out, you may load
418the module from Guile to get more information about the actual error:
419
420@example
421./pre-inst-env guile -c '(use-modules (gnu packages gnew))'
422@end example
423
424Once your package builds correctly, please send us a patch
425(@pxref{Submitting Patches}). Well, if you need help, we will be happy to
426help you too. Once the patch is committed in the Guix repository, the
427new package automatically gets built on the supported platforms by
4985a427 428@url{https://@value{SUBSTITUTE-SERVER-1}, our continuous integration system}.
afe7408e
LC
429
430@cindex substituter
431Users can obtain the new package definition simply by running
432@command{guix pull} (@pxref{Invoking guix pull}). When
4985a427 433@code{@value{SUBSTITUTE-SERVER-1}} is done building the package, installing the
afe7408e
LC
434package automatically downloads binaries from there
435(@pxref{Substitutes}). The only place where human intervention is
436needed is to review and apply the patch.
437
438
439@menu
440* Software Freedom:: What may go into the distribution.
441* Package Naming:: What's in a name?
442* Version Numbers:: When the name is not enough.
443* Synopses and Descriptions:: Helping users find the right package.
71e746cc 444* Snippets versus Phases:: Whether to use a snippet, or a build phase.
15fba3b1 445* Emacs Packages:: Your Elisp fix.
afe7408e
LC
446* Python Modules:: A touch of British comedy.
447* Perl Modules:: Little pearls.
448* Java Packages:: Coffee break.
8d1b22b2 449* Rust Crates:: Beware of oxidation.
aefcfdd0 450* Elm Packages:: Trees of browser code
afe7408e
LC
451* Fonts:: Fond of fonts.
452@end menu
453
454@node Software Freedom
455@subsection Software Freedom
456
457@c Adapted from http://www.gnu.org/philosophy/philosophy.html.
458@cindex free software
459The GNU operating system has been developed so that users can have
460freedom in their computing. GNU is @dfn{free software}, meaning that
21656ffa 461users have the @url{https://www.gnu.org/philosophy/free-sw.html,four
afe7408e
LC
462essential freedoms}: to run the program, to study and change the program
463in source code form, to redistribute exact copies, and to distribute
464modified versions. Packages found in the GNU distribution provide only
465software that conveys these four freedoms.
466
467In addition, the GNU distribution follow the
21656ffa 468@url{https://www.gnu.org/distros/free-system-distribution-guidelines.html,free
afe7408e
LC
469software distribution guidelines}. Among other things, these guidelines
470reject non-free firmware, recommendations of non-free software, and
471discuss ways to deal with trademarks and patents.
472
473Some otherwise free upstream package sources contain a small and optional
474subset that violates the above guidelines, for instance because this subset
475is itself non-free code. When that happens, the offending items are removed
476with appropriate patches or code snippets in the @code{origin} form of the
477package (@pxref{Defining Packages}). This way, @code{guix
478build --source} returns the ``freed'' source rather than the unmodified
479upstream source.
480
481
482@node Package Naming
483@subsection Package Naming
484
485@cindex package name
1dfc08f7 486A package actually has two names associated with it.
afe7408e
LC
487First, there is the name of the @emph{Scheme variable}, the one following
488@code{define-public}. By this name, the package can be made known in the
489Scheme code, for instance as input to another package. Second, there is
490the string in the @code{name} field of a package definition. This name
491is used by package management commands such as
492@command{guix package} and @command{guix build}.
493
494Both are usually the same and correspond to the lowercase conversion of
495the project name chosen upstream, with underscores replaced with
496hyphens. For instance, GNUnet is available as @code{gnunet}, and
497SDL_net as @code{sdl-net}.
498
1b1a61f8
TGRBGG
499A noteworthy exception to this rule is when the project name is only a
500single character, or if an older maintained project with the same name
501already exists---regardless of whether it has already been packaged for
502Guix. Use common sense to make such names unambiguous and meaningful.
503For example, Guix's package for the shell called ``s'' upstream is
504@code{s-shell} and @emph{not} @code{s}. Feel free to ask your fellow
505hackers for inspiration.
506
afe7408e
LC
507We do not add @code{lib} prefixes for library packages, unless these are
508already part of the official project name. But @pxref{Python
509Modules} and @ref{Perl Modules} for special rules concerning modules for
510the Python and Perl languages.
511
512Font package names are handled differently, @pxref{Fonts}.
513
514
515@node Version Numbers
516@subsection Version Numbers
517
518@cindex package version
519We usually package only the latest version of a given free software
520project. But sometimes, for instance for incompatible library versions,
521two (or more) versions of the same package are needed. These require
522different Scheme variable names. We use the name as defined
523in @ref{Package Naming}
524for the most recent version; previous versions use the same name, suffixed
525by @code{-} and the smallest prefix of the version number that may
526distinguish the two versions.
527
528The name inside the package definition is the same for all versions of a
529package and does not contain any version number.
530
531For instance, the versions 2.24.20 and 3.9.12 of GTK+ may be packaged as follows:
532
8ba31e8b 533@lisp
afe7408e
LC
534(define-public gtk+
535 (package
536 (name "gtk+")
537 (version "3.9.12")
538 ...))
539(define-public gtk+-2
540 (package
541 (name "gtk+")
542 (version "2.24.20")
543 ...))
8ba31e8b 544@end lisp
afe7408e 545If we also wanted GTK+ 3.8.2, this would be packaged as
8ba31e8b 546@lisp
afe7408e
LC
547(define-public gtk+-3.8
548 (package
549 (name "gtk+")
550 (version "3.8.2")
551 ...))
8ba31e8b 552@end lisp
afe7408e
LC
553
554@c See <https://lists.gnu.org/archive/html/guix-devel/2016-01/msg00425.html>,
555@c for a discussion of what follows.
556@cindex version number, for VCS snapshots
557Occasionally, we package snapshots of upstream's version control system
558(VCS) instead of formal releases. This should remain exceptional,
559because it is up to upstream developers to clarify what the stable
560release is. Yet, it is sometimes necessary. So, what should we put in
561the @code{version} field?
562
563Clearly, we need to make the commit identifier of the VCS snapshot
564visible in the version string, but we also need to make sure that the
565version string is monotonically increasing so that @command{guix package
566--upgrade} can determine which version is newer. Since commit
567identifiers, notably with Git, are not monotonically increasing, we add
568a revision number that we increase each time we upgrade to a newer
569snapshot. The resulting version string looks like this:
570
571@example
5722.0.11-3.cabba9e
573 ^ ^ ^
574 | | `-- upstream commit ID
575 | |
576 | `--- Guix package revision
577 |
578latest upstream version
579@end example
580
581It is a good idea to strip commit identifiers in the @code{version}
582field to, say, 7 digits. It avoids an aesthetic annoyance (assuming
583aesthetics have a role to play here) as well as problems related to OS
584limits such as the maximum shebang length (127 bytes for the Linux
b8baebae
XC
585kernel). There are helper functions for doing this for packages using
586@code{git-fetch} or @code{hg-fetch} (see below). It is best to use the
587full commit identifiers in @code{origin}s, though, to avoid ambiguities.
588A typical package definition may look like this:
589
afe7408e 590
8ba31e8b 591@lisp
afe7408e
LC
592(define my-package
593 (let ((commit "c3f29bc928d5900971f65965feaae59e1272a3f7")
594 (revision "1")) ;Guix package revision
595 (package
596 (version (git-version "0.9" revision commit))
597 (source (origin
598 (method git-fetch)
599 (uri (git-reference
600 (url "git://example.org/my-package.git")
601 (commit commit)))
602 (sha256 (base32 "1mbikn@dots{}"))
603 (file-name (git-file-name name version))))
604 ;; @dots{}
605 )))
8ba31e8b 606@end lisp
afe7408e 607
b8baebae
XC
608@deffn {Scheme Procedure} git-version @var{VERSION} @var{REVISION} @var{COMMIT}
609Return the version string for packages using @code{git-fetch}.
610
611@lisp
612(git-version "0.2.3" "0" "93818c936ee7e2f1ba1b315578bde363a7d43d05")
613@result{} "0.2.3-0.93818c9"
614@end lisp
615@end deffn
616
617@deffn {Scheme Procedure} hg-version @var{VERSION} @var{REVISION} @var{CHANGESET}
618Return the version string for packages using @code{hg-fetch}. It works
619in the same way as @code{git-version}.
620@end deffn
621
afe7408e
LC
622@node Synopses and Descriptions
623@subsection Synopses and Descriptions
624
625@cindex package description
626@cindex package synopsis
627As we have seen before, each package in GNU@tie{}Guix includes a
628synopsis and a description (@pxref{Defining Packages}). Synopses and
629descriptions are important: They are what @command{guix package
630--search} searches, and a crucial piece of information to help users
631determine whether a given package suits their needs. Consequently,
632packagers should pay attention to what goes into them.
633
634Synopses must start with a capital letter and must not end with a
635period. They must not start with ``a'' or ``the'', which usually does
636not bring anything; for instance, prefer ``File-frobbing tool'' over ``A
637tool that frobs files''. The synopsis should say what the package
638is---e.g., ``Core GNU utilities (file, text, shell)''---or what it is
639used for---e.g., the synopsis for GNU@tie{}grep is ``Print lines
640matching a pattern''.
641
642Keep in mind that the synopsis must be meaningful for a very wide
643audience. For example, ``Manipulate alignments in the SAM format''
644might make sense for a seasoned bioinformatics researcher, but might be
645fairly unhelpful or even misleading to a non-specialized audience. It
646is a good idea to come up with a synopsis that gives an idea of the
647application domain of the package. In this example, this might give
648something like ``Manipulate nucleotide sequence alignments'', which
649hopefully gives the user a better idea of whether this is what they are
650looking for.
651
652Descriptions should take between five and ten lines. Use full
653sentences, and avoid using acronyms without first introducing them.
654Please avoid marketing phrases such as ``world-leading'',
655``industrial-strength'', and ``next-generation'', and avoid superlatives
656like ``the most advanced''---they are not helpful to users looking for a
657package and may even sound suspicious. Instead, try to be factual,
658mentioning use cases and features.
659
660@cindex Texinfo markup, in package descriptions
661Descriptions can include Texinfo markup, which is useful to introduce
662ornaments such as @code{@@code} or @code{@@dfn}, bullet lists, or
663hyperlinks (@pxref{Overview,,, texinfo, GNU Texinfo}). However you
664should be careful when using some characters for example @samp{@@} and
665curly braces which are the basic special characters in Texinfo
666(@pxref{Special Characters,,, texinfo, GNU Texinfo}). User interfaces
667such as @command{guix package --show} take care of rendering it
668appropriately.
669
670Synopses and descriptions are translated by volunteers
2a9784ff
JL
671@uref{https://translate.fedoraproject.org/projects/guix/packages, at
672Weblate} so that as many users as possible can read them in
afe7408e
LC
673their native language. User interfaces search them and display them in
674the language specified by the current locale.
675
676To allow @command{xgettext} to extract them as translatable strings,
677synopses and descriptions @emph{must be literal strings}. This means
678that you cannot use @code{string-append} or @code{format} to construct
679these strings:
680
681@lisp
682(package
683 ;; @dots{}
684 (synopsis "This is translatable")
685 (description (string-append "This is " "*not*" " translatable.")))
686@end lisp
687
688Translation is a lot of work so, as a packager, please pay even more
689attention to your synopses and descriptions as every change may entail
690additional work for translators. In order to help them, it is possible
691to make recommendations or instructions visible to them by inserting
692special comments like this (@pxref{xgettext Invocation,,, gettext, GNU
693Gettext}):
694
93c25181 695@lisp
afe7408e
LC
696;; TRANSLATORS: "X11 resize-and-rotate" should not be translated.
697(description "ARandR is designed to provide a simple visual front end
698for the X11 resize-and-rotate (RandR) extension. @dots{}")
93c25181 699@end lisp
afe7408e 700
71e746cc
MC
701@node Snippets versus Phases
702@subsection Snippets versus Phases
703
704@cindex snippets, when to use
705The boundary between using an origin snippet versus a build phase to
706modify the sources of a package can be elusive. Origin snippets are
707typically used to remove unwanted files such as bundled libraries,
708nonfree sources, or to apply simple substitutions. The source derived
709from an origin should produce a source that can be used to build the
710package on any system that the upstream package supports (i.e., act as
711the corresponding source). In particular, origin snippets must not
712embed store items in the sources; such patching should rather be done
713using build phases. Refer to the @code{origin} record documentation for
714more information (@pxref{origin Reference}).
afe7408e 715
15fba3b1
MC
716@node Emacs Packages
717@subsection Emacs Packages
718
719@cindex emacs, packaging
720@cindex elisp, packaging
721Emacs packages should preferably use the Emacs build system
722(@pxref{emacs-build-system}), for uniformity and the benefits provided
723by its build phases, such as the auto-generation of the autoloads file
eea7cc31 724and the byte compilation of the sources. Because there is no
15fba3b1
MC
725standardized way to run a test suite for Emacs packages, tests are
726disabled by default. When a test suite is available, it should be
eea7cc31 727enabled by setting the @code{#:tests?} argument to @code{#true}. By
15fba3b1
MC
728default, the command to run the test is @command{make check}, but any
729command can be specified via the @code{#:test-command} argument. The
730@code{#:test-command} argument expects a list containing a command and
eea7cc31 731its arguments, to be invoked during the @code{check} phase.
15fba3b1
MC
732
733The Elisp dependencies of Emacs packages are typically provided as
734@code{propagated-inputs} when required at run time. As for other
735packages, build or test dependencies should be specified as
736@code{native-inputs}.
737
738Emacs packages sometimes depend on resources directories that should be
739installed along the Elisp files. The @code{#:include} argument can be
740used for that purpose, by specifying a list of regexps to match. The
741best practice when using the @code{#:include} argument is to extend
742rather than override its default value (accessible via the
743@code{%default-include} variable). As an example, a yasnippet extension
744package typically include a @file{snippets} directory, which could be
745copied to the installation directory using:
746
747@lisp
2c469f04 748#:include (cons "^snippets/" %default-include)
15fba3b1
MC
749@end lisp
750
751When encountering problems, it is wise to check for the presence of the
752@code{Package-Requires} extension header in the package main source
753file, and whether any dependencies and their versions listed therein are
754satisfied.
755
afe7408e
LC
756@node Python Modules
757@subsection Python Modules
758
759@cindex python
760We currently package Python 2 and Python 3, under the Scheme variable names
761@code{python-2} and @code{python} as explained in @ref{Version Numbers}.
762To avoid confusion and naming clashes with other programming languages, it
763seems desirable that the name of a package for a Python module contains
764the word @code{python}.
765
39356057
LF
766Some modules are compatible with only one version of Python, others with
767both. If the package Foo is compiled with Python 3, we name it
768@code{python-foo}. If it is compiled with Python 2, we name it
769@code{python2-foo}. Packages should be added when they are necessary;
770we don't add Python 2 variants of the package unless we are going to use
771them.
afe7408e
LC
772
773If a project already contains the word @code{python}, we drop this;
774for instance, the module python-dateutil is packaged under the names
775@code{python-dateutil} and @code{python2-dateutil}. If the project name
776starts with @code{py} (e.g.@: @code{pytz}), we keep it and prefix it as
777described above.
778
779@subsubsection Specifying Dependencies
780@cindex inputs, for Python packages
781
782Dependency information for Python packages is usually available in the
783package source tree, with varying degrees of accuracy: in the
784@file{setup.py} file, in @file{requirements.txt}, or in @file{tox.ini}.
785
786Your mission, when writing a recipe for a Python package, is to map
787these dependencies to the appropriate type of ``input'' (@pxref{package
788Reference, inputs}). Although the @code{pypi} importer normally does a
789good job (@pxref{Invoking guix import}), you may want to check the
790following check list to determine which dependency goes where.
791
792@itemize
793
794@item
795We currently package Python 2 with @code{setuptools} and @code{pip}
796installed like Python 3.4 has per default. Thus you don't need to
797specify either of these as an input. @command{guix lint} will warn you
798if you do.
799
800@item
801Python dependencies required at run time go into
802@code{propagated-inputs}. They are typically defined with the
803@code{install_requires} keyword in @file{setup.py}, or in the
804@file{requirements.txt} file.
805
806@item
807Python packages required only at build time---e.g., those listed with
808the @code{setup_requires} keyword in @file{setup.py}---or only for
809testing---e.g., those in @code{tests_require}---go into
810@code{native-inputs}. The rationale is that (1) they do not need to be
811propagated because they are not needed at run time, and (2) in a
812cross-compilation context, it's the ``native'' input that we'd want.
813
814Examples are the @code{pytest}, @code{mock}, and @code{nose} test
815frameworks. Of course if any of these packages is also required at
816run-time, it needs to go to @code{propagated-inputs}.
817
818@item
819Anything that does not fall in the previous categories goes to
820@code{inputs}, for example programs or C libraries required for building
821Python packages containing C extensions.
822
823@item
824If a Python package has optional dependencies (@code{extras_require}),
825it is up to you to decide whether to add them or not, based on their
826usefulness/overhead ratio (@pxref{Submitting Patches, @command{guix
827size}}).
828
829@end itemize
830
831
832@node Perl Modules
833@subsection Perl Modules
834
835@cindex perl
836Perl programs standing for themselves are named as any other package,
837using the lowercase upstream name.
838For Perl packages containing a single class, we use the lowercase class name,
839replace all occurrences of @code{::} by dashes and prepend the prefix
840@code{perl-}.
841So the class @code{XML::Parser} becomes @code{perl-xml-parser}.
842Modules containing several classes keep their lowercase upstream name and
843are also prepended by @code{perl-}. Such modules tend to have the word
844@code{perl} somewhere in their name, which gets dropped in favor of the
845prefix. For instance, @code{libwww-perl} becomes @code{perl-libwww}.
846
847
848@node Java Packages
849@subsection Java Packages
850
851@cindex java
852Java programs standing for themselves are named as any other package,
853using the lowercase upstream name.
854
855To avoid confusion and naming clashes with other programming languages,
856it is desirable that the name of a package for a Java package is
857prefixed with @code{java-}. If a project already contains the word
858@code{java}, we drop this; for instance, the package @code{ngsjava} is
859packaged under the name @code{java-ngs}.
860
861For Java packages containing a single class or a small class hierarchy,
862we use the lowercase class name, replace all occurrences of @code{.} by
863dashes and prepend the prefix @code{java-}. So the class
864@code{apache.commons.cli} becomes package
865@code{java-apache-commons-cli}.
866
867
8d1b22b2
EF
868@node Rust Crates
869@subsection Rust Crates
870
871@cindex rust
872Rust programs standing for themselves are named as any other package, using the
873lowercase upstream name.
874
875To prevent namespace collisions we prefix all other Rust packages with the
876@code{rust-} prefix. The name should be changed to lowercase as appropriate and
877dashes should remain in place.
878
879In the rust ecosystem it is common for multiple incompatible versions of a
784048c2
HG
880package to be used at any given time, so all package definitions should have a
881versioned suffix. The versioned suffix is the left-most non-zero digit (and
882any leading zeros, of course). This follows the ``caret'' version scheme
883intended by Cargo. Examples@: @code{rust-clap-2}, @code{rust-rand-0.6}.
8d1b22b2
EF
884
885Because of the difficulty in reusing rust packages as pre-compiled inputs for
886other packages the Cargo build system (@pxref{Build Systems,
887@code{cargo-build-system}}) presents the @code{#:cargo-inputs} and
888@code{cargo-development-inputs} keywords as build system arguments. It would be
889helpful to think of these as similar to @code{propagated-inputs} and
890@code{native-inputs}. Rust @code{dependencies} and @code{build-dependencies}
891should go in @code{#:cargo-inputs}, and @code{dev-dependencies} should go in
892@code{#:cargo-development-inputs}. If a Rust package links to other libraries
893then the standard placement in @code{inputs} and the like should be used.
894
895Care should be taken to ensure the correct version of dependencies are used; to
896this end we try to refrain from skipping the tests or using @code{#:skip-build?}
897when possible. Of course this is not always possible, as the package may be
898developed for a different Operating System, depend on features from the Nightly
899Rust compiler, or the test suite may have atrophied since it was released.
900
901
aefcfdd0
PM
902@node Elm Packages
903@subsection Elm Packages
904
905@cindex Elm
906Elm applications can be named like other software: their names need not
907mention Elm.
908
909Packages in the Elm sense (see @code{elm-build-system} under @ref{Build
910Systems}) are required use names of the format
911@var{author}@code{/}@var{project}, where both the @var{author} and the
912@var{project} may contain hyphens internally, and the @var{author} sometimes
913contains uppercase letters.
914
915To form the Guix package name from the upstream name, we follow a convention
916similar to Python packages (@pxref{Python Modules}), adding an @code{elm-}
917prefix unless the name would already begin with @code{elm-}.
918
919In many cases we can reconstruct an Elm package's upstream name heuristically,
920but, since conversion to a Guix-style name involves a loss of information,
921this is not always possible. Care should be taken to add the
922@code{'upstream-name} property when necessary so that tools
923will work correctly. The most notable scenarios
924when explicitly specifying the upstream name is necessary are:
925
926@enumerate
927@item
928When the @var{author} is @code{elm} and the @var{project} contains one or more
929hyphens, as with @code{elm/virtual-dom}; and
930
931@item
932When the @var{author} contains hyphens or uppercase letters, as with
933@code{Elm-Canvas/raster-shapes}---unless the @var{author} is
934@code{elm-explorations}, which is handled as a special case, so packages like
935@code{elm-explorations/markdown} do @emph{not} need to use the
936@code{'upstream-name} property.
937@end enumerate
938
939The module @code{(guix build-system elm)} provides the following utilities for
940working with names and related conventions:
941
942@deffn {Scheme procedure} elm-package-origin @var{elm-name} @var{version} @
943 @var{hash}
944Returns a Git origin using the repository naming and tagging regime required
945for a published Elm package with the upstream name @var{elm-name} at version
946@var{version} with sha256 checksum @var{hash}.
947
948For example:
949@lisp
950(package
951 (name "elm-html")
952 (version "1.0.0")
953 (source
954 (elm-package-origin
955 "elm/html"
956 version
957 (base32 "15k1679ja57vvlpinpv06znmrxy09lbhzfkzdc89i01qa8c4gb4a")))
958 ...)
959@end lisp
960@end deffn
961
962@deffn {Scheme procedure} elm->package-name @var{elm-name}
963Returns the Guix-style package name for an Elm package with upstream name
964@var{elm-name}.
965
966Note that there is more than one possible @var{elm-name} for which
967@code{elm->package-name} will produce a given result.
968@end deffn
969
970@deffn {Scheme procedure} guix-package->elm-name @var{package}
971Given an Elm @var{package}, returns the possibly-inferred upstream name, or
972@code{#f} the upstream name is not specified via the @code{'upstream-name}
973property and can not be inferred by @code{infer-elm-package-name}.
974@end deffn
975
976@deffn {Scheme procedure} infer-elm-package-name @var{guix-name}
977Given the @var{guix-name} of an Elm package, returns the inferred upstream
978name, or @code{#f} if the upstream name can't be inferred. If the result is
979not @code{#f}, supplying it to @code{elm->package-name} would produce
980@var{guix-name}.
981@end deffn
982
afe7408e
LC
983@node Fonts
984@subsection Fonts
985
986@cindex fonts
987For fonts that are in general not installed by a user for typesetting
988purposes, or that are distributed as part of a larger software package,
989we rely on the general packaging rules for software; for instance, this
990applies to the fonts delivered as part of the X.Org system or fonts that
991are part of TeX Live.
992
993To make it easier for a user to search for fonts, names for other packages
994containing only fonts are constructed as follows, independently of the
995upstream package name.
996
997The name of a package containing only one font family starts with
998@code{font-}; it is followed by the foundry name and a dash @code{-}
999if the foundry is known, and the font family name, in which spaces are
1000replaced by dashes (and as usual, all upper case letters are transformed
1001to lower case).
1002For example, the Gentium font family by SIL is packaged under the name
1003@code{font-sil-gentium}.
1004
1005For a package containing several font families, the name of the collection
1006is used in the place of the font family name.
1007For instance, the Liberation fonts consist of three families,
1008Liberation Sans, Liberation Serif and Liberation Mono.
1009These could be packaged separately under the names
1010@code{font-liberation-sans} and so on; but as they are distributed together
1011under a common name, we prefer to package them together as
1012@code{font-liberation}.
1013
1014In the case where several formats of the same font family or font collection
1015are packaged separately, a short form of the format, prepended by a dash,
1016is added to the package name. We use @code{-ttf} for TrueType fonts,
1017@code{-otf} for OpenType fonts and @code{-type1} for PostScript Type 1
1018fonts.
1019
1020
8c01b9d0
ML
1021@node Coding Style
1022@section Coding Style
1023
1024In general our code follows the GNU Coding Standards (@pxref{Top,,,
1025standards, GNU Coding Standards}). However, they do not say much about
1026Scheme, so here are some additional rules.
1027
1028@menu
1029* Programming Paradigm:: How to compose your elements.
1030* Modules:: Where to store your code?
1031* Data Types and Pattern Matching:: Implementing data structures.
1032* Formatting Code:: Writing conventions.
1033@end menu
1034
1035@node Programming Paradigm
1036@subsection Programming Paradigm
1037
1038Scheme code in Guix is written in a purely functional style. One
1039exception is code that involves input/output, and procedures that
1040implement low-level concepts, such as the @code{memoize} procedure.
1041
1042@node Modules
1043@subsection Modules
1044
1045Guile modules that are meant to be used on the builder side must live in
1046the @code{(guix build @dots{})} name space. They must not refer to
1047other Guix or GNU modules. However, it is OK for a ``host-side'' module
1048to use a build-side module.
1049
1050Modules that deal with the broader GNU system should be in the
1051@code{(gnu @dots{})} name space rather than @code{(guix @dots{})}.
1052
1053@node Data Types and Pattern Matching
1054@subsection Data Types and Pattern Matching
1055
1056The tendency in classical Lisp is to use lists to represent everything,
1057and then to browse them ``by hand'' using @code{car}, @code{cdr},
1058@code{cadr}, and co. There are several problems with that style,
1059notably the fact that it is hard to read, error-prone, and a hindrance
1060to proper type error reports.
1061
1062Guix code should define appropriate data types (for instance, using
1063@code{define-record-type*}) rather than abuse lists. In addition, it
1064should use pattern matching, via Guile’s @code{(ice-9 match)} module,
f06f569a
LC
1065especially when matching lists (@pxref{Pattern Matching,,, guile, GNU
1066Guile Reference Manual}).
8c01b9d0
ML
1067
1068@node Formatting Code
1069@subsection Formatting Code
1070
7bb2b10c
LC
1071@cindex formatting code
1072@cindex coding style
8c01b9d0
ML
1073When writing Scheme code, we follow common wisdom among Scheme
1074programmers. In general, we follow the
21656ffa 1075@url{https://mumble.net/~campbell/scheme/style.txt, Riastradh's Lisp
8c01b9d0
ML
1076Style Rules}. This document happens to describe the conventions mostly
1077used in Guile’s code too. It is very thoughtful and well written, so
1078please do read it.
1079
1080Some special forms introduced in Guix, such as the @code{substitute*}
1081macro, have special indentation rules. These are defined in the
8ca0c88a
AK
1082@file{.dir-locals.el} file, which Emacs automatically uses. Also note
1083that Emacs-Guix provides @code{guix-devel-mode} mode that indents and
1084highlights Guix code properly (@pxref{Development,,, emacs-guix, The
1085Emacs-Guix Reference Manual}).
7bb2b10c
LC
1086
1087@cindex indentation, of code
1088@cindex formatting, of code
1089If you do not use Emacs, please make sure to let your editor knows these
1090rules. To automatically indent a package definition, you can also run:
1091
1092@example
c4fe13c2 1093./pre-inst-env guix style @var{package}
7bb2b10c
LC
1094@end example
1095
1096@noindent
c4fe13c2 1097@xref{Invoking guix style}, for more information.
8c01b9d0 1098
60912a88
LC
1099@cindex Vim, Scheme code editing
1100If you are editing code with Vim, we recommend that you run @code{:set
1101autoindent} so that your code is automatically indented as you type.
1102Additionally,
1103@uref{https://www.vim.org/scripts/script.php?script_id=3998,
1104@code{paredit.vim}} may help you deal with all these parentheses.
1105
8c01b9d0
ML
1106We require all top-level procedures to carry a docstring. This
1107requirement can be relaxed for simple private procedures in the
1108@code{(guix build @dots{})} name space, though.
1109
1110Procedures should not have more than four positional parameters. Use
1111keyword parameters for procedures that take more than four parameters.
1112
1113
1114@node Submitting Patches
1115@section Submitting Patches
1116
1117Development is done using the Git distributed version control system.
1118Thus, access to the repository is not strictly necessary. We welcome
1119contributions in the form of patches as produced by @code{git
9fc8ae41
SM
1120format-patch} sent to the @email{guix-patches@@gnu.org} mailing list
1121(@pxref{submitting patches,, Submitting patches to a project, git, Git
1122User Manual}). Contributors are encouraged to take a moment to set some
1123Git repository options (@pxref{Configuring Git}) first, which can
1124improve the readability of patches. Seasoned Guix developers may also
1125want to look at the section on commit access (@pxref{Commit Access}).
230efa87 1126
a7bde77d
LC
1127This mailing list is backed by a Debbugs instance, which allows us to
1128keep track of submissions (@pxref{Tracking Bugs and Patches}). Each
1129message sent to that mailing list gets a new tracking number assigned;
1130people can then follow up on the submission by sending email to
1131@code{@var{NNN}@@debbugs.gnu.org}, where @var{NNN} is the tracking
1132number (@pxref{Sending a Patch Series}).
230efa87 1133
8c01b9d0
ML
1134Please write commit logs in the ChangeLog format (@pxref{Change Logs,,,
1135standards, GNU Coding Standards}); you can check the commit history for
1136examples.
1137
1138Before submitting a patch that adds or modifies a package definition,
fcc58db6
LC
1139please run through this check list:
1140
1141@enumerate
d18b787d 1142@cindex @code{git format-patch}
1143@cindex @code{git-format-patch}
1144@item
f697fc26
LF
1145When generating your patches with @code{git format-patch} or @code{git
1146send-email}, we recommend using the option @code{--base=}, perhaps with
1147the value @code{auto}. This option adds a note to the patch stating
1148which commit the patch is based on. This helps reviewers understand how
1149to apply and review your patches.
d18b787d 1150
308c08d3
RW
1151@item
1152If the authors of the packaged software provide a cryptographic
1153signature for the release tarball, make an effort to verify the
1154authenticity of the archive. For a detached GPG signature file this
1155would be done with the @code{gpg --verify} command.
1156
cbd02397
LC
1157@item
1158Take some time to provide an adequate synopsis and description for the
1159package. @xref{Synopses and Descriptions}, for some guidelines.
1160
fcc58db6
LC
1161@item
1162Run @code{guix lint @var{package}}, where @var{package} is the
8c01b9d0 1163name of the new or modified package, and fix any errors it reports
fcc58db6
LC
1164(@pxref{Invoking guix lint}).
1165
c4fe13c2
LC
1166@item
1167Run @code{guix style @var{package}} to format the new package definition
1168according to the project's conventions (@pxref{Invoking guix style}).
1169
fcc58db6
LC
1170@item
1171Make sure the package builds on your platform, using @code{guix build
1172@var{package}}.
1173
89339a35
DM
1174@item
1175We recommend you also try building the package on other supported
1176platforms. As you may not have access to actual hardware platforms, we
1177recommend using the @code{qemu-binfmt-service-type} to emulate them. In
a9afff4b
SR
1178order to enable it, add the @code{virtualization} service module and the
1179following service to the list of services in your @code{operating-system}
1180configuration:
89339a35 1181
8ba31e8b 1182@lisp
89339a35
DM
1183(service qemu-binfmt-service-type
1184 (qemu-binfmt-configuration
a9afff4b 1185 (platforms (lookup-qemu-platforms "arm" "aarch64"))))
8ba31e8b 1186@end lisp
89339a35
DM
1187
1188Then reconfigure your system.
1189
1190You can then build packages for different platforms by specifying the
1191@code{--system} option. For example, to build the "hello" package for
de393bd0 1192the armhf or aarch64 architectures, you would run the following
b28e4e3c 1193commands, respectively:
89339a35
DM
1194@example
1195guix build --system=armhf-linux --rounds=2 hello
1196guix build --system=aarch64-linux --rounds=2 hello
89339a35
DM
1197@end example
1198
d222522e
LC
1199@item
1200@cindex bundling
1201Make sure the package does not use bundled copies of software already
1202available as separate packages.
1203
1204Sometimes, packages include copies of the source code of their
1205dependencies as a convenience for users. However, as a distribution, we
1206want to make sure that such packages end up using the copy we already
1207have in the distribution, if there is one. This improves resource usage
1208(the dependency is built and stored only once), and allows the
1209distribution to make transverse changes such as applying security
1210updates for a given software package in a single place and have them
1211affect the whole system---something that bundled copies prevent.
1212
fcc58db6
LC
1213@item
1214Take a look at the profile reported by @command{guix size}
1215(@pxref{Invoking guix size}). This will allow you to notice references
1216to other packages unwillingly retained. It may also help determine
1217whether to split the package (@pxref{Packages with Multiple Outputs}),
024e358c 1218and which optional dependencies should be used. In particular, avoid adding
0afeb746 1219@code{texlive} as a dependency: because of its extreme size, use
48cccf06 1220the @code{texlive-tiny} package or @code{texlive-union} procedure instead.
fcc58db6
LC
1221
1222@item
f7331f06 1223For important changes, check that dependent packages (if applicable) are
fcc58db6 1224not affected by the change; @code{guix refresh --list-dependent
8c01b9d0
ML
1225@var{package}} will help you do that (@pxref{Invoking guix refresh}).
1226
916b5eba
LC
1227@c See <https://lists.gnu.org/archive/html/guix-devel/2016-10/msg00933.html>.
1228@cindex branching strategy
1229@cindex rebuild scheduling strategy
1230Depending on the number of dependent packages and thus the amount of
1231rebuilding induced, commits go to different branches, along these lines:
1232
1233@table @asis
1234@item 300 dependent packages or less
1235@code{master} branch (non-disruptive changes).
1236
bb9a99e6 1237@item between 300 and 1,800 dependent packages
916b5eba 1238@code{staging} branch (non-disruptive changes). This branch is intended
bb9a99e6 1239to be merged in @code{master} every 6 weeks or so. Topical changes
916b5eba 1240(e.g., an update of the GNOME stack) can instead go to a specific branch
4de68873
LF
1241(say, @code{gnome-updates}). This branch is not expected to be
1242buildable or usable until late in its development process.
916b5eba 1243
bb9a99e6 1244@item more than 1,800 dependent packages
916b5eba
LC
1245@code{core-updates} branch (may include major and potentially disruptive
1246changes). This branch is intended to be merged in @code{master} every
4de68873
LF
12476 months or so. This branch is not expected to be buildable or usable
1248until late in its development process.
916b5eba
LC
1249@end table
1250
4985a427 1251All these branches are @uref{https://@value{SUBSTITUTE-SERVER-1},
38ab778f 1252tracked by our build farm} and merged into @code{master} once
189b1543
LC
1253everything has been successfully built. This allows us to fix issues
1254before they hit users, and to reduce the window during which pre-built
1255binaries are not available.
1256
175bea0c 1257When we decide to start building the @code{staging} or
58853df8
LF
1258@code{core-updates} branches, they will be forked and renamed with the
1259suffix @code{-frozen}, at which time only bug fixes may be pushed to the
1260frozen branches. The @code{core-updates} and @code{staging} branches
1261will remain open to accept patches for the next cycle. Please ask on
1262the mailing list or IRC if unsure where to place a patch.
38ab778f
MB
1263@c TODO: It would be good with badges on the website that tracks these
1264@c branches. Or maybe even a status page.
1265
d23c20f1 1266@item
5b74fe06
LC
1267@cindex determinism, of build processes
1268@cindex reproducible builds, checking
d23c20f1
LC
1269Check whether the package's build process is deterministic. This
1270typically means checking whether an independent build of the package
1271yields the exact same result that you obtained, bit for bit.
1272
5b74fe06
LC
1273A simple way to do that is by building the same package several times in
1274a row on your machine (@pxref{Invoking guix build}):
1275
1276@example
1277guix build --rounds=2 my-package
1278@end example
1279
1280This is enough to catch a class of common non-determinism issues, such
1281as timestamps or randomly-generated output in the build result.
1282
1283Another option is to use @command{guix challenge} (@pxref{Invoking guix
1284challenge}). You may run it once the package has been committed and
4985a427 1285built by @code{@value{SUBSTITUTE-SERVER-1}} to check whether it obtains the same
5b74fe06
LC
1286result as you did. Better yet: Find another machine that can build it
1287and run @command{guix publish}. Since the remote build machine is
1288likely different from yours, this can catch non-determinism issues
1289related to the hardware---e.g., use of different instruction set
1290extensions---or to the operating system kernel---e.g., reliance on
1291@code{uname} or @file{/proc} files.
d23c20f1 1292
3c2d03a2
LC
1293@item
1294When writing documentation, please use gender-neutral wording when
1295referring to people, such as
1296@uref{https://en.wikipedia.org/wiki/Singular_they, singular
1297``they''@comma{} ``their''@comma{} ``them''}, and so forth.
1298
3a78fab8 1299@item
1300Verify that your patch contains only one set of related changes.
1301Bundling unrelated changes together makes reviewing harder and slower.
1302
1303Examples of unrelated changes include the addition of several packages,
1304or a package update along with fixes to that package.
1305
7bb2b10c 1306@item
c4fe13c2
LC
1307Please follow our code formatting rules, possibly running
1308@command{guix style} script to do that automatically for you
7bb2b10c
LC
1309(@pxref{Formatting Code}).
1310
4feb589b
PN
1311@item
1312When possible, use mirrors in the source URL (@pxref{Invoking guix download}).
1313Use reliable URLs, not generated ones. For instance, GitHub archives are not
1314necessarily identical from one generation to the next, so in this case it's
1315often better to clone the repository. Don't use the @command{name} field in
1316the URL: it is not very useful and if the name changes, the URL will probably
1317be wrong.
1318
bf99d7e0 1319@item
da31e7d9
PN
1320Check if Guix builds (@pxref{Building from Git}) and address the
1321warnings, especially those about use of undefined symbols.
bf99d7e0 1322
9fcf2820
PN
1323@item
1324Make sure your changes do not break Guix and simulate a @code{guix pull} with:
1325@example
1326guix pull --url=/path/to/your/checkout --profile=/tmp/guix.master
1327@end example
1328
fcc58db6
LC
1329@end enumerate
1330
a40424bd 1331When posting a patch to the mailing list, use @samp{[PATCH] @dots{}} as
a1891cbf
BW
1332a subject, if your patch is to be applied on a branch other than
1333@code{master}, say @code{core-updates}, specify it in the subject like
1334@samp{[PATCH core-updates] @dots{}}. You may use your email client or
1335the @command{git send-email} command (@pxref{Sending a Patch Series}).
1336We prefer to get patches in plain text messages, either inline or as
1337MIME attachments. You are advised to pay attention if your email client
1338changes anything like line breaks or indentation which could potentially
1339break the patches.
5a183a1e 1340
c8d6fa77
FL
1341Expect some delay when you submit your very first patch to
1342@email{guix-patches@@gnu.org}. You have to wait until you get an
4b08aad5 1343acknowledgement with the assigned tracking number. Future acknowledgements
c8d6fa77
FL
1344should not be delayed.
1345
4619b59c
JN
1346When a bug is resolved, please close the thread by sending an email to
1347@email{@var{NNN}-done@@debbugs.gnu.org}.
1348
9fc8ae41
SM
1349@node Configuring Git
1350@subsection Configuring Git
1351@cindex git configuration
1352@cindex @code{git format-patch}
1353@cindex @code{git send-email}
1354
1355If you have not done so already, you may wish to set a name and email
1356that will be associated with your commits (@pxref{telling git your name,
1357, Telling Git your name, git, Git User Manual}). If you wish to use a
5fafb6e7 1358different name or email just for commits in this repository, you can
9fc8ae41
SM
1359use @command{git config --local}, or edit @file{.git/config} in the
1360repository instead of @file{~/.gitconfig}.
1361
1362We provide some default settings in @file{etc/git/gitconfig} which
1363modify how patches are generated, making them easier to read and apply.
1364These settings can be applied by manually copying them to
1365@file{.git/config} in your checkout, or by telling Git to include the
1366whole file:
1367
1368@example
1369git config --local include.path ../etc/git/gitconfig
1370@end example
1371
1372From then on, any changes to @file{etc/git/gitconfig} would
1373automatically take effect.
1374
1375Since the first patch in a series must be sent separately
1376(@pxref{Sending a Patch Series}), it can also be helpful to tell
1377@command{git format-patch} to handle the e-mail threading instead of
1378@command{git send-email}:
1379
1380@example
1381git config --local format.thread shallow
1382git config --local sendemail.thread no
1383@end example
1384
5a183a1e
JN
1385@unnumberedsubsec Sending a Patch Series
1386@anchor{Sending a Patch Series}
1387@cindex patch series
1388@cindex @code{git send-email}
5a183a1e
JN
1389
1390When sending a patch series (e.g., using @code{git send-email}), please
1391first send one message to @email{guix-patches@@gnu.org}, and then send
1392subsequent patches to @email{@var{NNN}@@debbugs.gnu.org} to make sure
1393they are kept together. See
1394@uref{https://debbugs.gnu.org/Advanced.html, the Debbugs documentation}
fb8b99a5
AB
1395for more information. You can install @command{git send-email} with
1396@command{guix install git:send-email}.
5a183a1e 1397@c Debbugs bug: https://debbugs.gnu.org/db/15/15361.html
a7bde77d
LC
1398
1399@node Tracking Bugs and Patches
1400@section Tracking Bugs and Patches
1401
3c86372e
CM
1402This section describes how the Guix project tracks its bug reports and
1403patch submissions.
1404
1405@menu
1406* The Issue Tracker:: The official bug and patch tracker.
1407* Debbugs User Interfaces:: Ways to interact with Debbugs.
1408* Debbugs Usertags:: Tag reports with custom labels.
1409@end menu
1410
1411@node The Issue Tracker
1412@subsection The Issue Tracker
1413
a7bde77d
LC
1414@cindex bug reports, tracking
1415@cindex patch submissions, tracking
1416@cindex issue tracking
1417@cindex Debbugs, issue tracking system
1418Bug reports and patch submissions are currently tracked using the
1419Debbugs instance at @uref{https://bugs.gnu.org}. Bug reports are filed
1420against the @code{guix} ``package'' (in Debbugs parlance), by sending
1421email to @email{bug-guix@@gnu.org}, while patch submissions are filed
1422against the @code{guix-patches} package by sending email to
1423@email{guix-patches@@gnu.org} (@pxref{Submitting Patches}).
1424
3c86372e
CM
1425@node Debbugs User Interfaces
1426@subsection Debbugs User Interfaces
1427
a7bde77d
LC
1428A web interface (actually @emph{two} web interfaces!) are available to
1429browse issues:
1430
1431@itemize
1432@item
cdea5265
LC
1433@url{https://issues.guix.gnu.org} provides a pleasant
1434interface@footnote{The web interface at
1435@url{https://issues.guix.gnu.org} is powered by Mumi, a nice piece of
1436software written in Guile, and you can help! See
1437@url{https://git.elephly.net/gitweb.cgi?p=software/mumi.git}.} to browse
1438bug reports and patches, and to participate in discussions;
1439@item
a7bde77d
LC
1440@url{https://bugs.gnu.org/guix} lists bug reports;
1441@item
1442@url{https://bugs.gnu.org/guix-patches} lists patch submissions.
1443@end itemize
1444
cdea5265
LC
1445To view discussions related to issue number @var{n}, go to
1446@indicateurl{https://issues.guix.gnu.org/@var{n}} or
a7bde77d
LC
1447@indicateurl{https://bugs.gnu.org/@var{n}}.
1448
1449If you use Emacs, you may find it more convenient to interact with
1450issues using @file{debbugs.el}, which you can install with:
1451
1452@example
1453guix install emacs-debbugs
1454@end example
1455
1456For example, to list all open issues on @code{guix-patches}, hit:
1457
1458@example
1459@kbd{C-u} @kbd{M-x} debbugs-gnu @kbd{RET} @kbd{RET} guix-patches @kbd{RET} n y
1460@end example
1461
1462@xref{Top,,, debbugs-ug, Debbugs User Guide}, for more information on
1463this nifty tool!
2d315cd4 1464
3c86372e
CM
1465@node Debbugs Usertags
1466@subsection Debbugs Usertags
1467
1468@cindex usertags, for debbugs
1469@cindex Debbugs usertags
1470Debbugs provides a feature called @dfn{usertags} that allows any user to
1471tag any bug with an arbitrary label. Bugs can be searched by usertag,
1472so this is a handy way to organize bugs@footnote{The list of usertags is
1473public information, and anyone can modify any user's list of usertags,
1474so keep that in mind if you choose to use this feature.}.
1475
1476For example, to view all the bug reports (or patches, in the case of
1477@code{guix-patches}) tagged with the usertag @code{powerpc64le-linux}
586136d1
CM
1478for the user @code{guix}, open a URL like the following in a web
1479browser:
1480@url{https://debbugs.gnu.org/cgi-bin/pkgreport.cgi?tag=powerpc64le-linux;users=guix}.
3c86372e
CM
1481
1482For more information on how to use usertags, please refer to the
1483documentation for Debbugs or the documentation for whatever tool you use
1484to interact with Debbugs.
1485
1486In Guix, we are experimenting with usertags to keep track of
1487architecture-specific issues. To facilitate collaboration, all our
586136d1
CM
1488usertags are associated with the single user @code{guix}. The following
1489usertags currently exist for that user:
3c86372e
CM
1490
1491@table @code
1492
1493@item powerpc64le-linux
1494The purpose of this usertag is to make it easy to find the issues that
1495matter most for the @code{powerpc64le-linux} system type. Please assign
1496this usertag to bugs or patches that affect @code{powerpc64le-linux} but
1497not other system types. In addition, you may use it to identify issues
1498that for some reason are particularly important for the
1499@code{powerpc64le-linux} system type, even if the issue affects other
1500system types, too.
1501
1502@item reproducibility
1503For issues related to reproducibility. For example, it would be
1504appropriate to assign this usertag to a bug report for a package that
1505fails to build reproducibly.
1506
1507@end table
1508
1509If you're a committer and you want to add a usertag, just start using it
586136d1
CM
1510with the @code{guix} user. If the usertag proves useful to you,
1511consider updating this section of the manual so that others will know
1512what your usertag means.
3c86372e 1513
2d315cd4
LC
1514@node Commit Access
1515@section Commit Access
1516
1517@cindex commit access, for developers
aaf4a009
LC
1518Everyone can contribute to Guix without having commit access
1519(@pxref{Submitting Patches}). However, for frequent contributors,
c1043fd6
MC
1520having write access to the repository can be convenient. As a rule of
1521thumb, a contributor should have accumulated fifty (50) reviewed commits
1522to be considered as a committer and have sustained their activity in the
1523project for at least 6 months. This ensures enough interactions with
1524the contributor, which is essential for mentoring and assessing whether
1525they are ready to become a committer. Commit access should not be
1526thought of as a ``badge of honor'' but rather as a responsibility a
1527contributor is willing to take to help the project.
aaf4a009
LC
1528
1529The following sections explain how to get commit access, how to be ready
1530to push commits, and the policies and community expectations for commits
1531pushed upstream.
1532
1533@subsection Applying for Commit Access
1534
1535When you deem it necessary, consider applying for commit
ef09cb86
LC
1536access by following these steps:
1537
1538@enumerate
1539@item
1540Find three committers who would vouch for you. You can view the list of
1541committers at
1542@url{https://savannah.gnu.org/project/memberlist.php?group=guix}. Each
1543of them should email a statement to @email{guix-maintainers@@gnu.org} (a
1544private alias for the collective of maintainers), signed with their
1545OpenPGP key.
1546
1547Committers are expected to have had some interactions with you as a
1548contributor and to be able to judge whether you are sufficiently
1549familiar with the project's practices. It is @emph{not} a judgment on
1550the value of your work, so a refusal should rather be interpreted as
1551``let's try again later''.
1552
1553@item
1554Send @email{guix-maintainers@@gnu.org} a message stating your intent,
1555listing the three committers who support your application, signed with
1556the OpenPGP key you will use to sign commits, and giving its fingerprint
1557(see below). See @uref{https://emailselfdefense.fsf.org/en/}, for an
1558introduction to public-key cryptography with GnuPG.
1559
4a84deda
LC
1560@c See <https://sha-mbles.github.io/>.
1561Set up GnuPG such that it never uses the SHA1 hash algorithm for digital
1562signatures, which is known to be unsafe since 2019, for instance by
1563adding the following line to @file{~/.gnupg/gpg.conf} (@pxref{GPG
1564Esoteric Options,,, gnupg, The GNU Privacy Guard Manual}):
1565
1566@example
1567digest-algo sha512
1568@end example
1569
ef09cb86
LC
1570@item
1571Maintainers ultimately decide whether to grant you commit access,
1572usually following your referrals' recommendation.
1573
1574@item
84133320 1575@cindex OpenPGP, signed commits
ef09cb86
LC
1576If and once you've been given access, please send a message to
1577@email{guix-devel@@gnu.org} to say so, again signed with the OpenPGP key
1578you will use to sign commits (do that before pushing your first commit).
1579That way, everyone can notice and ensure you control that OpenPGP key.
1580
84133320
LC
1581@quotation Important
1582Before you can push for the first time, maintainers must:
1583
1584@enumerate
1585@item
1586add your OpenPGP key to the @code{keyring} branch;
1587@item
1588add your OpenPGP fingerprint to the @file{.guix-authorizations} file of
1589the branch(es) you will commit to.
1590@end enumerate
1591@end quotation
ef09cb86
LC
1592
1593@item
1594Make sure to read the rest of this section and... profit!
1595@end enumerate
1596
1597@quotation Note
1598Maintainers are happy to give commit access to people who have been
1599contributing for some time and have a track record---don't be shy and
1600don't underestimate your work!
1601
1602However, note that the project is working towards a more automated patch
1603review and merging system, which, as a consequence, may lead us to have
1604fewer people with commit access to the main repository. Stay tuned!
1605@end quotation
1606
2d315cd4
LC
1607All commits that are pushed to the central repository on Savannah must
1608be signed with an OpenPGP key, and the public key should be uploaded to
1609your user account on Savannah and to public key servers, such as
1610@code{keys.openpgp.org}. To configure Git to automatically sign
1611commits, run:
1612
1613@example
1614git config commit.gpgsign true
b5b9266e
LC
1615
1616# Substitute the fingerprint of your public PGP key.
2d315cd4
LC
1617git config user.signingkey CABBA6EA1DC0FF33
1618@end example
1619
1620You can prevent yourself from accidentally pushing unsigned commits to
b5b9266e 1621Savannah by using the pre-push Git hook located at
2d315cd4
LC
1622@file{etc/git/pre-push}:
1623
1624@example
1625cp etc/git/pre-push .git/hooks/pre-push
1626@end example
1627
aaf4a009
LC
1628@subsection Commit Policy
1629
1630If you get commit access, please make sure to follow
1631the policy below (discussions of the policy can take place on
1632@email{guix-devel@@gnu.org}).
1633
1634Non-trivial patches should always be posted to
1635@email{guix-patches@@gnu.org} (trivial patches include fixing typos,
1636etc.). This mailing list fills the patch-tracking database
1637(@pxref{Tracking Bugs and Patches}).
1638
1639For patches that just add a new package, and a simple one, it's OK to
1640commit, if you're confident (which means you successfully built it in a
1641chroot setup, and have done a reasonable copyright and license
1642auditing). Likewise for package upgrades, except upgrades that trigger
1643a lot of rebuilds (for example, upgrading GnuTLS or GLib). We have a
1644mailing list for commit notifications (@email{guix-commits@@gnu.org}),
1645so people can notice. Before pushing your changes, make sure to run
1646@code{git pull --rebase}.
1647
2d315cd4
LC
1648When pushing a commit on behalf of somebody else, please add a
1649@code{Signed-off-by} line at the end of the commit log message---e.g.,
1650with @command{git am --signoff}. This improves tracking of who did
1651what.
1652
1ad5209d
LC
1653When adding channel news entries (@pxref{Channels, Writing Channel
1654News}), make sure they are well-formed by running the following command
1655right before pushing:
1656
1657@example
1658make check-channel-news
1659@end example
1660
2d315cd4
LC
1661For anything else, please post to @email{guix-patches@@gnu.org} and
1662leave time for a review, without committing anything (@pxref{Submitting
1663Patches}). If you didn’t receive any reply after two weeks, and if
1664you're confident, it's OK to commit.
1665
1666That last part is subject to being adjusted, allowing individuals to commit
1667directly on non-controversial changes on parts they’re familiar with.
98ebcf1c 1668
d4751342
LC
1669@subsection Addressing Issues
1670
1671Peer review (@pxref{Submitting Patches}) and tools such as
1672@command{guix lint} (@pxref{Invoking guix lint}) and the test suite
1673(@pxref{Running the Test Suite}) should catch issues before they are
1674pushed. Yet, commits that ``break'' functionality might occasionally
1675go through. When that happens, there are two priorities: mitigating
1676the impact, and understanding what happened to reduce the chance of
1677similar incidents in the future. The responsibility for both these
1678things primarily lies with those involved, but like everything this is
1679a group effort.
1680
1681Some issues can directly affect all users---for instance because they
1682make @command{guix pull} fail or break core functionality, because they
1683break major packages (at build time or run time), or because they
1684introduce known security vulnerabilities.
1685
1686@cindex reverting commits
1687The people involved in authoring, reviewing, and pushing such
1688commit(s) should be at the forefront to mitigate their impact in a
1689timely fashion: by pushing a followup commit to fix it (if possible),
1690or by reverting it to leave time to come up with a proper fix, and by
1691communicating with other developers about the problem.
1692
1693If these persons are unavailable to address the issue in time, other
1694committers are entitled to revert the commit(s), explaining in the
1695commit log and on the mailing list what the problem was, with the goal
1696of leaving time to the original committer, reviewer(s), and author(s)
1697to propose a way forward.
1698
1699Once the problem has been dealt with, it is the responsibility of
1700those involved to make sure the situation is understood. If you are
1701working to understand what happened, focus on gathering information
1702and avoid assigning any blame. Do ask those involved to describe what
1703happened, do not ask them to explain the situation---this would
1704implicitly blame them, which is unhelpful. Accountability comes from
1705a consensus about the problem, learning from it and improving
1706processes so that it's less likely to reoccur.
1707
aaf4a009
LC
1708@subsection Commit Revocation
1709
9ade2b72
LF
1710In order to reduce the possibility of mistakes, committers will have
1711their Savannah account removed from the Guix Savannah project and their
1712key removed from @file{.guix-authorizations} after 12 months of
1713inactivity; they can ask to regain commit access by emailing the
1714maintainers, without going through the vouching process.
1715
d3d6d1c6
LC
1716Maintainers@footnote{See @uref{https://guix.gnu.org/en/about} for the
1717current list of maintainers. You can email them privately at
1718@email{guix-maintainers@@gnu.org}.} may also revoke an individual's
1719commit rights, as a last resort, if cooperation with the rest of the
1720community has caused too much friction---even within the bounds of the
1721project's code of conduct (@pxref{Contributing}). They would only do so
1722after public or private discussion with the individual and a clear
1723notice. Examples of behavior that hinders cooperation and could lead to
1724such a decision include:
1725
1726@itemize
1727@item repeated violation of the commit policy stated above;
1728@item repeated failure to take peer criticism into account;
1729@item breaching trust through a series of grave incidents.
1730@end itemize
1731
1732When maintainers resort to such a decision, they notify developers on
1733@email{guix-devel@@gnu.org}; inquiries may be sent to
1734@email{guix-maintainers@@gnu.org}. Depending on the situation, the
1735individual may still be welcome to contribute.
1736
aaf4a009
LC
1737@subsection Helping Out
1738
98ebcf1c
LC
1739One last thing: the project keeps moving forward because committers not
1740only push their own awesome changes, but also offer some of their time
1741@emph{reviewing} and pushing other people's changes. As a committer,
1742you're welcome to use your expertise and commit rights to help other
1743contributors, too!
5800d2aa
MC
1744
1745@node Updating the Guix Package
1746@section Updating the Guix Package
1747
1748@cindex update-guix-package, updating the guix package
1749It is sometimes desirable to update the @code{guix} package itself (the
1750package defined in @code{(gnu packages package-management)}), for
1751example to make new daemon features available for use by the
1752@code{guix-service-type} service type. In order to simplify this task,
1753the following command can be used:
1754
1755@example
1756make update-guix-package
1757@end example
1758
1759The @code{update-guix-package} make target will use the last known
1760@emph{commit} corresponding to @code{HEAD} in your Guix checkout,
1761compute the hash of the Guix sources corresponding to that commit and
1762update the @code{commit}, @code{revision} and hash of the @code{guix}
1763package definition.
1764
1765To validate that the updated @code{guix} package hashes are correct and
1766that it can be built successfully, the following command can be run from
1767the directory of your Guix checkout:
1768
1769@example
1770./pre-inst-env guix build guix
1771@end example
1772
1773To guard against accidentally updating the @code{guix} package to a
1774commit that others can't refer to, a check is made that the commit used
1775has already been pushed to the Savannah-hosted Guix git repository.
1776
1777This check can be disabled, @emph{at your own peril}, by setting the
3de898b4
MC
1778@code{GUIX_ALLOW_ME_TO_USE_PRIVATE_COMMIT} environment variable. When
1779this variable is set, the updated package source is also added to the
1780store. This is used as part of the release process of Guix.
1897a6ef
JL
1781
1782@cindex translation
1783@cindex l10n
1784@cindex i18n
1785@cindex native language support
1786@node Translating Guix
1787@section Translating Guix
1788
1789Writing code and packages is not the only way to provide a meaningful
1790contribution to Guix. Translating to a language you speak is another
1791example of a valuable contribution you can make. This section is designed
1792to describe the translation process. It gives you advice on how you can
1793get involved, what can be translated, what mistakes you should avoid and
1794what we can do to help you!
1795
1796Guix is a big project that has multiple components that can be translated.
1797We coordinate the translation effort on a
1798@uref{https://translate.fedoraproject.org/projects/guix/,Weblate instance}
1799hosted by our friends at Fedora. You will need an account to submit
1800translations.
1801
1802Some of the software packaged in Guix also contain translations. We do not
1803host a translation platform for them. If you want to translate a package
ef7275cd 1804provided by Guix, you should contact their developers or find the information
1897a6ef
JL
1805on their website. As an example, you can find the homepage of the
1806@code{hello} package by typing @code{guix show hello}. On the ``homepage''
1807line, you will see @url{https://www.gnu.org/software/hello/} as the homepage.
1808
1809Many GNU and non-GNU packages can be translated on the
1810@uref{https://translationproject.org,Translation Project}. Some projects
1811with multiple components have their own platform. For instance, GNOME has
1812its own platform, @uref{https://l10n.gnome.org/,Damned Lies}.
1813
1814Guix has five components hosted on Weblate.
1815
1816@itemize
1817@item @code{guix} contains all the strings from the Guix software (the
1818 guided system installer, the package manager, etc), excluding packages.
1819@item @code{packages} contains the synopsis (single-sentence description
1820 of a package) and description (longer description) of packages in Guix.
1821@item @code{website} contains the official Guix website, except for
1822 blog posts and multimedia content.
1823@item @code{documentation-manual} corresponds to this manual.
1824@item @code{documentation-cookbook} is the component for the cookbook.
1825@end itemize
1826
1827@subsubheading General Directions
1828
1829Once you get an account, you should be able to select a component from
1830@uref{https://translate.fedoraproject.org/projects/guix/,the guix project},
1831and select a language. If your language does not appear in the list, go
1832to the bottom and click on the ``Start new translation'' button. Select
1833the language you want to translate to from the list, to start your new
1834translation.
1835
1836Like lots of other free software packages, Guix uses
1837@uref{https://www.gnu.org/software/gettext,GNU Gettext} for its translations,
1838with which translatable strings are extracted from the source code to so-called
1839PO files.
1840
1841Even though PO files are text files, changes should not be made with a text
1842editor but with PO editing software. Weblate integrates PO editing
1843functionality. Alternatively, translators can use any of various
1844free-software tools for filling in translations, of which
1845@uref{https://poedit.net/,Poedit} is one example, and (after logging in)
1846@uref{https://docs.weblate.org/en/latest/user/files.html,upload} the changed
1847file. There is also a special
1848@uref{https://www.emacswiki.org/emacs/PoMode,PO editing mode} for users of GNU
1849Emacs. Over time translators find out what software they are happy with and
1850what features they need.
1851
1852On Weblate, you will find various links to the editor, that will show various
1853subsets (or all) of the strings. Have a look around and at the
1854@uref{https://docs.weblate.org/en/latest/,documentation} to familiarize
1855yourself with the platform.
1856
1857@subsubheading Translation Components
1858
1859In this section, we provide more detailed guidance on the translation
1860process, as well as details on what you should or should not do. When in
1861doubt, please contact us, we will be happy to help!
1862
1863@table @asis
1864@item guix
1865Guix is written in the Guile programming language, and some strings contain
d127fdd0 1866special formatting that is interpreted by Guile. These special formatting
1897a6ef
JL
1867should be highlighted by Weblate. They start with @code{~} followed by one
1868or more characters.
1869
d127fdd0 1870When printing the string, Guile replaces the special formatting symbols with
1897a6ef
JL
1871actual values. For instance, the string @samp{ambiguous package specification
1872`~a'} would be substituted to contain said package specification instead of
d127fdd0 1873@code{~a}. To properly translate this string, you must keep the formatting
1897a6ef
JL
1874code in your translation, although you can place it where it makes sense in
1875your language. For instance, the French translation says @samp{spécification
1876du paquet « ~a » ambiguë} because the adjective needs to be placed in the
1877end of the sentence.
1878
d127fdd0 1879If there are multiple formatting symbols, make sure to respect the order.
1897a6ef
JL
1880Guile does not know in which order you intended the string to be read, so it
1881will substitute the symbols in the same order as the English sentence.
1882
1883As an example, you cannot translate @samp{package '~a' has been superseded by
1884'~a'} by @samp{'~a' superseeds package '~a'}, because the meaning would be
ef7275cd 1885reversed. If @var{foo} is superseded by @var{bar}, the translation would read
1897a6ef 1886@samp{'foo' superseeds package 'bar'}. To work around this problem, it
d127fdd0 1887is possible to use more advanced formatting to select a given piece of data,
1897a6ef 1888instead of following the default English order. @xref{Formatted Output,,,
d127fdd0 1889guile, GNU Guile Reference Manual}, for more information on formatting in Guile.
1897a6ef
JL
1890
1891@item packages
1892
1893Package descriptions occasionally contain Texinfo markup (@pxref{Synopses
1894and Descriptions}). Texinfo markup looks like @samp{@@code@{rm -rf@}},
1895@samp{@@emph@{important@}}, etc. When translating, please leave markup as is.
1896
1897The characters after ``@@'' form the name of the markup, and the text between
1898``@{'' and ``@}'' is its content. In general, you should not translate the
1899content of markup like @code{@@code}, as it contains literal code that do not
d127fdd0 1900change with language. You can translate the content of formatting markup such
1897a6ef
JL
1901as @code{@@emph}, @code{@@i}, @code{@@itemize}, @code{@@item}. However, do
1902not translate the name of the markup, or it will not be recognized. Do
1903not translate the word after @code{@@end}, it is the name of the markup that
1904is closed at this position (e.g.@: @code{@@itemize ... @@end itemize}).
1905
1906@item documentation-manual and documentation-cookbook
1907
1908The first step to ensure a successful translation of the manual is to find
1909and translate the following strings @emph{first}:
1910
1911@itemize
1912@item @code{version.texi}: Translate this string as @code{version-xx.texi},
1913 where @code{xx} is your language code (the one shown in the URL on
1914 weblate).
1915@item @code{contributing.texi}: Translate this string as
1916 @code{contributing.xx.texi}, where @code{xx} is the same language code.
1917@item @code{Top}: Do not translate this string, it is important for Texinfo.
1918 If you translate it, the document will be empty (missing a Top node).
1919 Please look for it, and register @code{Top} as its translation.
1920@end itemize
1921
1922Translating these strings first ensure we can include your translation in
1923the guix repository without breaking the make process or the
1924@command{guix pull} machinery.
1925
1926The manual and the cookbook both use Texinfo. As for @code{packages}, please
1927keep Texinfo markup as is. There are more possible markup types in the manual
1928than in the package descriptions. In general, do not translate the content
1929of @code{@@code}, @code{@@file}, @code{@@var}, @code{@@value}, etc. You
d127fdd0 1930should translate the content of formatting markup such as @code{@@emph},
1897a6ef
JL
1931@code{@@i}, etc.
1932
d127fdd0 1933The manual contains sections that can be referred to by name by @code{@@ref},
1897a6ef
JL
1934@code{@@xref} and @code{@@pxref}. We have a mechanism in place so you do
1935not have to translate their content. If you keep the English title, we will
1936automatically replace it with your translation of that title. This ensures
1937that Texinfo will always be able to find the node. If you decide to change
1938the translation of the title, the references will automatically be updated
1939and you will not have to update them all yourself.
1940
1941When translating references from the cookbook to the manual, you need to
1942replace the name of the manual and the name of the section. For instance,
1943to translate @code{@@pxref@{Defining Packages,,, guix, GNU Guix Reference
1944Manual@}}, you would replace @code{Defining Packages} with the title of that
1945section in the translated manual @emph{only} if that title is translated.
1946If the title is not translated in your language yet, do not translate it here,
1947or the link will be broken. Replace @code{guix} with @code{guix.xx} where
1948@code{xx} is your language code. @code{GNU Guix Reference Manual} is the
1949text of the link. You can translate it however you wish.
1950
1951@item website
1952
1953The website pages are written using SXML, an s-expression version of HTML,
1954the basic language of the web. We have a process to extract translatable
1955strings from the source, and replace complex s-expressions with a more familiar
1956XML markup, where each markup is numbered. Translators can arbitrarily change
1957the ordering, as in the following example.
1958
1959@example
1960#. TRANSLATORS: Defining Packages is a section name
1961#. in the English (en) manual.
1962#: apps/base/templates/about.scm:64
1963msgid "Packages are <1>defined<1.1>en</1.1><1.2>Defining-Packages.html</1.2></1> as native <2>Guile</2> modules."
1964msgstr "Pakete werden als reine <2>Guile</2>-Module <1>definiert<1.1>de</1.1><1.2>Pakete-definieren.html</1.2></1>."
1965@end example
1966
1967Note that you need to include the same markups. You cannot skip any.
1968@end table
1969
1970In case you make a mistake, the component might fail to build properly with your
1971language, or even make guix pull fail. To prevent that, we have a process
1972in place to check the content of the files before pushing to our repository.
1973We will not be able to update the translation for your language in Guix, so
1974we will notify you (through weblate and/or by email) so you get a chance to
1975fix the issue.
1976
1977@subsubheading Outside of Weblate
1978
1979Currently, some parts of Guix cannot be translated on Weblate, help wanted!
1980
1981@itemize
1982@item @command{guix pull} news can be translated in @file{news.scm}, but is not
1983 available from Weblate. If you want to provide a translation, you
1984 can prepare a patch as described above, or simply send us your
1985 translation with the name of the news entry you translated and your
1986 language. @xref{Writing Channel News}, for more information about
1987 channel news.
1988@item Guix blog posts cannot currently be translated.
1989@item The installer script (for foreign distributions) is entirely in English.
1990@item Some of the libraries Guix uses cannot be translated or are translated
1991 outside of the Guix project. Guile itself is not internationalized.
1992@item Other manuals linked from this manual or the cookbook might not be
1993 translated.
1994@end itemize
1995
6386c011
JL
1996@subsubheading Conditions for Inclusion
1997
1998There are no conditions for adding new translations of the @code{guix} and
1999@code{guix-packages} components, other than they need at least one translated
2000string. New languages will be added to Guix as soon as possible. The
2001files may be removed if they fall out of sync and have no more translated
2002strings.
2003
2004Given that the web site is dedicated to new users, we want its translation
2005to be as complete as possible before we include it in the language menu.
2006For a new language to be included, it needs to reach at least 80% completion.
2007When a language is included, it may be removed in the future if it stays
2008out of sync and falls below 60% completion.
2009
2010The manual and cookbook are automatically added in the default compilation
2011target. Everytime we synchronize translations, developers need to
2012recompile all the translated manuals and cookbooks. This is useless for what
2013is essentially the English manual or cookbook. Therefore, we will only
2014include a new language when it reaches 10% completion in the component.
2015When a language is included, it may be removed in the future if it stays
2016out of sync and falls below 5% completion.
2017
1897a6ef
JL
2018@subsubheading Translation Infrastructure
2019
2020Weblate is backed by a git repository from which it discovers new strings to
2021translate and pushes new and updated translations. Normally, it would be
2022enough to give it commit access to our repositories. However, we decided
2023to use a separate repository for two reasons. First, we would have to give
2024Weblate commit access and authorize its signing key, but we do not trust it
ef7275cd 2025in the same way we trust guix developers, especially since we do not manage
1897a6ef
JL
2026the instance ourselves. Second, if translators mess something up, it can
2027break the generation of the website and/or guix pull for all our users,
2028independently of their language.
2029
2030For these reasons, we use a dedicated repository to host translations, and we
2031synchronize it with our guix and artworks repositories after checking no issue
2032was introduced in the translation.
2033
ef7275cd 2034Developers can download the latest PO files from weblate in the Guix
d127fdd0 2035repository by running the @command{make download-po} command. It will
1897a6ef
JL
2036automatically download the latest files from weblate, reformat them to a
2037canonical form, and check they do not contain issues. The manual needs to be
2038built again to check for additional issues that might crash Texinfo.
2039
ef7275cd 2040Before pushing new translation files, developers should add them to the
1897a6ef
JL
2041make machinery so the translations are actually available. The process
2042differs for the various components.
2043
2044@itemize
2045@item New po files for the @code{guix} and @code{packages} components must
2046 be registered by adding the new language to @file{po/guix/LINGUAS} or
2047 @file{po/packages/LINGUAS}.
2048@item New po files for the @code{documentation-manual} component must be
2049 registered by adding the file name to @code{DOC_PO_FILES} in
2050 @file{po/doc/local.mk}, the generated @file{%D%/guix.xx.texi} manual to
2051 @code{info_TEXINFOS} in @file{doc/local.mk} and the generated
2052 @file{%D%/guix.xx.texi} and @file{%D%/contributing.xx.texi} to
2053 @code{TRANSLATED_INFO} also in @file{doc/local.mk}.
2054@item New po files for the @code{documentation-cookbook} component must be
2055 registered by adding the file name to @code{DOC_COOKBOOK_PO_FILES} in
2056 @file{po/doc/local.mk}, the generated @file{%D%/guix-cookbook.xx.texi}
2057 manual to @code{info_TEXINFOS} in @file{doc/local.mk} and the generated
2058 @file{%D%/guix-cookbook.xx.texi} to @code{TRANSLATED_INFO} also
2059 in @file{doc/local.mk}.
2060@item New po files for the @code{website} component must be added to the
2061 @code{guix-artwork} repository, in @file{website/po/}.
2062 @file{website/po/LINGUAS} and @file{website/po/ietf-tags.scm} must
2063 be updated accordingly (see @file{website/i18n-howto.txt} for more
2064 information on the process).
2065@end itemize