Update NEWS.
[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
9149f1a0 5Copyright © 2012, 2013 Ludovic Courtès <ludo@gnu.org>
84dbbc76 6Copyright © 2013 Nikita Karetnikov <nikita@karetnikov.org>
450ccdc3
LC
7
8 Copying and distribution of this file, with or without modification,
9 are permitted in any medium without royalty provided the copyright
10 notice and this notice are preserved.
11
12
84dbbc76
NK
13* Building from Git
14
15First, make sure that Autoconf (>= 2.69), Automake, and pkg-config are
16installed. Run ‘./bootstrap’ that, among other things, invokes ‘git submodule
17update’, or you might get the following error
18
19 make: *** No rule to make target `nix/libstore/schema.sql', needed by
20 `nix/libstore/schema.sql.hh'
21
22Then, as always, run ‘./configure’. If you get an error like this one
23
24 ./configure: line 6755: `PKG_CHECK_MODULES(GUILE, guile-2.0 >= 2.0.5)'
25
26it probably means that Autoconf couldn’t find ‘pkg.m4’, which is provided by
27pkg-config. Make sure that ‘pkg.m4’ is available. For instance, if you
28installed Automake in ‘/usr/local’, it wouldn’t look for ‘.m4’ files in
29‘/usr/share’. So you have to invoke the following command in that case
30
31 $ export ACLOCAL_PATH=/usr/share/aclocal
32
33See “info '(automake) Macro Search Path'” for more information.
34
35After that you should proceed with ‘make’. You might also get this error
36
37 /bin/bash: dot: command not found
38 make[2]: *** [doc/images/bootstrap-graph.png] Error 127
39
40This one is easy to handle; just install Graphviz. It is not listed as a
41requirement because the resulting images should come with a tarball.
42
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
45<bug-guix@gnu.org>.
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
59b775cc
LC
78* Adding new packages
79
80Package recipes in Guix look like this:
81
82#+BEGIN_SRC scheme
83 (package
84 (name "nettle")
85 (version "2.5")
86 (source
87 (origin
3dc1970d
LC
88 (method url-fetch)
89 (uri (string-append "mirror://gnu/nettle/nettle-"
59b775cc
LC
90 version ".tar.gz"))
91 (sha256
92 (base32
93 "0wicr7amx01l03rm0pzgr1qvw3f9blaw17vjsy1301dh13ll58aa"))))
94 (build-system gnu-build-system)
08ba7ff3 95 (inputs `(("m4" ,m4)))
59b775cc
LC
96 (propagated-inputs `(("gmp" ,gmp)))
97 (home-page
98 "http://www.lysator.liu.se/~nisse/nettle/")
99 (synopsis "GNU Nettle, a cryptographic library")
100 (description
101 "Nettle is a cryptographic library...")
08ba7ff3 102 (license gpl2+))
59b775cc
LC
103#+END_SRC
104
105Such a recipe can be written by hand, and then tested by running
9bf3c1a7 106‘./pre-inst-env guix build nettle’.
59b775cc
LC
107
108When writing the recipe, the base32-encoded SHA256 hash of the source
109code tarball, which can be seen in the example above, can be obtained by
110running:
111
9bf3c1a7 112 guix download http://ftp.gnu.org/gnu/nettle/nettle-2.5.tar.gz
59b775cc
LC
113
114Alternatively, it is possible to semi-automatically import recipes from
115the [[http://nixos.org/nixpkgs/][Nixpkgs]] software distribution using this command:
116
9bf3c1a7 117 guix import /path/to/nixpkgs/checkout nettle
59b775cc
LC
118
119The command automatically fetches and converts to Guix the “Nix
120expression” of Nettle.
121
9bf3c1a7
LC
122* Submitting Patches
123
124Development is done using the Git distributed version control system. Thus,
125access to the repository is not strictly necessary. We welcome contributions
126in the form of patches as produced by ‘git format-patch’ sent to
127bug-guix@gnu.org. Please write commit logs in the [[http://www.gnu.org/prep/standards/html_node/Change-Logs.html#Change-Logs][GNU ChangeLog format]].
128
129As you become a regular contributor, you may find it convenient to have write
130access to the repository (see below.)
131
132* Commit Access
133
134For frequent contributors, having write access to the repository is
135convenient. When you deem it necessary, feel free to ask for it on the
136mailing list. When you get commit access, please make sure to follow the
137policy below (discussions of the policy can take place on bug-guix@gnu.org.)
138
139Non-trivial patches should always be posted to bug-guix@gnu.org (trivial
140patches include fixing typos, etc.)
141
142For patches that just add a new package, and a simple one, it’s OK to commit,
e20ec9cc
LC
143if you’re confident (which means you successfully built it in a chroot setup,
144and have done a reasonable copyright and license auditing.) Likewise for
145package upgrades. We have a mailing list for commit notifications
146(guix-commits@gnu.org), so people can notice. Before pushing your changes,
147make sure to run ‘git pull --rebase’.
9bf3c1a7
LC
148
149For anything else, please post to bug-guix@gnu.org and leave time for a
150review, without committing anything. If you didn’t receive any reply
151after two weeks, and if you’re confident, it’s OK to commit.
152
153That last part is subject to being adjusted, allowing individuals to commit
154directly on non-controversial changes on parts they’re familiar with.