gnu: texlive-bin: Disable tests on aarch64.
[jackhill/guix/guix.git] / doc / contributing.texi
CommitLineData
8c01b9d0
ML
1@node Contributing
2@chapter Contributing
3
4This project is a cooperative effort, and we need your help to make it
5grow! Please get in touch with us on @email{guix-devel@@gnu.org} and
6@code{#guix} on the Freenode IRC network. We welcome ideas, bug
7reports, patches, and anything that may be helpful to the project. We
8particularly welcome help on packaging (@pxref{Packaging Guidelines}).
9
e15fcdd1
LC
10@cindex code of conduct, of contributors
11@cindex contributor covenant
dcb7119a
AS
12We want to provide a warm, friendly, and harassment-free environment, so
13that anyone can contribute to the best of their abilities. To this end
14our project uses a ``Contributor Covenant'', which was adapted from
15@url{http://contributor-covenant.org/}. You can find a local version in
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.
26* Coding Style:: Hygiene of the contributor.
27* Submitting Patches:: Share your work.
28@end menu
29
30@node Building from Git
31@section Building from Git
32
33If you want to hack Guix itself, it is recommended to use the latest
dbfcadfc
LC
34version from the Git repository:
35
36@example
37git clone https://git.savannah.gnu.org/git/guix.git
38@end example
39
40When building Guix from a checkout,
8c01b9d0
ML
41the following packages are required in addition to those mentioned in
42the installation instructions (@pxref{Requirements}).
43
44@itemize
45@item @url{http://gnu.org/software/autoconf/, GNU Autoconf};
46@item @url{http://gnu.org/software/automake/, GNU Automake};
47@item @url{http://gnu.org/software/gettext/, GNU Gettext};
0431ed00 48@item @url{http://gnu.org/software/texinfo/, GNU Texinfo};
8c01b9d0
ML
49@item @url{http://www.graphviz.org/, Graphviz};
50@item @url{http://www.gnu.org/software/help2man/, GNU Help2man (optional)}.
51@end itemize
52
5fb95cc5
LC
53The easiest way to set up a development environment for Guix is, of
54course, by using Guix! The following command starts a new shell where
55all the dependencies and appropriate environment variables are set up to
56hack on Guix:
8c01b9d0 57
5fb95cc5
LC
58@example
59guix environment guix
60@end example
61
62@xref{Invoking guix environment}, for more information on that command.
63Extra dependencies can be added with @option{--ad-hoc}:
64
65@example
66guix environment guix --ad-hoc help2man git strace
67@end example
68
69Run @command{./bootstrap} to generate the build system infrastructure
70using Autoconf and Automake. If you get an error like this one:
8c01b9d0
ML
71
72@example
73configure.ac:46: error: possibly undefined macro: PKG_CHECK_MODULES
74@end example
75
5fb95cc5 76@noindent
8c01b9d0 77it probably means that Autoconf couldn’t find @file{pkg.m4}, which is
5fb95cc5
LC
78provided by pkg-config. Make sure that @file{pkg.m4} is available. The
79same holds for the @file{guile.m4} set of macros provided by Guile. For
80instance, if you installed Automake in @file{/usr/local}, it wouldn’t
81look for @file{.m4} files in @file{/usr/share}. In that case, you have
82to invoke the following command:
8c01b9d0
ML
83
84@example
85export ACLOCAL_PATH=/usr/share/aclocal
86@end example
87
aabe6d38 88@xref{Macro Search Path,,, automake, The GNU Automake Manual}, for
8c01b9d0
ML
89more information.
90
3a25c631
LC
91Then, run @command{./configure} as usual. Make sure to pass
92@code{--localstatedir=@var{directory}} where @var{directory} is the
93@code{localstatedir} value used by your current installation (@pxref{The
94Store}, for information about this).
8c01b9d0 95
3a25c631
LC
96Finally, you have to invoke @code{make check} to run tests
97(@pxref{Running the Test Suite}). If anything
8c01b9d0
ML
98fails, take a look at installation instructions (@pxref{Installation})
99or send a message to the @email{guix-devel@@gnu.org, mailing list}.
100
101
102@node Running Guix Before It Is Installed
103@section Running Guix Before It Is Installed
104
105In order to keep a sane working environment, you will find it useful to
106test the changes made in your local source tree checkout without
107actually installing them. So that you can distinguish between your
108``end-user'' hat and your ``motley'' costume.
109
110To that end, all the command-line tools can be used even if you have not
111run @code{make install}. To do that, prefix each command with
112@command{./pre-inst-env} (the @file{pre-inst-env} script lives in the
73a20345 113top build tree of Guix), as in:
8c01b9d0
ML
114
115@example
73a20345 116$ sudo ./pre-inst-env guix-daemon --build-users-group=guixbuild
8c01b9d0
ML
117$ ./pre-inst-env guix build hello
118@end example
119
120@noindent
121Similarly, for a Guile session using the Guix modules:
122
123@example
124$ ./pre-inst-env guile -c '(use-modules (guix utils)) (pk (%current-system))'
96856613
LC
125
126;;; ("x86_64-linux")
127@end example
128
129@noindent
130@cindex REPL
131@cindex read-eval-print loop
132@dots{} and for a REPL (@pxref{Using Guile Interactively,,, guile, Guile
133Reference Manual}):
134
135@example
136$ ./pre-inst-env guile
137scheme@@(guile-user)> ,use(guix)
138scheme@@(guile-user)> ,use(gnu)
139scheme@@(guile-user)> (define snakes
140 (fold-packages
141 (lambda (package lst)
142 (if (string-prefix? "python"
143 (package-name package))
144 (cons package lst)
145 lst))
146 '()))
147scheme@@(guile-user)> (length snakes)
148$1 = 361
8c01b9d0
ML
149@end example
150
151The @command{pre-inst-env} script sets up all the environment variables
152necessary to support this, including @env{PATH} and @env{GUILE_LOAD_PATH}.
153
ef54b61d
AV
154Note that @command{./pre-inst-env guix pull} does @emph{not} upgrade the
155local source tree; it simply updates the @file{~/.config/guix/latest}
156symlink (@pxref{Invoking guix pull}). Run @command{git pull} instead if
b5f990a6
CAW
157you want to upgrade your local source tree.@footnote{If you would like
158to set up @command{guix} to use your Git checkout, you can point the
159@file{~/.config/guix/latest} symlink to your Git checkout directory.
160If you are the sole user of your system, you may also consider pointing
161the @file{/root/.config/guix/latest} symlink to point to
162@file{~/.config/guix/latest}; this way it will always use the same
163@command{guix} as your user does.}
ef54b61d 164
8c01b9d0
ML
165
166@node The Perfect Setup
167@section The Perfect Setup
168
169The Perfect Setup to hack on Guix is basically the perfect setup used
170for Guile hacking (@pxref{Using Guile in Emacs,,, guile, Guile Reference
171Manual}). First, you need more than an editor, you need
172@url{http://www.gnu.org/software/emacs, Emacs}, empowered by the
173wonderful @url{http://nongnu.org/geiser/, Geiser}.
174
175Geiser allows for interactive and incremental development from within
176Emacs: code compilation and evaluation from within buffers, access to
177on-line documentation (docstrings), context-sensitive completion,
178@kbd{M-.} to jump to an object definition, a REPL to try out your code,
179and more (@pxref{Introduction,,, geiser, Geiser User Manual}). For
180convenient Guix development, make sure to augment Guile’s load path so
181that it finds source files from your checkout:
182
183@lisp
184;; @r{Assuming the Guix checkout is in ~/src/guix.}
bb38ece4
AK
185(with-eval-after-load 'geiser-guile
186 (add-to-list 'geiser-guile-load-path "~/src/guix"))
8c01b9d0
ML
187@end lisp
188
189To actually edit the code, Emacs already has a neat Scheme mode. But in
190addition to that, you must not miss
191@url{http://www.emacswiki.org/emacs/ParEdit, Paredit}. It provides
192facilities to directly operate on the syntax tree, such as raising an
193s-expression or wrapping it, swallowing or rejecting the following
194s-expression, etc.
195
196
197@node Coding Style
198@section Coding Style
199
200In general our code follows the GNU Coding Standards (@pxref{Top,,,
201standards, GNU Coding Standards}). However, they do not say much about
202Scheme, so here are some additional rules.
203
204@menu
205* Programming Paradigm:: How to compose your elements.
206* Modules:: Where to store your code?
207* Data Types and Pattern Matching:: Implementing data structures.
208* Formatting Code:: Writing conventions.
209@end menu
210
211@node Programming Paradigm
212@subsection Programming Paradigm
213
214Scheme code in Guix is written in a purely functional style. One
215exception is code that involves input/output, and procedures that
216implement low-level concepts, such as the @code{memoize} procedure.
217
218@node Modules
219@subsection Modules
220
221Guile modules that are meant to be used on the builder side must live in
222the @code{(guix build @dots{})} name space. They must not refer to
223other Guix or GNU modules. However, it is OK for a ``host-side'' module
224to use a build-side module.
225
226Modules that deal with the broader GNU system should be in the
227@code{(gnu @dots{})} name space rather than @code{(guix @dots{})}.
228
229@node Data Types and Pattern Matching
230@subsection Data Types and Pattern Matching
231
232The tendency in classical Lisp is to use lists to represent everything,
233and then to browse them ``by hand'' using @code{car}, @code{cdr},
234@code{cadr}, and co. There are several problems with that style,
235notably the fact that it is hard to read, error-prone, and a hindrance
236to proper type error reports.
237
238Guix code should define appropriate data types (for instance, using
239@code{define-record-type*}) rather than abuse lists. In addition, it
240should use pattern matching, via Guile’s @code{(ice-9 match)} module,
241especially when matching lists.
242
243@node Formatting Code
244@subsection Formatting Code
245
7bb2b10c
LC
246@cindex formatting code
247@cindex coding style
8c01b9d0
ML
248When writing Scheme code, we follow common wisdom among Scheme
249programmers. In general, we follow the
250@url{http://mumble.net/~campbell/scheme/style.txt, Riastradh's Lisp
251Style Rules}. This document happens to describe the conventions mostly
252used in Guile’s code too. It is very thoughtful and well written, so
253please do read it.
254
255Some special forms introduced in Guix, such as the @code{substitute*}
256macro, have special indentation rules. These are defined in the
8ca0c88a
AK
257@file{.dir-locals.el} file, which Emacs automatically uses. Also note
258that Emacs-Guix provides @code{guix-devel-mode} mode that indents and
259highlights Guix code properly (@pxref{Development,,, emacs-guix, The
260Emacs-Guix Reference Manual}).
7bb2b10c
LC
261
262@cindex indentation, of code
263@cindex formatting, of code
264If you do not use Emacs, please make sure to let your editor knows these
265rules. To automatically indent a package definition, you can also run:
266
267@example
557d9c8d 268./etc/indent-code.el gnu/packages/@var{file}.scm @var{package}
7bb2b10c
LC
269@end example
270
271@noindent
272This automatically indents the definition of @var{package} in
557d9c8d
LC
273@file{gnu/packages/@var{file}.scm} by running Emacs in batch mode. To
274indent a whole file, omit the second argument:
275
276@example
277./etc/indent-code.el gnu/services/@var{file}.scm
278@end example
8c01b9d0
ML
279
280We require all top-level procedures to carry a docstring. This
281requirement can be relaxed for simple private procedures in the
282@code{(guix build @dots{})} name space, though.
283
284Procedures should not have more than four positional parameters. Use
285keyword parameters for procedures that take more than four parameters.
286
287
288@node Submitting Patches
289@section Submitting Patches
290
291Development is done using the Git distributed version control system.
292Thus, access to the repository is not strictly necessary. We welcome
293contributions in the form of patches as produced by @code{git
230efa87
LC
294format-patch} sent to the @email{guix-patches@@gnu.org} mailing list.
295
296This mailing list is backed by a Debbugs instance accessible at
297@uref{https://bugs.gnu.org/guix-patches}, which allows us to keep track
298of submissions. Each message sent to that mailing list gets a new
299tracking number assigned; people can then follow up on the submission by
300sending email to @code{@var{NNN}@@debbugs.gnu.org}, where @var{NNN} is
5a183a1e 301the tracking number (@pxref{Sending a Patch Series}).
230efa87 302
8c01b9d0
ML
303Please write commit logs in the ChangeLog format (@pxref{Change Logs,,,
304standards, GNU Coding Standards}); you can check the commit history for
305examples.
306
307Before submitting a patch that adds or modifies a package definition,
fcc58db6
LC
308please run through this check list:
309
310@enumerate
308c08d3
RW
311@item
312If the authors of the packaged software provide a cryptographic
313signature for the release tarball, make an effort to verify the
314authenticity of the archive. For a detached GPG signature file this
315would be done with the @code{gpg --verify} command.
316
cbd02397
LC
317@item
318Take some time to provide an adequate synopsis and description for the
319package. @xref{Synopses and Descriptions}, for some guidelines.
320
fcc58db6
LC
321@item
322Run @code{guix lint @var{package}}, where @var{package} is the
8c01b9d0 323name of the new or modified package, and fix any errors it reports
fcc58db6
LC
324(@pxref{Invoking guix lint}).
325
326@item
327Make sure the package builds on your platform, using @code{guix build
328@var{package}}.
329
d222522e
LC
330@item
331@cindex bundling
332Make sure the package does not use bundled copies of software already
333available as separate packages.
334
335Sometimes, packages include copies of the source code of their
336dependencies as a convenience for users. However, as a distribution, we
337want to make sure that such packages end up using the copy we already
338have in the distribution, if there is one. This improves resource usage
339(the dependency is built and stored only once), and allows the
340distribution to make transverse changes such as applying security
341updates for a given software package in a single place and have them
342affect the whole system---something that bundled copies prevent.
343
fcc58db6
LC
344@item
345Take a look at the profile reported by @command{guix size}
346(@pxref{Invoking guix size}). This will allow you to notice references
347to other packages unwillingly retained. It may also help determine
348whether to split the package (@pxref{Packages with Multiple Outputs}),
349and which optional dependencies should be used.
350
351@item
352For important changes, check that dependent package (if applicable) are
353not affected by the change; @code{guix refresh --list-dependent
8c01b9d0
ML
354@var{package}} will help you do that (@pxref{Invoking guix refresh}).
355
916b5eba
LC
356@c See <https://lists.gnu.org/archive/html/guix-devel/2016-10/msg00933.html>.
357@cindex branching strategy
358@cindex rebuild scheduling strategy
359Depending on the number of dependent packages and thus the amount of
360rebuilding induced, commits go to different branches, along these lines:
361
362@table @asis
363@item 300 dependent packages or less
364@code{master} branch (non-disruptive changes).
365
366@item between 300 and 1,200 dependent packages
367@code{staging} branch (non-disruptive changes). This branch is intended
368to be merged in @code{master} every 3 weeks or so. Topical changes
369(e.g., an update of the GNOME stack) can instead go to a specific branch
370(say, @code{gnome-updates}).
371
372@item more than 1,200 dependent packages
373@code{core-updates} branch (may include major and potentially disruptive
374changes). This branch is intended to be merged in @code{master} every
3752.5 months or so.
376@end table
377
378All these branches are tracked by our build farm
379and merged into @code{master} once
189b1543
LC
380everything has been successfully built. This allows us to fix issues
381before they hit users, and to reduce the window during which pre-built
382binaries are not available.
383
d23c20f1 384@item
5b74fe06
LC
385@cindex determinism, of build processes
386@cindex reproducible builds, checking
d23c20f1
LC
387Check whether the package's build process is deterministic. This
388typically means checking whether an independent build of the package
389yields the exact same result that you obtained, bit for bit.
390
5b74fe06
LC
391A simple way to do that is by building the same package several times in
392a row on your machine (@pxref{Invoking guix build}):
393
394@example
395guix build --rounds=2 my-package
396@end example
397
398This is enough to catch a class of common non-determinism issues, such
399as timestamps or randomly-generated output in the build result.
400
401Another option is to use @command{guix challenge} (@pxref{Invoking guix
402challenge}). You may run it once the package has been committed and
403built by @code{hydra.gnu.org} to check whether it obtains the same
404result as you did. Better yet: Find another machine that can build it
405and run @command{guix publish}. Since the remote build machine is
406likely different from yours, this can catch non-determinism issues
407related to the hardware---e.g., use of different instruction set
408extensions---or to the operating system kernel---e.g., reliance on
409@code{uname} or @file{/proc} files.
d23c20f1 410
3c2d03a2
LC
411@item
412When writing documentation, please use gender-neutral wording when
413referring to people, such as
414@uref{https://en.wikipedia.org/wiki/Singular_they, singular
415``they''@comma{} ``their''@comma{} ``them''}, and so forth.
416
3a78fab8 417@item
418Verify that your patch contains only one set of related changes.
419Bundling unrelated changes together makes reviewing harder and slower.
420
421Examples of unrelated changes include the addition of several packages,
422or a package update along with fixes to that package.
423
7bb2b10c
LC
424@item
425Please follow our code formatting rules, possibly running the
557d9c8d 426@command{etc/indent-code.el} script to do that automatically for you
7bb2b10c
LC
427(@pxref{Formatting Code}).
428
fcc58db6
LC
429@end enumerate
430
a40424bd
CM
431When posting a patch to the mailing list, use @samp{[PATCH] @dots{}} as
432a subject. You may use your email client or the @command{git
5a183a1e
JN
433send-email} command (@pxref{Sending a Patch Series}). We prefer to get
434patches in plain text messages, either inline or as MIME attachments.
435You are advised to pay attention if your email client changes anything
436like line breaks or indentation which could potentially break the
437patches.
438
4619b59c
JN
439When a bug is resolved, please close the thread by sending an email to
440@email{@var{NNN}-done@@debbugs.gnu.org}.
441
5a183a1e
JN
442@unnumberedsubsec Sending a Patch Series
443@anchor{Sending a Patch Series}
444@cindex patch series
445@cindex @code{git send-email}
446@cindex @code{git-send-email}
447
448When sending a patch series (e.g., using @code{git send-email}), please
449first send one message to @email{guix-patches@@gnu.org}, and then send
450subsequent patches to @email{@var{NNN}@@debbugs.gnu.org} to make sure
451they are kept together. See
452@uref{https://debbugs.gnu.org/Advanced.html, the Debbugs documentation}
453for more information.
454@c Debbugs bug: https://debbugs.gnu.org/db/15/15361.html