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