gnu: Add Synfig Studio.
[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
10@menu
11* Building from Git:: The latest and greatest.
12* Running Guix Before It Is Installed:: Hacker tricks.
13* The Perfect Setup:: The right tools.
14* Coding Style:: Hygiene of the contributor.
15* Submitting Patches:: Share your work.
16@end menu
17
18@node Building from Git
19@section Building from Git
20
21If you want to hack Guix itself, it is recommended to use the latest
22version from the Git repository. When building Guix from a checkout,
23the following packages are required in addition to those mentioned in
24the installation instructions (@pxref{Requirements}).
25
26@itemize
27@item @url{http://gnu.org/software/autoconf/, GNU Autoconf};
28@item @url{http://gnu.org/software/automake/, GNU Automake};
29@item @url{http://gnu.org/software/gettext/, GNU Gettext};
0431ed00 30@item @url{http://gnu.org/software/texinfo/, GNU Texinfo};
8c01b9d0
ML
31@item @url{http://www.graphviz.org/, Graphviz};
32@item @url{http://www.gnu.org/software/help2man/, GNU Help2man (optional)}.
33@end itemize
34
35Run @command{./bootstrap} to download the Nix daemon source code and to
36generate the build system infrastructure using autoconf. It reports an
37error if an inappropriate version of the above packages is being used.
38
39@noindent
40If you get an error like this one:
41
42@example
43configure.ac:46: error: possibly undefined macro: PKG_CHECK_MODULES
44@end example
45
46it probably means that Autoconf couldn’t find @file{pkg.m4}, which is
47provided by @command{pkg-config}. Make sure that @file{pkg.m4} is
48available. For instance, if you installed Automake in
49@file{/usr/local}, it wouldn’t look for @file{.m4} files in
50@file{/usr/share}. So you have to invoke the following command in that
51case
52
53@example
54export ACLOCAL_PATH=/usr/share/aclocal
55@end example
56
57See @pxref{Macro Search Path,,, automake, The GNU Automake Manual} for
58more information.
59
60Then, run @command{./configure} as usual.
61
62Finally, you have to invoke @code{make check} to run tests. If anything
63fails, take a look at installation instructions (@pxref{Installation})
64or send a message to the @email{guix-devel@@gnu.org, mailing list}.
65
66
67@node Running Guix Before It Is Installed
68@section Running Guix Before It Is Installed
69
70In order to keep a sane working environment, you will find it useful to
71test the changes made in your local source tree checkout without
72actually installing them. So that you can distinguish between your
73``end-user'' hat and your ``motley'' costume.
74
75To that end, all the command-line tools can be used even if you have not
76run @code{make install}. To do that, prefix each command with
77@command{./pre-inst-env} (the @file{pre-inst-env} script lives in the
78top build tree of Guix), as in:
79
80@example
81$ sudo ./pre-inst-env guix-daemon --build-users-group=guixbuild
82$ ./pre-inst-env guix build hello
83@end example
84
85@noindent
86Similarly, for a Guile session using the Guix modules:
87
88@example
89$ ./pre-inst-env guile -c '(use-modules (guix utils)) (pk (%current-system))'
96856613
LC
90
91;;; ("x86_64-linux")
92@end example
93
94@noindent
95@cindex REPL
96@cindex read-eval-print loop
97@dots{} and for a REPL (@pxref{Using Guile Interactively,,, guile, Guile
98Reference Manual}):
99
100@example
101$ ./pre-inst-env guile
102scheme@@(guile-user)> ,use(guix)
103scheme@@(guile-user)> ,use(gnu)
104scheme@@(guile-user)> (define snakes
105 (fold-packages
106 (lambda (package lst)
107 (if (string-prefix? "python"
108 (package-name package))
109 (cons package lst)
110 lst))
111 '()))
112scheme@@(guile-user)> (length snakes)
113$1 = 361
8c01b9d0
ML
114@end example
115
116The @command{pre-inst-env} script sets up all the environment variables
117necessary to support this, including @env{PATH} and @env{GUILE_LOAD_PATH}.
118
ef54b61d
AV
119Note that @command{./pre-inst-env guix pull} does @emph{not} upgrade the
120local source tree; it simply updates the @file{~/.config/guix/latest}
121symlink (@pxref{Invoking guix pull}). Run @command{git pull} instead if
122you want to upgrade your local source tree.
123
8c01b9d0
ML
124
125@node The Perfect Setup
126@section The Perfect Setup
127
128The Perfect Setup to hack on Guix is basically the perfect setup used
129for Guile hacking (@pxref{Using Guile in Emacs,,, guile, Guile Reference
130Manual}). First, you need more than an editor, you need
131@url{http://www.gnu.org/software/emacs, Emacs}, empowered by the
132wonderful @url{http://nongnu.org/geiser/, Geiser}.
133
134Geiser allows for interactive and incremental development from within
135Emacs: code compilation and evaluation from within buffers, access to
136on-line documentation (docstrings), context-sensitive completion,
137@kbd{M-.} to jump to an object definition, a REPL to try out your code,
138and more (@pxref{Introduction,,, geiser, Geiser User Manual}). For
139convenient Guix development, make sure to augment Guile’s load path so
140that it finds source files from your checkout:
141
142@lisp
143;; @r{Assuming the Guix checkout is in ~/src/guix.}
144(add-to-list 'geiser-guile-load-path "~/src/guix")
145@end lisp
146
147To actually edit the code, Emacs already has a neat Scheme mode. But in
148addition to that, you must not miss
149@url{http://www.emacswiki.org/emacs/ParEdit, Paredit}. It provides
150facilities to directly operate on the syntax tree, such as raising an
151s-expression or wrapping it, swallowing or rejecting the following
152s-expression, etc.
153
187f80c6
AK
154GNU Guix also comes with a minor mode that provides some additional
155functionality for Scheme buffers (@pxref{Emacs Development}).
156
8c01b9d0
ML
157
158@node Coding Style
159@section Coding Style
160
161In general our code follows the GNU Coding Standards (@pxref{Top,,,
162standards, GNU Coding Standards}). However, they do not say much about
163Scheme, so here are some additional rules.
164
165@menu
166* Programming Paradigm:: How to compose your elements.
167* Modules:: Where to store your code?
168* Data Types and Pattern Matching:: Implementing data structures.
169* Formatting Code:: Writing conventions.
170@end menu
171
172@node Programming Paradigm
173@subsection Programming Paradigm
174
175Scheme code in Guix is written in a purely functional style. One
176exception is code that involves input/output, and procedures that
177implement low-level concepts, such as the @code{memoize} procedure.
178
179@node Modules
180@subsection Modules
181
182Guile modules that are meant to be used on the builder side must live in
183the @code{(guix build @dots{})} name space. They must not refer to
184other Guix or GNU modules. However, it is OK for a ``host-side'' module
185to use a build-side module.
186
187Modules that deal with the broader GNU system should be in the
188@code{(gnu @dots{})} name space rather than @code{(guix @dots{})}.
189
190@node Data Types and Pattern Matching
191@subsection Data Types and Pattern Matching
192
193The tendency in classical Lisp is to use lists to represent everything,
194and then to browse them ``by hand'' using @code{car}, @code{cdr},
195@code{cadr}, and co. There are several problems with that style,
196notably the fact that it is hard to read, error-prone, and a hindrance
197to proper type error reports.
198
199Guix code should define appropriate data types (for instance, using
200@code{define-record-type*}) rather than abuse lists. In addition, it
201should use pattern matching, via Guile’s @code{(ice-9 match)} module,
202especially when matching lists.
203
204@node Formatting Code
205@subsection Formatting Code
206
207When writing Scheme code, we follow common wisdom among Scheme
208programmers. In general, we follow the
209@url{http://mumble.net/~campbell/scheme/style.txt, Riastradh's Lisp
210Style Rules}. This document happens to describe the conventions mostly
211used in Guile’s code too. It is very thoughtful and well written, so
212please do read it.
213
214Some special forms introduced in Guix, such as the @code{substitute*}
215macro, have special indentation rules. These are defined in the
216@file{.dir-locals.el} file, which Emacs automatically uses. If you do
217not use Emacs, please make sure to let your editor know the rules.
218
219We require all top-level procedures to carry a docstring. This
220requirement can be relaxed for simple private procedures in the
221@code{(guix build @dots{})} name space, though.
222
223Procedures should not have more than four positional parameters. Use
224keyword parameters for procedures that take more than four parameters.
225
226
227@node Submitting Patches
228@section Submitting Patches
229
230Development is done using the Git distributed version control system.
231Thus, access to the repository is not strictly necessary. We welcome
232contributions in the form of patches as produced by @code{git
233format-patch} sent to the @email{guix-devel@@gnu.org, mailing list}.
234Please write commit logs in the ChangeLog format (@pxref{Change Logs,,,
235standards, GNU Coding Standards}); you can check the commit history for
236examples.
237
238Before submitting a patch that adds or modifies a package definition,
fcc58db6
LC
239please run through this check list:
240
241@enumerate
cbd02397
LC
242@item
243Take some time to provide an adequate synopsis and description for the
244package. @xref{Synopses and Descriptions}, for some guidelines.
245
fcc58db6
LC
246@item
247Run @code{guix lint @var{package}}, where @var{package} is the
8c01b9d0 248name of the new or modified package, and fix any errors it reports
fcc58db6
LC
249(@pxref{Invoking guix lint}).
250
251@item
252Make sure the package builds on your platform, using @code{guix build
253@var{package}}.
254
255@item
256Take a look at the profile reported by @command{guix size}
257(@pxref{Invoking guix size}). This will allow you to notice references
258to other packages unwillingly retained. It may also help determine
259whether to split the package (@pxref{Packages with Multiple Outputs}),
260and which optional dependencies should be used.
261
262@item
263For important changes, check that dependent package (if applicable) are
264not affected by the change; @code{guix refresh --list-dependent
8c01b9d0
ML
265@var{package}} will help you do that (@pxref{Invoking guix refresh}).
266
d23c20f1
LC
267@item
268Check whether the package's build process is deterministic. This
269typically means checking whether an independent build of the package
270yields the exact same result that you obtained, bit for bit.
271
272A simple way to do that is with @command{guix challenge}
273(@pxref{Invoking guix challenge}). You may run it once the package has
274been committed and built by @code{hydra.gnu.org} to check whether it
275obtains the same result as you did. Better yet: Find another machine
276that can build it and run @command{guix publish}.
277
fcc58db6
LC
278@end enumerate
279
8c01b9d0
ML
280When posting a patch to the mailing list, use @samp{[PATCH] @dots{}} as a
281subject. You may use your email client or the @command{git send-mail}
282command.