gnu: Add dosfstools.
[jackhill/guix/guix.git] / HACKING
CommitLineData
450ccdc3
LC
1-*- mode: org; coding: utf-8; -*-
2
08ba7ff3 3#+TITLE: Hacking GNU Guix and Its Incredible Distro
450ccdc3 4
5ff3c4b8 5Copyright © 2012, 2013, 2014 Ludovic Courtès <ludo@gnu.org>
84dbbc76 6Copyright © 2013 Nikita Karetnikov <nikita@karetnikov.org>
5ff3c4b8 7Copyright © 2014 Pierre-Antoine Rault <par@rigelk.eu>
450ccdc3
LC
8
9 Copying and distribution of this file, with or without modification,
10 are permitted in any medium without royalty provided the copyright
11 notice and this notice are preserved.
12
13
84dbbc76
NK
14* Building from Git
15
8b2d9e5d
LC
16When building Guix from a checkout, the following packages are required in
17addition to those mentioned in the installation instructions:
18
19 - [[http://www.gnu.org/software/autoconf/][GNU Autoconf]]
20 - [[http://www.gnu.org/software/automake/][GNU Automake]]
21 - [[http://www.gnu.org/software/gettext/][GNU Gettext]]
22 - [[http://www.graphviz.org/][Graphviz]]
23
24Run ‘./bootstrap’ to download the Nix daemon source code and to generate the
25build system infrastructure using autoconf. It reports an error if an
26inappropriate version of the above packages is being used.
27
25ed6edb 28If you get an error like this one:
84dbbc76 29
25ed6edb 30 configure.ac:46: error: possibly undefined macro: PKG_CHECK_MODULES
84dbbc76
NK
31
32it probably means that Autoconf couldn’t find ‘pkg.m4’, which is provided by
33pkg-config. Make sure that ‘pkg.m4’ is available. For instance, if you
34installed Automake in ‘/usr/local’, it wouldn’t look for ‘.m4’ files in
35‘/usr/share’. So you have to invoke the following command in that case
36
37 $ export ACLOCAL_PATH=/usr/share/aclocal
38
39See “info '(automake) Macro Search Path'” for more information.
40
25ed6edb
LC
41Then, run ‘./configure’ as usual.
42
84dbbc76
NK
43Finally, you have to invoke ‘make check’ to run tests. If anything fails,
44take a look at “info '(guix) Installation'” or send a message to
8b2d9e5d 45<guix-devel@gnu.org>.
84dbbc76 46
08ba7ff3
LC
47* Running Guix before it is installed
48
49Command-line tools can be used even if you have not run "make install".
50To do that, prefix each command with ‘./pre-inst-env’, as in:
51
9bf3c1a7 52 ./pre-inst-env guix build --help
08ba7ff3
LC
53
54Similarly, for a Guile session using the Guix modules:
55
56 ./pre-inst-env guile -c '(use-modules (guix utils)) (pk (%current-system))'
57
58The ‘pre-inst-env’ script sets up all the environment variables
59necessary to support this.
60
c6dbd505
LC
61* The Perfect Setup
62
63The Perfect Setup to hack on Guix is basically the perfect setup used
64for Guile hacking (info "(guile) Using Guile in Emacs"). First, you
65need more than an editor, you need [[http://www.gnu.org/software/emacs][Emacs]], empowered by the wonderful
66[[http://nongnu.org/geiser/][Geiser]].
67
68Geiser allows for interactive and incremental development from within
69Emacs: code compilation and evaluation from within buffers, access to
70on-line documentation (docstrings), context-sensitive completion, M-. to
71jump to an object definition, a REPL to try out your code, and more.
72
73To actually edit the code, Emacs already has a neat Scheme mode. But in
74addition to that, you must not miss [[http://www.emacswiki.org/emacs/ParEdit][Paredit]]. It provides facilities to
75directly operate on the syntax tree, such as raising an s-expression or
76wrapping it, swallowing or rejecting the following s-expression, etc.
77
9bf3c1a7
LC
78* Submitting Patches
79
80Development is done using the Git distributed version control system. Thus,
81access to the repository is not strictly necessary. We welcome contributions
82in the form of patches as produced by ‘git format-patch’ sent to
5ff3c4b8
PAR
83guix-devel@gnu.org. Please write commit logs in the [[http://www.gnu.org/prep/standards/html_node/Change-Logs.html#Change-Logs][GNU ChangeLog
84format]]; you can check the commit history for examples.
85
141360b5
LC
86Before submitting a patch that adds or modifies a package definition, please
87run ‘guix lint PACKAGE’, where PACKAGE is the name of the new or modified
88package, and fix any errors it reports. In addition, please make sure the
89package builds on your platform, using ‘guix build’. You may also want to
90check that dependent package (if applicable) are not affected by the change;
91‘guix refresh --list-dependent PACKAGE’ will help you do that.
92
5ff3c4b8
PAR
93When posting a patch to the mailing list, use "[PATCH] ..." as a subject. You
94may use your email client or the ‘git send-mail’ command.
9bf3c1a7
LC
95
96As you become a regular contributor, you may find it convenient to have write
97access to the repository (see below.)
98
e1c5a835
LC
99* Coding Style
100
101In general our code follows the [[info:standards][GNU Coding Standards]] (GCS). However, the GCS
102do not say much about Scheme, so here are some additional rules.
103
104** Programming Paradigm
105
106Scheme code in Guix is written in a purely functional style. One exception is
107code that involves input/output, and procedures that implement low-level
108concepts, such as the ‘memoize’ procedure.
109
110** Modules
111
112Guile modules that are meant to be used on the builder side must live in the
113(guix build …) name space. They must not refer to other Guix or GNU modules.
114However, it is OK for a “host-side” module to use a build-side module.
115
116Modules that deal with the broader GNU system should be in the (gnu …) name
117space rather than (guix …).
118
2df74ac1
LC
119** Data Types and Pattern Matching
120
121The tendency in classical Lisp is to use lists to represent everything, and
122then to browse them “by hand” using ‘car’, ‘cdr’, ‘cadr’, and co. There are
123several problems with that style, notably the fact that it is hard to read,
124error-prone, and a hindrance to proper type error reports.
125
126Guix code should define appropriate data types (for instance, using
127‘define-record-type*’) rather than abuse lists. In addition, it should use
128pattern matching, via Guile’s (ice-9 match) module, especially when matching
129lists.
130
e1c5a835
LC
131** Formatting Code
132
133When writing Scheme code, we follow common wisdom among Scheme programmers.
134In general, we follow the [[http://mumble.net/~campbell/scheme/style.txt][Riastradh's Lisp Style Rules]]. This document happens
135to describe the conventions mostly used in Guile’s code too. It is very
136thoughtful and well written, so please do read it.
137
1a2e6495
LC
138Some special forms introduced in Guix, such as the ‘substitute*’ macro, have
139special indentation rules. These are defined in the .dir-locals.el file,
140which Emacs automatically uses. If you do not use Emacs, please make sure to
141let your editor know the rules.
142
143We require all top-level procedures to carry a docstring. This requirement
144can be relaxed for simple private procedures in the (guix build …) name space,
145though.
e1c5a835
LC
146
147Procedures should not have more than four positional parameters. Use keyword
148parameters for procedures that take more than four parameters.
149
9bf3c1a7
LC
150* Commit Access
151
152For frequent contributors, having write access to the repository is
153convenient. When you deem it necessary, feel free to ask for it on the
154mailing list. When you get commit access, please make sure to follow the
2d2ad989 155policy below (discussions of the policy can take place on guix-devel@gnu.org.)
9bf3c1a7 156
2d2ad989 157Non-trivial patches should always be posted to guix-devel@gnu.org (trivial
9bf3c1a7
LC
158patches include fixing typos, etc.)
159
160For patches that just add a new package, and a simple one, it’s OK to commit,
e20ec9cc
LC
161if you’re confident (which means you successfully built it in a chroot setup,
162and have done a reasonable copyright and license auditing.) Likewise for
d0c64188
LC
163package upgrades, except upgrades that trigger a lot of rebuilds (for example,
164upgrading GnuTLS or GLib.) We have a mailing list for commit notifications
e20ec9cc
LC
165(guix-commits@gnu.org), so people can notice. Before pushing your changes,
166make sure to run ‘git pull --rebase’.
9bf3c1a7 167
2d2ad989 168For anything else, please post to guix-devel@gnu.org and leave time for a
9bf3c1a7
LC
169review, without committing anything. If you didn’t receive any reply
170after two weeks, and if you’re confident, it’s OK to commit.
171
172That last part is subject to being adjusted, allowing individuals to commit
173directly on non-controversial changes on parts they’re familiar with.