summaryrefslogtreecommitdiff
path: root/HACKING
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2012-10-25 23:44:27 +0200
committerLudovic Courtès <ludo@gnu.org>2012-10-25 23:44:27 +0200
commit450ccdc3aae6d1a0f1685de3bef4d962e18c3855 (patch)
tree8f4eb256631f37d5a257cfd903a14b8604038279 /HACKING
parentfbc93bedff2a419305038564232837aff52513d2 (diff)
doc: Add `HACKING'.
* HACKING: New file. * Makefile.am (EXTRA_DIST): Add it.
Diffstat (limited to 'HACKING')
-rw-r--r--HACKING119
1 files changed, 119 insertions, 0 deletions
diff --git a/HACKING b/HACKING
new file mode 100644
index 00000000000..500d2e3bf01
--- /dev/null
+++ b/HACKING
@@ -0,0 +1,119 @@
1-*- mode: org; coding: utf-8; -*-
2
3#+TITLE: Hacking Guix and its incredible distro
4
5Copyright © 2012 Ludovic Courtès <ludo@gnu.org>
6
7 Copying and distribution of this file, with or without modification,
8 are permitted in any medium without royalty provided the copyright
9 notice and this notice are preserved.
10
11
12* Porting the Guix distro on a new platform
13
14** Introduction
15
16Unlike Make or similar build tools, Guix requires absolutely /all/ the
17dependencies of a build process to be specified.
18
19For a user-land software distribution, that means that the process that
20builds GCC (then used to build all other programs) must itself be
21specified; and the process to build the C library to build that GCC; and
22the process to build the GCC to build that library; and... See the
23problem? Chicken-and-egg.
24
25To break that cycle, the distro starts from a set of pre-built
26binaries–usually referred to as “bootstrap binaries.” These include
27statically-linked versions of Guile, GCC, Coreutils, Make, Grep, sed,
28etc., and the GNU C Library.
29
30This section describes how to build those bootstrap binaries when
31porting to a new platform.
32
33** When the platform is supported by Nixpkgs
34
35In that case, the easiest thing is to bootstrap the distro using
36binaries from Nixpkgs.
37
38To do that, you need to comment out the definitions of
39‘%bootstrap-guile’ and ‘%bootstrap-inputs’ in distro/packages/base.scm
40to force the use of Nixpkgs derivations. For instance, when porting to
41‘i686-linux’, you should redefine these variables along these lines:
42
43#+BEGIN_SRC scheme
44 (define %bootstrap-guile
45 (nixpkgs-derivation "guile" "i686-linux"))
46
47 (define %bootstrap-inputs
48 (compile-time-value
49 `(("libc" ,(nixpkgs-derivation "glibc" "i686-linux"))
50 ,@(map (lambda (name)
51 (list name (nixpkgs-derivation name "i686-linux")))
52 '("gnutar" "gzip" "bzip2" "xz" "patch"
53 "coreutils" "gnused" "gnugrep" "bash"
54 "gawk" ; used by `config.status'
55 "gcc" "binutils")))))
56#+END_SRC
57
58That should allow the distro to be bootstrapped.
59
60Then, the tarballs containing the initial binaries of Guile, Coreutils,
61GCC, libc, etc. need to be built. To that end, run the following
62commands:
63
64#+BEGIN_SRC sh
65 ./pre-inst-env guix-build \
66 -e '(@@ (distro packages base) %guile-bootstrap-tarball)' \
67 --system=i686-linux
68
69 ./pre-inst-env guix-build \
70 -e '(@@ (distro packages base) %bootstrap-binaries-tarball)' \
71 --system=i686-linux
72
73 ./pre-inst-env guix-build \
74 -e '(@@ (distro packages base) %binutils-bootstrap-tarball)' \
75 --system=i686-linux
76
77 ./pre-inst-env guix-build \
78 -e '(@@ (distro packages base) %glibc-bootstrap-tarball)' \
79 --system=i686-linux
80
81 ./pre-inst-env guix-build \
82 -e '(@@ (distro packages base) %gcc-bootstrap-tarball)' \
83 --system=i686-linux
84
85#+END_SRC
86
87These should build tarballs containing statically-linked tools usable on
88that system.
89
90In the source tree, you need to install binaries for ‘mkdir’, ‘bash’,
91‘tar’, and ‘xz’ under ‘distro/packages/bootstrap/i686-linux’. These
92binaries can be extracted from the static-binaries tarball built above.
93
94A rule for
95‘distro/packages/bootstrap/i686-linux/guile-bootstrap-2.0.6.tar.xz’
96needs to be added in ‘Makefile.am’, with the appropriate hexadecimal
97vrepresentation of its SHA256 hash.
98
99You may then revert your changes to ‘base.scm’. For the variables
100‘%bootstrap-coreutils&co’, ‘%bootstrap-binutils’, ‘%bootstrap-glibc’,
101and ‘%bootstrap-gcc’, the expected SHA256 of the corresponding tarballs
102for ‘i686-linux’ (built above) must be added.
103
104This should be enough to bootstrap the distro without resorting to
105Nixpkgs.
106
107** When the platform is *not* supported by Nixpkgs
108
109In that case, the bootstrap binaries should be built using whatever
110tools are available on the target platform. That is, the tarballs and
111binaries show above must first be built manually, using the available
112tools.
113
114They should have the same properties as those built by the Guix recipes
115shown above. For example, all the binaries (except for glibc) must be
116statically-linked; the bootstrap Guile must be relocatable (see patch in
117the Guix distro); the static-binaries tarball must contain the same
118programs (Coreutils, Grep, sed, Awk, etc.); and so on.
119