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