tests: Avoid unnecessary use of 'mock'.
[jackhill/guix/guix.git] / doc / guix-cookbook.texi
CommitLineData
7bc46ecc
RW
1\input texinfo
2@c -*-texinfo-*-
3
4@c %**start of header
5@setfilename guix-cookbook.info
6@documentencoding UTF-8
7@settitle GNU Guix Cookbook
8@c %**end of header
9
10@copying
11Copyright @copyright{} 2019 Ricardo Wurmus@*
12Copyright @copyright{} 2019 Efraim Flashner@*
13Copyright @copyright{} 2019 Pierre Neidhardt@*
14
15Permission is granted to copy, distribute and/or modify this document
16under the terms of the GNU Free Documentation License, Version 1.3 or
17any later version published by the Free Software Foundation; with no
18Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A
19copy of the license is included in the section entitled ``GNU Free
20Documentation License''.
21@end copying
22
23@dircategory System administration
24@direntry
25* Guix cookbook: (guix-cookbook). Tutorials and examples for GNU Guix.
26@end direntry
27
28@titlepage
29@title GNU Guix Cookbook
30@subtitle Tutorials and examples for using the GNU Guix Functional Package Manager
31@author The GNU Guix Developers
32
33@page
34@vskip 0pt plus 1filll
35
36@insertcopying
37@end titlepage
38
39@contents
40
41@c *********************************************************************
42@node Top
43@top GNU Guix Cookbook
44
45This document presents tutorials and detailed examples for GNU@tie{}Guix, a
46functional package management tool written for the GNU system. Please
47@pxref{Top,,, guix, GNU Guix reference manual} for details about the system,
48its API, and related concepts.
49
50@c TRANSLATORS: You can replace the following paragraph with information on
51@c how to join your own translation team and how to report issues with the
52@c translation.
53If you would like to translate this document in your native language, consider
54joining the @uref{https://translationproject.org/domain/guix-cookbook.html,
55Translation Project}.
56
57@menu
58* Scheme tutorials:: Meet your new favorite language!
59* Packaging:: Packaging tutorials
60* System Configuration:: Customizing the GNU System
4c463569 61* Advanced package management:: Power to the users!
7bc46ecc
RW
62
63* Acknowledgments:: Thanks!
64* GNU Free Documentation License:: The license of this document.
65* Concept Index:: Concepts.
66
67@detailmenu
68 --- The Detailed Node Listing ---
69
70Scheme tutorials
71
72* A Scheme Crash Course:: Learn the basics of Scheme
73
74Packaging
75
76* Packaging Tutorial:: Let's add a package to Guix!
77
78System Configuration
79
80* Customizing the Kernel:: Creating and using a custom Linux kernel
81
82
83@end detailmenu
84@end menu
85
86@c *********************************************************************
87@node Scheme tutorials
88@chapter Scheme tutorials
89
90GNU@tie{}Guix is written in the general purpose programming language Scheme,
91and many of its features can be accessed and manipulated programmatically.
92You can use Scheme to generate package definitions, to modify them, to build
93them, to deploy whole operating systems, etc.
94
95Knowing the basics of how to program in Scheme will unlock many of the
96advanced features Guix provides --- and you don't even need to be an
97experienced programmer to use them!
98
99Let's get started!
100
101@node A Scheme Crash Course
102@section A Scheme Crash Course
103
104@cindex Scheme, crash course
105
106Guix uses the Guile implementation of Scheme. To start playing with the
107language, install it with @code{guix install guile} and start a
108@uref{https://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop,
109REPL} by running @code{guile} from the command line.
110
111Alternatively you can also run @code{guix environment --ad-hoc guile -- guile}
112if you'd rather not have Guile installed in your user profile.
113
114In the following examples we use the @code{>} symbol to denote the REPL
115prompt, that is, the line reserved for user input. @xref{Using Guile
116Interactively,,, guile, GNU Guile Reference Manual}) for more details on the
117REPL.
118
119@itemize
120@item
121Scheme syntax boils down to a tree of expressions (or @emph{s-expression} in
122Lisp lingo). An expression can be a literal such as numbers and strings, or a
123compound which is a parenthesized list of compounds and literals. @code{#t}
124and @code{#f} stand for the booleans "true" and "false", respectively.
125
126Examples of valid expressions:
127
b1eecb5c 128@lisp
7bc46ecc
RW
129> "Hello World!"
130"Hello World!"
131> 17
13217
133> (display (string-append "Hello " "Guix" "\n"))
134"Hello Guix!"
b1eecb5c 135@end lisp
7bc46ecc
RW
136
137@item
138This last example is a function call nested in another function call. When a
139parenthesized expression is evaluated, the first term is the function and the
140rest are the arguments passed to the function. Every function returns the
141last evaluated expression as its return value.
142
143@item
144Anonymous functions are declared with the @code{lambda} term:
145
b1eecb5c 146@lisp
7bc46ecc
RW
147> (lambda (x) (* x x))
148#<procedure 120e348 at <unknown port>:24:0 (x)>
b1eecb5c 149@end lisp
7bc46ecc
RW
150
151The above procedure returns the square of its argument. Since everything is
152an expression, the @code{lambda} expression returns an anonymous procedure,
153which can in turn be applied to an argument:
154
b1eecb5c 155@lisp
7bc46ecc
RW
156> ((lambda (x) (* x x)) 3)
1579
b1eecb5c 158@end lisp
7bc46ecc
RW
159
160@item
161Anything can be assigned a global name with @code{define}:
162
b1eecb5c 163@lisp
7bc46ecc
RW
164> (define a 3)
165> (define square (lambda (x) (* x x)))
166> (square a)
1679
b1eecb5c 168@end lisp
7bc46ecc
RW
169
170@item
171Procedures can be defined more concisely with the following syntax:
172
b1eecb5c 173@lisp
7bc46ecc 174(define (square x) (* x x))
b1eecb5c 175@end lisp
7bc46ecc
RW
176
177@item
178A list structure can be created with the @code{list} procedure:
179
b1eecb5c 180@lisp
7bc46ecc
RW
181> (list 2 a 5 7)
182(2 3 5 7)
b1eecb5c 183@end lisp
7bc46ecc
RW
184
185@item
186The @emph{quote} disables evaluation of a parenthesized expression: the first
187term is not called over the other terms. Thus it effectively returns a list
188of terms.
189
b1eecb5c 190@lisp
7bc46ecc
RW
191> '(display (string-append "Hello " "Guix" "\n"))
192(display (string-append "Hello " "Guix" "\n"))
193> '(2 a 5 7)
194(2 a 5 7)
b1eecb5c 195@end lisp
7bc46ecc
RW
196
197@item
198The @emph{quasiquote} disables evaluation of a parenthesized expression until
199a comma re-enables it. Thus it provides us with fine-grained control over
200what is evaluated and what is not.
201
b1eecb5c 202@lisp
7bc46ecc
RW
203> `(2 a 5 7 (2 ,a 5 ,(+ a 4)))
204(2 a 5 7 (2 3 5 7))
b1eecb5c 205@end lisp
7bc46ecc
RW
206
207Note that the above result is a list of mixed elements: numbers, symbols (here
208@code{a}) and the last element is a list itself.
209
210@item
211Multiple variables can be named locally with @code{let}:
212
b1eecb5c 213@lisp
7bc46ecc
RW
214> (define x 10)
215> (let ((x 2)
216 (y 3))
217 (list x y))
218(2 3)
219> x
22010
221> y
222ERROR: In procedure module-lookup: Unbound variable: y
b1eecb5c 223@end lisp
7bc46ecc
RW
224
225Use @code{let*} to allow later variable declarations to refer to earlier
226definitions.
227
b1eecb5c 228@lisp
7bc46ecc
RW
229> (let* ((x 2)
230 (y (* x 3)))
231 (list x y))
232(2 6)
b1eecb5c 233@end lisp
7bc46ecc
RW
234
235@item
236The keyword syntax is @code{#:}; it is used to create unique identifiers.
237@pxref{Keywords,,, guile, GNU Guile Reference Manual}.
238
239@item
240The percentage @code{%} is typically used for read-only global variables in
241the build stage. Note that it is merely a convention, like @code{_} in C.
242Scheme treats @code{%} exactly the same as any other letter.
243
244@item
245Modules are created with @code{define-module}. For instance
246
b1eecb5c 247@lisp
7bc46ecc
RW
248(define-module (guix build-system ruby)
249 #:use-module (guix store)
250 #:export (ruby-build
251 ruby-build-system))
b1eecb5c 252@end lisp
7bc46ecc
RW
253
254defines the module @code{guix build-system ruby} which must be located in
255@file{guix/build-system/ruby.scm} somewhere in the Guile load path. It
256depends on the @code{(guix store)} module and it exports two variables,
257@code{ruby-build} and @code{ruby-build-system}.
258@end itemize
259
260For a more detailed introduction, check out
261@uref{http://www.troubleshooters.com/codecorn/scheme_guile/hello.htm, Scheme
262at a Glance}, by Steve Litt.
263
264One of the reference Scheme books is the seminal ``Structure and
265Interpretation of Computer Programs'', by Harold Abelson and Gerald Jay
266Sussman, with Julie Sussman. You'll find a
267@uref{https://mitpress.mit.edu/sites/default/files/sicp/index.html, free copy
268online}, together with
269@uref{https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-001-structure-and-interpretation-of-computer-programs-spring-2005/video-lectures/,
270videos of the lectures by the authors}. The book is available in Texinfo
271format as the @code{sicp} Guix package. Go ahead, run @code{guix install
ed79636c 272sicp} and start reading with @code{info sicp} (@pxref{,,, sicp, Structure and Interpretation of Computer Programs}).
7bc46ecc
RW
273An @uref{https://sarabander.github.io/sicp/, unofficial ebook is also
274available}.
275
276You'll find more books, tutorials and other resources at
277@url{https://schemers.org/}.
278
279
280@c *********************************************************************
281@node Packaging
282@chapter Packaging
283
284@cindex packaging
285
286This chapter is dedicated to teaching you how to add packages to the
287collection of packages that come with GNU Guix. This involves writing package
288definitions in Guile Scheme, organizing them in package modules, and building
289them.
290
291@menu
292* Packaging Tutorial:: A tutorial on how to add packages to Guix.
293@end menu
294
295@node Packaging Tutorial
296@section Packaging Tutorial
297
298GNU Guix stands out as the @emph{hackable} package manager, mostly because it
299uses @uref{https://www.gnu.org/software/guile/, GNU Guile}, a powerful
300high-level programming language, one of the
301@uref{https://en.wikipedia.org/wiki/Scheme_%28programming_language%29, Scheme}
302dialects from the
303@uref{https://en.wikipedia.org/wiki/Lisp_%28programming_language%29, Lisp family}.
304
305Package definitions are also written in Scheme, which empowers Guix in some
306very unique ways, unlike most other package managers that use shell scripts or
307simple languages.
308
309@itemize
310@item
311Use functions, structures, macros and all of Scheme expressiveness for your
312package definitions.
313
314@item
315Inheritance makes it easy to customize a package by inheriting from it and
316modifying only what is needed.
317
318@item
319Batch processing: the whole package collection can be parsed, filtered and
320processed. Building a headless server with all graphical interfaces stripped
321out? It's possible. Want to rebuild everything from source using specific
322compiler optimization flags? Pass the @code{#:make-flags "..."} argument to
323the list of packages. It wouldn't be a stretch to think
324@uref{https://wiki.gentoo.org/wiki/USE_flag, Gentoo USE flags} here, but this
325goes even further: the changes don't have to be thought out beforehand by the
326packager, they can be @emph{programmed} by the user!
327@end itemize
328
329The following tutorial covers all the basics around package creation with Guix.
330It does not assume much knowledge of the Guix system nor of the Lisp language.
331The reader is only expected to be familiar with the command line and to have some
332basic programming knowledge.
333
ffe059af 334@node A "Hello World" package
7bc46ecc
RW
335@subsection A "Hello World" package
336
337The “Defining Packages” section of the manual introduces the basics of Guix
338packaging (@pxref{Defining Packages,,, guix, GNU Guix Reference Manual}). In
339the following section, we will partly go over those basics again.
340
341``GNU hello'' is a dummy project that serves as an idiomatic example for
342packaging. It uses the GNU build system (@code{./configure && make && make
343install}). Guix already provides a package definition which is a perfect
344example to start with. You can look up its declaration with @code{guix edit
345hello} from the command line. Let's see how it looks:
346
b1eecb5c 347@lisp
7bc46ecc
RW
348(define-public hello
349 (package
350 (name "hello")
351 (version "2.10")
352 (source (origin
353 (method url-fetch)
354 (uri (string-append "mirror://gnu/hello/hello-" version
355 ".tar.gz"))
356 (sha256
357 (base32
358 "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i"))))
359 (build-system gnu-build-system)
360 (synopsis "Hello, GNU world: An example GNU package")
361 (description
362 "GNU Hello prints the message \"Hello, world!\" and then exits. It
363serves as an example of standard GNU coding practices. As such, it supports
364command-line arguments, multiple languages, and so on.")
365 (home-page "https://www.gnu.org/software/hello/")
366 (license gpl3+)))
b1eecb5c 367@end lisp
7bc46ecc
RW
368
369As you can see, most of it is rather straightforward. But let's review the
370fields together:
371
372@table @samp
373@item name
374The project name. Using Scheme conventions, we prefer to keep it
375lower case, without underscore and using dash-separated words.
376
377@item source
378This field contains a description of the source code origin. The
379@code{origin} record contains these fields:
380
381@enumerate
382@item The method, here @code{url-fetch} to download via HTTP/FTP, but other methods
383 exist, such as @code{git-fetch} for Git repositories.
384@item The URI, which is typically some @code{https://} location for @code{url-fetch}. Here
385 the special `mirror://gnu` refers to a set of well known locations, all of
386 which can be used by Guix to fetch the source, should some of them fail.
387@item The @code{sha256} checksum of the requested file. This is essential to ensure
388 the source is not corrupted. Note that Guix works with base32 strings,
389 hence the call to the @code{base32} function.
390@end enumerate
391
392@item build-system
393
394This is where the power of abstraction provided by the Scheme language really
395shines: in this case, the @code{gnu-build-system} abstracts away the famous
396@code{./configure && make && make install} shell invocations. Other build
397systems include the @code{trivial-build-system} which does not do anything and
398requires from the packager to program all the build steps, the
399@code{python-build-system}, the @code{emacs-build-system}, and many more
400(@pxref{Build Systems,,, guix, GNU Guix Reference Manual}).
401
402@item synopsis
403It should be a concise summary of what the package does. For many packages a
404tagline from the project's home page can be used as the synopsis.
405
406@item description
407Same as for the synopsis, it's fine to re-use the project description from the
408homepage. Note that Guix uses Texinfo syntax.
409
410@item home-page
411Use HTTPS if available.
412
413@item license
414See @code{guix/licenses.scm} in the project source for a full list of
415available licenses.
416@end table
417
418Time to build our first package! Nothing fancy here for now: we will stick to a
419dummy "my-hello", a copy of the above declaration.
420
421As with the ritualistic "Hello World" taught with most programming languages,
422this will possibly be the most "manual" approach. We will work out an ideal
423setup later; for now we will go the simplest route.
424
425Save the following to a file @file{my-hello.scm}.
426
b1eecb5c 427@lisp
7bc46ecc
RW
428(use-modules (guix packages)
429 (guix download)
430 (guix build-system gnu)
431 (guix licenses))
432
433(package
434 (name "my-hello")
435 (version "2.10")
436 (source (origin
437 (method url-fetch)
438 (uri (string-append "mirror://gnu/hello/hello-" version
439 ".tar.gz"))
440 (sha256
441 (base32
442 "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i"))))
443 (build-system gnu-build-system)
444 (synopsis "Hello, Guix world: An example custom Guix package")
445 (description
446 "GNU Hello prints the message \"Hello, world!\" and then exits. It
447serves as an example of standard GNU coding practices. As such, it supports
448command-line arguments, multiple languages, and so on.")
449 (home-page "https://www.gnu.org/software/hello/")
450 (license gpl3+))
b1eecb5c 451@end lisp
7bc46ecc
RW
452
453We will explain the extra code in a moment.
454
455Feel free to play with the different values of the various fields. If you
456change the source, you'll need to update the checksum. Indeed, Guix refuses to
457build anything if the given checksum does not match the computed checksum of the
458source code. To obtain the correct checksum of the package declaration, we
459need to download the source, compute the sha256 checksum and convert it to
460base32.
461
462Thankfully, Guix can automate this task for us; all we need is to provide the
463URI:
464
465@c TRANSLATORS: This is example shell output.
466@example sh
467$ guix download mirror://gnu/hello/hello-2.10.tar.gz
468
469Starting download of /tmp/guix-file.JLYgL7
470From https://ftpmirror.gnu.org/gnu/hello/hello-2.10.tar.gz...
471following redirection to `https://mirror.ibcp.fr/pub/gnu/hello/hello-2.10.tar.gz'...
472 …10.tar.gz 709KiB 2.5MiB/s 00:00 [##################] 100.0%
473/gnu/store/hbdalsf5lpf01x4dcknwx6xbn6n5km6k-hello-2.10.tar.gz
4740ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i
475@end example
476
477In this specific case the output tells us which mirror was chosen.
478If the result of the above command is not the same as in the above snippet,
479update your @code{my-hello} declaration accordingly.
480
481Note that GNU package tarballs come with an OpenPGP signature, so you
482should definitely check the signature of this tarball with `gpg` to
483authenticate it before going further:
484
485@c TRANSLATORS: This is example shell output.
486@example sh
487$ guix download mirror://gnu/hello/hello-2.10.tar.gz.sig
488
489Starting download of /tmp/guix-file.03tFfb
490From https://ftpmirror.gnu.org/gnu/hello/hello-2.10.tar.gz.sig...
491following redirection to `https://ftp.igh.cnrs.fr/pub/gnu/hello/hello-2.10.tar.gz.sig'...
492 ….tar.gz.sig 819B 1.2MiB/s 00:00 [##################] 100.0%
493/gnu/store/rzs8wba9ka7grrmgcpfyxvs58mly0sx6-hello-2.10.tar.gz.sig
4940q0v86n3y38z17rl146gdakw9xc4mcscpk8dscs412j22glrv9jf
495$ gpg --verify /gnu/store/rzs8wba9ka7grrmgcpfyxvs58mly0sx6-hello-2.10.tar.gz.sig /gnu/store/hbdalsf5lpf01x4dcknwx6xbn6n5km6k-hello-2.10.tar.gz
496gpg: Signature made Sun 16 Nov 2014 01:08:37 PM CET
497gpg: using RSA key A9553245FDE9B739
498gpg: Good signature from "Sami Kerola <kerolasa@@iki.fi>" [unknown]
499gpg: aka "Sami Kerola (http://www.iki.fi/kerolasa/) <kerolasa@@iki.fi>" [unknown]
500gpg: WARNING: This key is not certified with a trusted signature!
501gpg: There is no indication that the signature belongs to the owner.
502Primary key fingerprint: 8ED3 96E3 7E38 D471 A005 30D3 A955 3245 FDE9 B739
503@end example
504
505You can then happily run
506
507@c TRANSLATORS: Do not translate this command
508@example sh
509$ guix package --install-from-file=my-hello.scm
510@end example
511
512You should now have @code{my-hello} in your profile!
513
514@c TRANSLATORS: Do not translate this command
515@example sh
516$ guix package --list-installed=my-hello
517my-hello 2.10 out
518/gnu/store/f1db2mfm8syb8qvc357c53slbvf1g9m9-my-hello-2.10
519@end example
520
521We've gone as far as we could without any knowledge of Scheme. Before moving
522on to more complex packages, now is the right time to brush up on your Scheme
523knowledge. @pxref{A Scheme Crash Course} to get up to speed.
524
ffe059af
PN
525@node Setup
526@subsection Setup
7bc46ecc 527
ffe059af
PN
528In the rest of this chapter we will rely on some basic Scheme
529programming knowledge. Now let's detail the different possible setups
530for working on Guix packages.
531
532There are several ways to set up a Guix packaging environment.
533
534We recommend you work directly on the Guix source checkout since it makes it
535easier for everyone to contribute to the project.
536
537But first, let's look at other possibilities.
538
539@node Local file
540@subsubsection Local file
541
542This is what we previously did with @samp{my-hello}. With the Scheme basics we've
543covered, we are now able to explain the leading chunks. As stated in @code{guix
544package --help}:
545
546@example
547 -f, --install-from-file=FILE
548 install the package that the code within FILE
549 evaluates to
550@end example
551
552Thus the last expression @emph{must} return a package, which is the case in our
553earlier example.
554
555The @code{use-modules} expression tells which of the modules we need in the file.
556Modules are a collection of values and procedures. They are commonly called
557"libraries" or "packages" in other programming languages.
558
559@node @samp{GUIX_PACKAGE_PATH}
560@subsubsection @samp{GUIX_PACKAGE_PATH}
561
562@emph{Note: Starting from Guix 0.16, the more flexible Guix "channels" are the
563preferred way and supersede @samp{GUIX_PACKAGE_PATH}. See next section.}
564
565It can be tedious to specify the file from the command line instead of simply
566calling @code{guix package --install my-hello} as you would do with the official
567packages.
568
569Guix makes it possible to streamline the process by adding as many "package
570declaration paths" as you want.
571
572Create a directory, say @samp{~./guix-packages} and add it to the @samp{GUIX_PACKAGE_PATH}
573environment variable:
574
575@example
576$ mkdir ~/guix-packages
577$ export GUIX_PACKAGE_PATH=~/guix-packages
578@end example
579
580To add several directories, separate them with a colon (@code{:}).
581
582Our previous @samp{my-hello} needs some adjustments though:
583
584@example
585(define-module (my-hello)
586 #:use-module (guix licenses)
587 #:use-module (guix packages)
588 #:use-module (guix build-system gnu)
589 #:use-module (guix download))
590
591(define-public my-hello
592 (package
593 (name "my-hello")
594 (version "2.10")
595 (source (origin
596 (method url-fetch)
597 (uri (string-append "mirror://gnu/hello/hello-" version
598 ".tar.gz"))
599 (sha256
600 (base32
601 "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i"))))
602 (build-system gnu-build-system)
603 (synopsis "Hello, Guix world: An example custom Guix package")
604 (description
605 "GNU Hello prints the message \"Hello, world!\" and then exits. It
606serves as an example of standard GNU coding practices. As such, it supports
607command-line arguments, multiple languages, and so on.")
608 (home-page "https://www.gnu.org/software/hello/")
609 (license gpl3+)))
610@end example
611
612Note that we have assigned the package value to an exported variable name with
613@code{define-public}. This is effectively assigning the package to the @code{my-hello}
614variable so that it can be referenced, among other as dependency of other
615packages.
616
617If you use @code{guix package --install-from-file=my-hello.scm} on the above file, it
618will fail because the last expression, @code{define-public}, does not return a
619package. If you want to use @code{define-public} in this use-case nonetheless, make
620sure the file ends with an evaluation of @code{my-hello}:
621
622@example
623; ...
624(define-public my-hello
625 ; ...
626 )
627
628my-hello
629@end example
630
631This last example is not very typical.
632
633Now @samp{my-hello} should be part of the package collection like all other official
634packages. You can verify this with:
635
636@example
637$ guix package --show=my-hello
638@end example
639
640@node Guix channels
641@subsubsection Guix channels
642
643Guix 0.16 features channels, which is very similar to @samp{GUIX_PACKAGE_PATH} but
644provides better integration and provenance tracking. Channels are not
645necessarily local, they can be maintained as a public Git repository for
646instance. Of course, several channels can be used at the same time.
647
648@xref{Channels,,, guix, GNU Guix Reference Manual} for setup details.
649
650@node Direct checkout hacking
651@subsubsection Direct checkout hacking
652
653Working directly on the Guix project is recommended: it reduces the friction
654when the time comes to submit your changes upstream to let the community benefit
655from your hard work!
656
657Unlike most software distributions, the Guix repository holds in one place both
658the tooling (including the package manager) and the package definitions. This
659choice was made so that it would give developers the flexibility to modify the
660API without breakage by updating all packages at the same time. This reduces
661development inertia.
662
663Check out the official @uref{https://git-scm.com/, Git} repository:
664
665@example
666$ git clone https://git.savannah.gnu.org/git/guix.git
667@end example
668
669In the rest of this article, we use @samp{$GUIX_CHECKOUT} to refer to the location of
670the checkout.
671
672
673Follow the instruction in the manual (@pxref{Contributing,,, guix, GNU Guix
674Reference Manual}) to set up the repository environment.
675
676Once ready, you should be able to use the package definitions from the
677repository environment.
678
679Feel free to edit package definitions found in @samp{$GUIX_CHECKOUT/gnu/packages}.
680
681The @samp{$GUIX_CHECKOUT/pre-inst-env} script lets you use @samp{guix} over the package
682collection of the repository.
683
684@itemize
685@item
686Search packages, such as Ruby:
687
688@example
689 $ cd $GUIX_CHECKOUT
690 $ ./pre-inst-env guix package --list-available=ruby
691 ruby 1.8.7-p374 out gnu/packages/ruby.scm:119:2
692 ruby 2.1.6 out gnu/packages/ruby.scm:91:2
693 ruby 2.2.2 out gnu/packages/ruby.scm:39:2
694@end example
695
696@item
697Build a package, here Ruby version 2.1:
698
699@example
700 $ ./pre-inst-env guix build --keep-failed ruby@@2.1
701 /gnu/store/c13v73jxmj2nir2xjqaz5259zywsa9zi-ruby-2.1.6
702@end example
703
704@item
705Install it to your user profile:
706
707@example
708 $ ./pre-inst-env guix package --install ruby@@2.1
709@end example
710
711@item
712Check for common mistakes:
713
714@example
715 $ ./pre-inst-env guix lint ruby@@2.1
716@end example
717@end itemize
718
719Guix strives at maintaining a high packaging standard; when contributing to the
720Guix project, remember to
721
722@itemize
723@item
724follow the coding style (@pxref{Coding Style,,, guix, GNU Guix Reference Manual}),
725@item
726and review the check list from the manual (@pxref{Submitting Patches,,, guix, GNU Guix Reference Manual}).
727@end itemize
728
729Once you are happy with the result, you are welcome to send your contribution to
730make it part of Guix. This process is also detailed in the manual. (@pxref{Contributing,,, guix, GNU Guix Reference Manual})
731
732
733It's a community effort so the more join in, the better Guix becomes!
734
735@node Extended example
736@subsection Extended example
737
738The above "Hello World" example is as simple as it goes. Packages can be more
739complex than that and Guix can handle more advanced scenarios. Let's look at
740another, more sophisticated package (slightly modified from the source):
741
742@example
743(define-module (gnu packages version-control)
744 #:use-module ((guix licenses) #:prefix license:)
745 #:use-module (guix utils)
746 #:use-module (guix packages)
747 #:use-module (guix git-download)
748 #:use-module (guix build-system cmake)
749 #:use-module (gnu packages ssh)
750 #:use-module (gnu packages web)
751 #:use-module (gnu packages pkg-config)
752 #:use-module (gnu packages python)
753 #:use-module (gnu packages compression)
754 #:use-module (gnu packages tls))
755
756(define-public my-libgit2
757 (let ((commit "e98d0a37c93574d2c6107bf7f31140b548c6a7bf")
758 (revision "1"))
759 (package
760 (name "my-libgit2")
761 (version (git-version "0.26.6" revision commit))
762 (source (origin
763 (method git-fetch)
764 (uri (git-reference
765 (url "https://github.com/libgit2/libgit2/")
766 (commit commit)))
767 (file-name (git-file-name name version))
768 (sha256
769 (base32
770 "17pjvprmdrx4h6bb1hhc98w9qi6ki7yl57f090n9kbhswxqfs7s3"))
771 (patches (search-patches "libgit2-mtime-0.patch"))
772 (modules '((guix build utils)))
773 (snippet '(begin
774 ;; Remove bundled software.
775 (delete-file-recursively "deps")
776 #t))))
777 (build-system cmake-build-system)
778 (outputs '("out" "debug"))
779 (arguments
780 `(#:tests? #t ; Run the test suite (this is the default)
781 #:configure-flags '("-DUSE_SHA1DC=ON") ; SHA-1 collision detection
782 #:phases
783 (modify-phases %standard-phases
784 (add-after 'unpack 'fix-hardcoded-paths
785 (lambda _
786 (substitute* "tests/repo/init.c"
787 (("#!/bin/sh") (string-append "#!" (which "sh"))))
788 (substitute* "tests/clar/fs.h"
789 (("/bin/cp") (which "cp"))
790 (("/bin/rm") (which "rm")))
791 #t))
792 ;; Run checks more verbosely.
793 (replace 'check
794 (lambda _ (invoke "./libgit2_clar" "-v" "-Q")))
795 (add-after 'unpack 'make-files-writable-for-tests
796 (lambda _ (for-each make-file-writable (find-files "." ".*")))))))
797 (inputs
798 `(("libssh2" ,libssh2)
799 ("http-parser" ,http-parser)
800 ("python" ,python-wrapper)))
801 (native-inputs
802 `(("pkg-config" ,pkg-config)))
803 (propagated-inputs
804 ;; These two libraries are in 'Requires.private' in libgit2.pc.
805 `(("openssl" ,openssl)
806 ("zlib" ,zlib)))
807 (home-page "https://libgit2.github.com/")
808 (synopsis "Library providing Git core methods")
809 (description
810 "Libgit2 is a portable, pure C implementation of the Git core methods
811provided as a re-entrant linkable library with a solid API, allowing you to
812write native speed custom Git applications in any language with bindings.")
813 ;; GPLv2 with linking exception
814 (license license:gpl2))))
815@end example
816
817(In those cases were you only want to tweak a few fields from a package
818definition, you should rely on inheritance instead of copy-pasting everything.
819See below.)
820
821Let's discuss those fields in depth.
822
823@subsubsection @code{git-fetch} method
824
825Unlike the @code{url-fetch} method, @code{git-fetch} expects a @code{git-reference} which takes
826a Git repository and a commit. The commit can be any Git reference such as
827tags, so if the @code{version} is tagged, then it can be used directly. Sometimes
828the tag is prefixed with a @code{v}, in which case you'd use @code{(commit (string-append
829"v" version))}.
830
831To ensure that the source code from the Git repository is stored in a unique
832directory with a readable name we use @code{(file-name (git-file-name name
833version))}.
834
835Note that there is also a @code{git-version} procedure that can be used to derive the
836version when packaging programs for a specific commit.
837
838@subsubsection Snippets
839
840Snippets are quoted (i.e. non-evaluated) Scheme code that are a means of patching
841the source. They are a Guix-y alternative to the traditional @samp{.patch} files.
842Because of the quote, the code in only evaluated when passed to the Guix daemon
843for building.
844
845There can be as many snippet as needed.
846
847Snippets might need additional Guile modules which can be imported from the
848@code{modules} field.
849
850@subsubsection Inputs
851
852First, a syntactic comment: See the quasi-quote / comma syntax?
853
854@example
855 (native-inputs
856 `(("pkg-config" ,pkg-config)))
857@end example
858
859is equivalent to
860
861@example
862 (native-inputs
863 (list (list "pkg-config" pkg-config)))
864@end example
865
866You'll mostly see the former because it's shorter.
867
868There are 3 different input types. In short:
869
870@table @asis
871@item native-inputs
872Required for building but not runtime -- installing a package
873through a substitute won't install these inputs.
874@item inputs
875Installed in the store but not in the profile, as well as being
876present at build time.
877@item propagated-inputs
878Installed in the store and in the profile, as well as
879being present at build time.
880@end table
881
882@xref{Package Reference,,, guix, GNU Guix Reference Manual} for more details.
883
884The distinction between the various inputs is important: if a dependency can be
885handled as an @emph{input} instead of a @emph{propagated input}, it should be done so, or
886else it "pollutes" the user profile for no good reason.
887
888For instance, a user installing a graphical program that depends on a
889command line tool might only be interested in the graphical part, so there is no
890need to force the command line tool into the user profile. The dependency is a
891concern to the package, not to the user. @emph{Inputs} make it possible to handle
892dependencies without bugging the user by adding undesired executable files (or
893libraries) to their profile.
894
895Same goes for @emph{native-inputs}: once the program is installed, build-time
896dependencies can be safely garbage-collected.
897It also matters when a substitute is available, in which case only the @emph{inputs}
898and @emph{propagated inputs} will be fetched: the @emph{native inputs} are not required to
899install a package from a substitute.
900
901@subsubsection Outputs
902
903Just like how a package can have multiple inputs, it can also produce multiple
904outputs.
905
906Each output corresponds to a separate directory in the store.
907
908The user can choose which output to install; this is useful to save space or
909to avoid polluting the user profile with unwanted executables or libraries.
910
911Output separation is optional. When the @code{outputs} field is left out, the
912default and only output (the complete package) is referred to as @code{"out"}.
913
914Typical separate output names include @code{debug} and @code{doc}.
915
916It's advised to separate outputs only when you've shown it's worth it: if the
917output size is significant (compare with @code{guix size}) or in case the package is
918modular.
919
920@subsubsection Build system arguments
921
922The @code{arguments} is a keyword-value list used to configure the build process.
923
924The simplest argument @code{#:tests?} can be used to disable the test suite when
925building the package. This is mostly useful when the package does not feature
926any test suite. It's strongly recommended to keep the test suite on if there is
927one.
928
929Another common argument is @code{:make-flags}, which specifies a list of flags to
930append when running make, as you would from the command line. For instance, the
931following flags
932
933@example
934#:make-flags (list (string-append "prefix=" (assoc-ref %outputs "out"))
935 "CC=gcc")
936@end example
937
938translate into
939
940@example
941$ make CC=gcc prefix=/gnu/store/...-<out>
942@end example
943
944This sets the C compiler to @code{gcc} and the @code{prefix} variable (the installation
945directory in Make parlance) to @code{(assoc-ref %outputs "out")}, which is a build-stage
946global variable pointing to the destination directory in the store (something like
947@samp{/gnu/store/...-my-libgit2-20180408}).
948
949Similarly, it's possible to set the "configure" flags.
950
951@example
952#:configure-flags '("-DUSE_SHA1DC=ON")
953@end example
954
955The @code{%build-inputs} variable is also generated in scope. It's an association
956table that maps the input names to their store directories.
957
958The @code{phases} keyword lists the sequential steps of the build system. Typically
959phases include @code{unpack}, @code{configure}, @code{build}, @code{install} and @code{check}. To know
960more about those phases, you need to work out the appropriate build system
961definition in @samp{$GUIX_CHECKOUT/guix/build/gnu-build-system.scm}:
962
963@example
964(define %standard-phases
965 ;; Standard build phases, as a list of symbol/procedure pairs.
966 (let-syntax ((phases (syntax-rules ()
967 ((_ p ...) `((p . ,p) ...)))))
968 (phases set-SOURCE-DATE-EPOCH set-paths install-locale unpack
969 bootstrap
970 patch-usr-bin-file
971 patch-source-shebangs configure patch-generated-file-shebangs
972 build check install
973 patch-shebangs strip
974 validate-runpath
975 validate-documentation-location
976 delete-info-dir-file
977 patch-dot-desktop-files
978 install-license-files
979 reset-gzip-timestamps
980 compress-documentation)))
981@end example
982
983Or from the REPL:
984
985@example
986> (add-to-load-path "/path/to/guix/checkout")
987> ,module (guix build gnu-build-system)
988> (map first %standard-phases)
989(set-SOURCE-DATE-EPOCH set-paths install-locale unpack bootstrap patch-usr-bin-file patch-source-shebangs configure patch-generated-file-shebangs build check install patch-shebangs strip validate-runpath validate-documentation-location delete-info-dir-file patch-dot-desktop-files install-license-files reset-gzip-timestamps compress-documentation)
990@end example
991
992If you want to know more about what happens during those phases, consult the
993associated procedures.
994
995For instance, as of this writing the definition of @code{unpack} for the GNU build
996system is
997
998@example
999(define* (unpack #:key source #:allow-other-keys)
1000 "Unpack SOURCE in the working directory, and change directory within the
1001source. When SOURCE is a directory, copy it in a sub-directory of the current
1002working directory."
1003 (if (file-is-directory? source)
1004 (begin
1005 (mkdir "source")
1006 (chdir "source")
1007
1008 ;; Preserve timestamps (set to the Epoch) on the copied tree so that
1009 ;; things work deterministically.
1010 (copy-recursively source "."
1011 #:keep-mtime? #t))
1012 (begin
1013 (if (string-suffix? ".zip" source)
1014 (invoke "unzip" source)
1015 (invoke "tar" "xvf" source))
1016 (chdir (first-subdirectory "."))))
1017 #t)
1018@end example
1019
1020Note the @code{chdir} call: it changes the working directory to where the source was
1021unpacked.
1022Thus every phase following the @code{unpack} will use the source as a working
1023directory, which is why we can directly work on the source files.
1024That is to say, unless a later phase changes the working directory to something
1025else.
1026
1027We modify the list of @code{%standard-phases} of the build system with the
1028@code{modify-phases} macro as per the list of specified modifications, which may have
1029the following forms:
1030
1031@itemize
1032@item
1033@code{(add-before PHASE NEW-PHASE PROCEDURE)}: Run @code{PROCEDURE} named @code{NEW-PHASE} before @code{PHASE}.
1034@item
1035@code{(add-after PHASE NEW-PHASE PROCEDURE)}: Same, but afterwards.
1036@item
1037@code{(replace PHASE PROCEDURE)}.
1038@item
1039@code{(delete PHASE)}.
1040@end itemize
1041
1042The @code{PROCEDURE} supports the keyword arguments @code{inputs} and @code{outputs}. Each
1043input (whether @emph{native}, @emph{propagated} or not) and output directory is referenced
1044by their name in those variables. Thus @code{(assoc-ref outputs "out")} is the store
1045directory of the main output of the package. A phase procedure may look like
1046this:
1047
1048@example
1049(lambda* (#:key inputs outputs #:allow-other-keys)
1050 (let (((bash-directory (assoc-ref inputs "bash"))
1051 (output-directory (assoc-ref outputs "out"))
1052 (doc-directory (assoc-ref outputs "doc"))
1053 ; ...
1054 #t)
1055@end example
1056
1057The procedure must return @code{#t} on success. It's brittle to rely on the return
1058value of the last expression used to tweak the phase because there is no
1059guarantee it would be a @code{#t}. Hence the trailing @code{#t} to ensure the right value
1060is returned on success.
1061
1062@subsubsection Code staging
1063
1064The astute reader may have noticed the quasi-quote and comma syntax in the
1065argument field. Indeed, the build code in the package declaration should not be
1066evaluated on the client side, but only when passed to the Guix daemon. This
1067mechanism of passing code around two running processes is called @uref{https://arxiv.org/abs/1709.00833, code staging}.
1068
1069@subsubsection "Utils" functions
1070
1071When customizing @code{phases}, we often need to write code that mimics the
1072equivalent system invocations (@code{make}, @code{mkdir}, @code{cp}, etc.) commonly used during
1073regular "Unix-style" installations.
1074
1075Some like @code{chmod} are native to Guile.
1076@xref{,,, guile, Guile reference manual} for a complete list.
1077
1078Guix provides additional helper functions which prove especially handy in the
1079context of package management.
1080
1081Some of those functions can be found in
1082@samp{$GUIX_CHECKOUT/guix/guix/build/utils.scm}. Most of them mirror the behaviour
1083of the traditional Unix system commands:
1084
1085@table @asis
1086@item which
1087Like the @samp{which} system command.
1088@item find-files
1089Akin to the @samp{find} system command.
1090@item mkdir-p
1091Like @samp{mkdir -p}, which creates all parents as needed.
1092@item install-file
1093Similar to @samp{install} when installing a file to a (possibly
1094non-existing) directory. Guile has @code{copy-file} which works
1095like @samp{cp}.
1096@item copy-recursively
1097Like @samp{cp -r}.
1098@item delete-file-recursively
1099Like @samp{rm -rf}.
1100@item invoke
1101Run an executable. This should be used instead of @code{system*}.
1102@item with-directory-excursion
1103Run the body in a different working directory,
1104then restore the previous working directory.
1105@item substitute*
1106A "sed-like" function.
1107@end table
1108
1109@subsubsection Module prefix
1110
1111The license in our last example needs a prefix: this is because of how the
1112@code{license} module was imported in the package, as @code{#:use-module ((guix licenses)
1113#:prefix license:)}. The Guile module import mechanism
1114(@pxref{Using Guile Modules,,, guile, Guile reference manual})
1115gives the user full control over namespacing: this is needed to avoid
1116clashes between, say, the
1117@samp{zlib} variable from @samp{licenses.scm} (a @emph{license} value) and the @samp{zlib} variable
1118from @samp{compression.scm} (a @emph{package} value).
1119
1120@node Other build systems
1121@subsection Other build systems
1122
1123What we've seen so far covers the majority of packages using a build system
1124other than the @code{trivial-build-system}. The latter does not automate anything
1125and leaves you to build everything manually. This can be more demanding and we
1126won't cover it here for now, but thankfully it is rarely necessary to fall back
1127on this system.
1128
1129For the other build systems, such as ASDF, Emacs, Perl, Ruby and many more, the
1130process is very similar to the GNU build system except for a few specialized
1131arguments.
1132
1133Learn more about build systems in
1134@itemize
1135@item
1136@uref{https://www.gnu.org/software/guix/manual/en/html_node/Build-Systems.html#Build-Systems, the manual, section 4.2 Build systems},
1137@item
1138the source code in the @samp{$GUIX_CHECKOUT/guix/build} and
1139@samp{$GUIX_CHECKOUT/guix/build-system} directories.
1140@end itemize
1141
1142@node Programmable and automated package definition
1143@subsection Programmable and automated package definition
1144
1145We can't repeat it enough: having a full-fledged programming language at hand
1146empowers us in ways that reach far beyond traditional package management.
1147
1148Let's illustrate this with some awesome features of Guix!
1149
1150@node Recursive importers
1151@subsubsection Recursive importers
1152
1153You might find some build systems good enough that there is little to do at all
1154to write a package, to the point that it becomes repetitive and tedious after a
1155while. A @emph{raison d'être} of computers is to replace human beings at those
1156boring tasks. So let's tell Guix to do this for us and create the package
1157definition of an R package from CRAN (the output is trimmed for conciseness):
1158
1159@example
1160$ guix import cran --recursive walrus
1161
1162(define-public r-mc2d
1163 ; ...
1164 (license gpl2+)))
1165
1166(define-public r-jmvcore
1167 ; ...
1168 (license gpl2+)))
1169
1170(define-public r-wrs2
1171 ; ...
1172 (license gpl3)))
1173
1174(define-public r-walrus
1175 (package
1176 (name "r-walrus")
1177 (version "1.0.3")
1178 (source
1179 (origin
1180 (method url-fetch)
1181 (uri (cran-uri "walrus" version))
1182 (sha256
1183 (base32
1184 "1nk2glcvy4hyksl5ipq2mz8jy4fss90hx6cq98m3w96kzjni6jjj"))))
1185 (build-system r-build-system)
1186 (propagated-inputs
1187 `(("r-ggplot2" ,r-ggplot2)
1188 ("r-jmvcore" ,r-jmvcore)
1189 ("r-r6" ,r-r6)
1190 ("r-wrs2" ,r-wrs2)))
1191 (home-page "https://github.com/jamovi/walrus")
1192 (synopsis "Robust Statistical Methods")
1193 (description
1194 "This package provides a toolbox of common robust statistical
1195tests, including robust descriptives, robust t-tests, and robust ANOVA.
1196It is also available as a module for 'jamovi' (see
1197<https://www.jamovi.org> for more information). Walrus is based on the
1198WRS2 package by Patrick Mair, which is in turn based on the scripts and
1199work of Rand Wilcox. These analyses are described in depth in the book
1200'Introduction to Robust Estimation & Hypothesis Testing'.")
1201 (license gpl3)))
1202@end example
1203
1204The recursive importer won't import packages for which Guix already has package
1205definitions, except for the very first.
1206
1207Not all applications can be packaged this way, only those relying on a select
1208number of supported systems. Read about the full list of importers in
1209the guix import section of the manual
1210(@pxref{Invoking guix import,,, guix, GNU Guix Reference Manual}).
1211
1212@node Automatic update
1213@subsubsection Automatic update
1214
1215Guix can be smart enough to check for updates on systems it knows. It can
1216report outdated package definitions with
1217
1218@example
1219$ guix refresh hello
1220@end example
1221
1222In most cases, updating a package to a newer version requires little more than
1223changing the version number and the checksum. Guix can do that automatically as
1224well:
1225
1226@example
1227$ guix refresh hello --update
1228@end example
1229
1230@node Inheritance
1231@subsubsection Inheritance
1232
1233If you've started browsing the existing package definitions, you might have
1234noticed that a significant number of them have a @code{inherit} field:
1235
1236@example
1237(define-public adwaita-icon-theme
1238 (package (inherit gnome-icon-theme)
1239 (name "adwaita-icon-theme")
1240 (version "3.26.1")
1241 (source (origin
1242 (method url-fetch)
1243 (uri (string-append "mirror://gnome/sources/" name "/"
1244 (version-major+minor version) "/"
1245 name "-" version ".tar.xz"))
1246 (sha256
1247 (base32
1248 "17fpahgh5dyckgz7rwqvzgnhx53cx9kr2xw0szprc6bnqy977fi8"))))
1249 (native-inputs
1250 `(("gtk-encode-symbolic-svg" ,gtk+ "bin")))))
1251@end example
1252
1253All unspecified fields are inherited from the parent package. This is very
1254convenient to create alternative packages, for instance with different source,
1255version or compilation options.
1256
1257@node Getting help
1258@subsection Getting help
1259
1260Sadly, some applications can be tough to package. Sometimes they need a patch to
1261work with the non-standard filesystem hierarchy enforced by the store.
1262Sometimes the tests won't run properly. (They can be skipped but this is not
1263recommended.) Other times the resulting package won't be reproducible.
1264
1265Should you be stuck, unable to figure out how to fix any sort of packaging
1266issue, don't hesitate to ask the community for help.
1267
1268See the @uref{https://www.gnu.org/software/guix/contact/, Guix homepage} for information on the mailing lists, IRC, etc.
1269
1270@node Conclusion
1271@subsection Conclusion
1272
1273This tutorial was a showcase of the sophisticated package management that Guix
1274boasts. At this point we have mostly restricted this introduction to the
1275@code{gnu-build-system} which is a core abstraction layer on which more advanced
1276abstractions are based.
1277
1278Where do we go from here? Next we ought to dissect the innards of the build
1279system by removing all abstractions, using the @code{trivial-build-system}: this
1280should give us a thorough understanding of the process before investigating some
1281more advanced packaging techniques and edge cases.
1282
1283Other features worth exploring are the interactive editing and debugging
1284capabilities of Guix provided by the Guile REPL@.
1285
1286Those fancy features are completely optional and can wait; now is a good time
1287to take a well-deserved break. With what we've introduced here you should be
1288well armed to package lots of programs. You can get started right away and
1289hopefully we will see your contributions soon!
1290
1291@node References
1292@subsection References
1293
1294@itemize
1295@item
1296The @uref{https://www.gnu.org/software/guix/manual/en/html_node/Defining-Packages.html, package reference in the manual}
1297
1298@item
1299@uref{https://gitlab.com/pjotrp/guix-notes/blob/master/HACKING.org, Pjotr’s hacking guide to GNU Guix}
1300
1301@item
1302@uref{https://www.gnu.org/software/guix/guix-ghm-andreas-20130823.pdf, "GNU Guix: Package without a scheme!"}, by Andreas Enge
1303@end itemize
7bc46ecc
RW
1304
1305@c *********************************************************************
1306@node System Configuration
1307@chapter System Configuration
1308
1309Guix offers a flexible language for declaratively configuring your Guix
1310System. This flexibility can at times be overwhelming. The purpose of this
1311chapter is to demonstrate some advanced configuration concepts.
1312
1313@pxref{System Configuration,,, guix, GNU Guix Reference Manual} for a complete
1314reference.
1315
1316@menu
1317* Customizing the Kernel:: Creating and using a custom Linux kernel on Guix System.
1318@end menu
1319
1320@node Customizing the Kernel
1321@section Customizing the Kernel
1322
1323Guix is, at its core, a source based distribution with substitutes
1324(@pxref{Substitutes,,, guix, GNU Guix Reference Manual}), and as such building
1325packages from their source code is an expected part of regular package
1326installations and upgrades. Given this starting point, it makes sense that
1327efforts are made to reduce the amount of time spent compiling packages, and
1328recent changes and upgrades to the building and distribution of substitutes
1329continues to be a topic of discussion within Guix.
1330
1331The kernel, while not requiring an overabundance of RAM to build, does take a
1332rather long time on an average machine. The official kernel configuration, as
1333is the case with many GNU/Linux distributions, errs on the side of
1334inclusiveness, and this is really what causes the build to take such a long
1335time when the kernel is built from source.
1336
1337The Linux kernel, however, can also just be described as a regular old
1338package, and as such can be customized just like any other package. The
1339procedure is a little bit different, although this is primarily due to the
1340nature of how the package definition is written.
1341
1342The @code{linux-libre} kernel package definition is actually a procedure which
1343creates a package.
1344
b1eecb5c 1345@lisp
7bc46ecc
RW
1346(define* (make-linux-libre version hash supported-systems
1347 #:key
1348 ;; A function that takes an arch and a variant.
1349 ;; See kernel-config for an example.
1350 (extra-version #f)
1351 (configuration-file #f)
1352 (defconfig "defconfig")
1353 (extra-options %default-extra-linux-options)
1354 (patches (list %boot-logo-patch)))
1355 ...)
b1eecb5c 1356@end lisp
7bc46ecc
RW
1357
1358The current @code{linux-libre} package is for the 5.1.x series, and is
1359declared like this:
1360
b1eecb5c 1361@lisp
7bc46ecc
RW
1362(define-public linux-libre
1363 (make-linux-libre %linux-libre-version
1364 %linux-libre-hash
1365 '("x86_64-linux" "i686-linux" "armhf-linux" "aarch64-linux")
1366 #:patches %linux-libre-5.1-patches
1367 #:configuration-file kernel-config))
b1eecb5c 1368@end lisp
7bc46ecc
RW
1369
1370Any keys which are not assigned values inherit their default value from the
1371@code{make-linux-libre} definition. When comparing the two snippets above,
1372you may notice that the code comment in the first doesn't actually refer to
1373the @code{#:extra-version} keyword; it is actually for
1374@code{#:configuration-file}. Because of this, it is not actually easy to
1375include a custom kernel configuration from the definition, but don't worry,
1376there are other ways to work with what we do have.
1377
1378There are two ways to create a kernel with a custom kernel configuration. The
1379first is to provide a standard @file{.config} file during the build process by
1380including an actual @file{.config} file as a native input to our custom
1381kernel. The following is a snippet from the custom @code{'configure} phase of
1382the @code{make-linux-libre} package definition:
1383
b1eecb5c 1384@lisp
7bc46ecc
RW
1385(let ((build (assoc-ref %standard-phases 'build))
1386 (config (assoc-ref (or native-inputs inputs) "kconfig")))
1387
1388 ;; Use a custom kernel configuration file or a default
1389 ;; configuration file.
1390 (if config
1391 (begin
1392 (copy-file config ".config")
1393 (chmod ".config" #o666))
1394 (invoke "make" ,defconfig))
b1eecb5c 1395@end lisp
7bc46ecc
RW
1396
1397Below is a sample kernel package. The @code{linux-libre} package is nothing
1398special and can be inherited from and have its fields overridden like any
1399other package:
1400
b1eecb5c 1401@lisp
7bc46ecc
RW
1402(define-public linux-libre/E2140
1403 (package
1404 (inherit linux-libre)
1405 (native-inputs
1406 `(("kconfig" ,(local-file "E2140.config"))
1407 ,@@(alist-delete "kconfig"
1408 (package-native-inputs linux-libre))))))
b1eecb5c 1409@end lisp
7bc46ecc
RW
1410
1411In the same directory as the file defining @code{linux-libre-E2140} is a file
1412named @file{E2140.config}, which is an actual kernel configuration file. The
1413@code{defconfig} keyword of @code{make-linux-libre} is left blank here, so the
1414only kernel configuration in the package is the one which was included in the
1415@code{native-inputs} field.
1416
1417The second way to create a custom kernel is to pass a new value to the
1418@code{extra-options} keyword of the @code{make-linux-libre} procedure. The
1419@code{extra-options} keyword works with another function defined right below
1420it:
1421
b1eecb5c 1422@lisp
7bc46ecc
RW
1423(define %default-extra-linux-options
1424 `(;; https://lists.gnu.org/archive/html/guix-devel/2014-04/msg00039.html
1425 ("CONFIG_DEVPTS_MULTIPLE_INSTANCES" . #t)
1426 ;; Modules required for initrd:
1427 ("CONFIG_NET_9P" . m)
1428 ("CONFIG_NET_9P_VIRTIO" . m)
1429 ("CONFIG_VIRTIO_BLK" . m)
1430 ("CONFIG_VIRTIO_NET" . m)
1431 ("CONFIG_VIRTIO_PCI" . m)
1432 ("CONFIG_VIRTIO_BALLOON" . m)
1433 ("CONFIG_VIRTIO_MMIO" . m)
1434 ("CONFIG_FUSE_FS" . m)
1435 ("CONFIG_CIFS" . m)
1436 ("CONFIG_9P_FS" . m)))
1437
1438(define (config->string options)
1439 (string-join (map (match-lambda
1440 ((option . 'm)
1441 (string-append option "=m"))
1442 ((option . #t)
1443 (string-append option "=y"))
1444 ((option . #f)
1445 (string-append option "=n")))
1446 options)
1447 "\n"))
b1eecb5c 1448@end lisp
7bc46ecc
RW
1449
1450And in the custom configure script from the `make-linux-libre` package:
1451
b1eecb5c 1452@lisp
7bc46ecc
RW
1453;; Appending works even when the option wasn't in the
1454;; file. The last one prevails if duplicated.
1455(let ((port (open-file ".config" "a"))
1456 (extra-configuration ,(config->string extra-options)))
1457 (display extra-configuration port)
1458 (close-port port))
1459
1460(invoke "make" "oldconfig"))))
b1eecb5c 1461@end lisp
7bc46ecc
RW
1462
1463So by not providing a configuration-file the @file{.config} starts blank, and
1464then we write into it the collection of flags that we want. Here's another
1465custom kernel:
1466
b1eecb5c 1467@lisp
7bc46ecc
RW
1468(define %macbook41-full-config
1469 (append %macbook41-config-options
1470 %filesystems
1471 %efi-support
1472 %emulation
1473 (@@@@ (gnu packages linux) %default-extra-linux-options)))
1474
1475(define-public linux-libre-macbook41
1476 ;; XXX: Access the internal 'make-linux-libre' procedure, which is
1477 ;; private and unexported, and is liable to change in the future.
1478 ((@@@@ (gnu packages linux) make-linux-libre) (@@@@ (gnu packages linux) %linux-libre-version)
1479 (@@@@ (gnu packages linux) %linux-libre-hash)
1480 '("x86_64-linux")
1481 #:extra-version "macbook41"
1482 #:patches (@@@@ (gnu packages linux) %linux-libre-5.1-patches)
1483 #:extra-options %macbook41-config-options))
b1eecb5c 1484@end lisp
7bc46ecc
RW
1485
1486In the above example @code{%filesystems} is a collection of flags enabling
1487different filesystem support, @code{%efi-support} enables EFI support and
1488@code{%emulation} enables a x86_64-linux machine to act in 32-bit mode also.
1489@code{%default-extra-linux-options} are the ones quoted above, which had to be
1490added in since they were replaced in the @code{extra-options} keyword.
1491
1492This all sounds like it should be doable, but how does one even know which
1493modules are required for a particular system? Two places that can be helpful
1494in trying to answer this question is the
1495@uref{https://wiki.gentoo.org/wiki/Handbook:AMD64/Installation/Kernel, Gentoo
1496Handbook} and the
1497@uref{https://www.kernel.org/doc/html/latest/admin-guide/README.html?highlight=localmodconfig,
1498documentation from the kernel itself}. From the kernel documentation, it
1499seems that @code{make localmodconfig} is the command we want.
1500
1501In order to actually run @code{make localmodconfig} we first need to get and
1502unpack the kernel source code:
1503
1504@example shell
1505tar xf $(guix build linux-libre --source)
1506@end example
1507
1508Once inside the directory containing the source code run @code{touch .config}
1509to create an initial, empty @file{.config} to start with. @code{make
1510localmodconfig} works by seeing what you already have in @file{.config} and
1511letting you know what you're missing. If the file is blank then you're
1512missing everything. The next step is to run:
1513
1514@example shell
1515guix environment linux-libre -- make localmodconfig
1516@end example
1517
1518and note the output. Do note that the @file{.config} file is still empty.
1519The output generally contains two types of warnings. The first start with
1520"WARNING" and can actually be ignored in our case. The second read:
1521
1522@example shell
1523module pcspkr did not have configs CONFIG_INPUT_PCSPKR
1524@end example
1525
1526For each of these lines, copy the @code{CONFIG_XXXX_XXXX} portion into the
1527@file{.config} in the directory, and append @code{=m}, so in the end it looks
1528like this:
1529
1530@example shell
1531CONFIG_INPUT_PCSPKR=m
1532CONFIG_VIRTIO=m
1533@end example
1534
1535After copying all the configuration options, run @code{make localmodconfig}
1536again to make sure that you don't have any output starting with "module".
1537After all of these machine specific modules there are a couple more left that
1538are also needed. @code{CONFIG_MODULES} is necessary so that you can build and
1539load modules separately and not have everything built into the kernel.
1540@code{CONFIG_BLK_DEV_SD} is required for reading from hard drives. It is
1541possible that there are other modules which you will need.
1542
1543This post does not aim to be a guide to configuring your own kernel however,
1544so if you do decide to build a custom kernel you'll have to seek out other
1545guides to create a kernel which is just right for your needs.
1546
1547The second way to setup the kernel configuration makes more use of Guix's
1548features and allows you to share configuration segments between different
1549kernels. For example, all machines using EFI to boot have a number of EFI
1550configuration flags that they need. It is likely that all the kernels will
1551share a list of filesystems to support. By using variables it is easier to
1552see at a glance what features are enabled and to make sure you don't have
1553features in one kernel but missing in another.
1554
1555Left undiscussed however, is Guix's initrd and its customization. It is
1556likely that you'll need to modify the initrd on a machine using a custom
1557kernel, since certain modules which are expected to be built may not be
1558available for inclusion into the initrd.
1559
4c463569
PN
1560@c *********************************************************************
1561@node Advanced package management
1562@chapter Advanced package management
1563
1564Guix is a functional package manager that offers many features beyond
1565what more traditional package managers can do. To the uninitiated,
1566those features might not have obvious use cases at first. The purpose
1567of this chapter is to demonstrate some advanced package management
1568concepts.
1569
1570@pxref{Package Management,,, guix, GNU Guix Reference Manual} for a complete
1571reference.
1572
1573@menu
1574* Guix Profiles in Practice:: Strategies for multiple profiles and manifests.
1575@end menu
1576
1577@node Guix Profiles in Practice
1578@section Guix Profiles in Practice
1579
1580Guix provides a very useful feature that may be quite foreign to newcomers:
1581@emph{profiles}. They are a way to group package installations together and all users
f6c27c55 1582on the same system are free to use as many profiles as they want.
4c463569
PN
1583
1584Whether you're a developer or not, you may find that multiple profiles bring you
1585great power and flexibility. While they shift the paradigm somewhat compared to
1586@emph{traditional package managers}, they are very convenient to use once you've
1587understood how to set them up.
1588
1589If you are familiar with Python's @samp{virtualenv}, you can think of a profile as a
1590kind of universal @samp{virtualenv} that can hold any kind of software whatsoever, not
1591just Python software. Furthermore, profiles are self-sufficient: they capture
1592all the runtime dependencies which guarantees that all programs within a profile
1593will always work at any point in time.
1594
1595Multiple profiles have many benefits:
1596
1597@itemize
1598@item
1599Clean semantic separation of the various packages a user needs for different contexts.
1600
1601@item
1602Multiple profiles can be made available into the environment either on login
1603or within a dedicated shell.
1604
1605@item
1606Profiles can be loaded on demand. For instance, the user can use multiple
1607shells, each of them running different profiles.
1608
1609@item
1610Isolation: Programs from one profile will not use programs from the other, and
f6c27c55 1611the user can even install different versions of the same programs to the two
4c463569
PN
1612profiles without conflict.
1613
1614@item
1615Deduplication: Profiles share dependencies that happens to be the exact same.
1616This makes multiple profiles storage-efficient.
1617
1618@item
1619Reproducible: when used with declarative manifests, a profile can be fully
1620specified by the Guix commit that was active when it was set up. This means
f6c27c55
PN
1621that the exact same profile can be
1622@uref{https://guix.gnu.org/blog/2018/multi-dimensional-transactions-and-rollbacks-oh-my/,
1623set up anywhere and anytime}, with just the commit information. See the
1624section on @ref{Reproducible profiles}.
4c463569
PN
1625
1626@item
1627Easier upgrades and maintenance: Multiple profiles make it easy to keep
1628package listings at hand and make upgrades completely friction-less.
1629@end itemize
1630
1631Concretely, here follows some typical profiles:
1632
1633@itemize
1634@item
1635The dependencies of a project you are working on.
1636
1637@item
1638Your favourite programming language libraries.
1639
1640@item
1641Laptop-specific programs (like @samp{powertop}) that you don't need on a desktop.
1642
1643@item
1644@TeX{}live (this one can be really useful when you need to install just one
1645package for this one document you've just received over email).
1646
1647@item
1648Games.
1649@end itemize
1650
1651Let's dive in the set up!
1652
1653@node Basic setup with manifests
1654@subsection Basic setup with manifests
1655
1656A Guix profile can be set up @emph{via} a so-called @emph{manifest specification} that looks like
1657this:
1658
b1eecb5c 1659@lisp
4c463569
PN
1660(specifications->manifest
1661 '("package-1"
1662 ;; Version 1.3 of package-2.
1663 "package-2@@1.3"
1664 ;; The "lib" output of package-3.
1665 "package-3:lib"
1666 ; ...
1667 "package-N"))
b1eecb5c 1668@end lisp
4c463569 1669
b1eecb5c 1670@pxref{Invoking guix package,,, guix, GNU Guix Reference Manual}, for
4c463569
PN
1671the syntax details.
1672
1673We can create a manifest specification per profile and install them this way:
1674
1675@example
1676GUIX_EXTRA_PROFILES=$HOME/.guix-extra-profiles
1677mkdir -p "$GUIX_EXTRA_PROFILES"/my-project # if it does not exist yet
1678guix package --manifest=/path/to/guix-my-project-manifest.scm --profile="$GUIX_EXTRA_PROFILES"/my-project/my-project
1679@end example
1680
1681Here we set an arbitrary variable @samp{GUIX_EXTRA_PROFILES} to point to the directory
1682where we will store our profiles in the rest of this article.
1683
1684Placing all your profiles in a single directory, with each profile getting its
1685own sub-directory, is somewhat cleaner. This way, each sub-directory will
1686contain all the symlinks for precisely one profile. Besides, "looping over
1687profiles" becomes obvious from any programming language (e.g. a shell script) by
1688simply looping over the sub-directories of @samp{$GUIX_EXTRA_PROFILES}.
1689
1690Note that it's also possible to loop over the output of
1691
1692@example
1693guix package --list-profiles
1694@end example
1695
1696although you'll probably have to filter out @samp{~/.config/guix/current}.
1697
1698To enable all profiles on login, add this to your @samp{~/.bash_profile} (or similar):
1699
1700@example
1701for i in $GUIX_EXTRA_PROFILES/*; do
1702 profile=$i/$(basename "$i")
1703 if [ -f "$profile"/etc/profile ]; then
1704 GUIX_PROFILE="$profile"
1705 . "$GUIX_PROFILE"/etc/profile
1706 fi
1707 unset profile
1708done
1709@end example
1710
1711Note to Guix System users: the above reflects how your default profile
1712@samp{~/.guix-profile} is activated from @samp{/etc/profile}, that latter being loaded by
1713@samp{~/.bashrc} by default.
1714
1715You can obviously choose to only enable a subset of them:
1716
1717@example
1718for i in "$GUIX_EXTRA_PROFILES"/my-project-1 "$GUIX_EXTRA_PROFILES"/my-project-2; do
1719 profile=$i/$(basename "$i")
1720 if [ -f "$profile"/etc/profile ]; then
1721 GUIX_PROFILE="$profile"
1722 . "$GUIX_PROFILE"/etc/profile
1723 fi
1724 unset profile
1725done
1726@end example
1727
1728When a profile is off, it's straightforward to enable it for an individual shell
1729without "polluting" the rest of the user session:
1730
1731@example
1732GUIX_PROFILE="path/to/my-project" ; . "$GUIX_PROFILE"/etc/profile
1733@end example
1734
1735The key to enabling a profile is to @emph{source} its @samp{etc/profile} file. This file
1736contains shell code that exports the right environment variables necessary to
1737activate the software contained in the profile. It is built automatically by
1738Guix and meant to be sourced.
1739It contains the same variables you would get if you ran:
1740
1741@example
1742guix package --search-paths=prefix --profile=$my_profile"
1743@end example
1744
1745Once again, see (@pxref{Invoking guix package,,, guix, GNU Guix Reference Manual})
1746for the command line options.
1747
1748To upgrade a profile, simply install the manifest again:
1749
1750@example
1751guix package -m /path/to/guix-my-project-manifest.scm -p "$GUIX_EXTRA_PROFILES"/my-project/my-project
1752@end example
1753
1754To upgrade all profiles, it's easy enough to loop over them. For instance,
1755assuming your manifest specifications are stored in
1756@samp{~/.guix-manifests/guix-$profile-manifest.scm}, with @samp{$profile} being the name
1757of the profile (e.g. "project1"), you could do the following in Bourne shell:
1758
1759@example
1760for profile in "$GUIX_EXTRA_PROFILES"/*; do
1761 guix package --profile="$profile" --manifest="$HOME/.guix-manifests/guix-$profile-manifest.scm"
1762done
1763@end example
1764
1765Each profile has its own generations:
1766
1767@example
1768guix package -p "$GUIX_EXTRA_PROFILES"/my-project/my-project --list-generations
1769@end example
1770
1771You can roll-back to any generation of a given profile:
1772
1773@example
1774guix package -p "$GUIX_EXTRA_PROFILES"/my-project/my-project --switch-generations=17
1775@end example
cb7b501d
PN
1776
1777Finally, if you want to switch to a profile without inheriting from the
1778current environment, you can activate it from an empty shell:
1779
1780@example
1781env -i $(which bash) --login --noprofile --norc
1782. my-project/etc/profile
1783@end example
4c463569
PN
1784
1785@node Required packages
1786@subsection Required packages
1787
1788Activating a profile essentially boils down to exporting a bunch of
1789environmental variables. This is the role of the @samp{etc/profile} within the
1790profile.
1791
1792@emph{Note: Only the environmental variables of the packages that consume them will
1793be set.}
1794
1795For instance, @samp{MANPATH} won't be set if there is no consumer application for man
1796pages within the profile. So if you need to transparently access man pages once
1797the profile is loaded, you've got two options:
1798
1799@itemize
1800@item
1801Either export the variable manually, e.g.
1802@example
f6c27c55 1803export MANPATH=/path/to/profile$@{MANPATH:+:@}$MANPATH
4c463569
PN
1804@end example
1805
1806@item
1807Or include @samp{man-db} to the profile manifest.
1808@end itemize
1809
1810The same is true for @samp{INFOPATH} (you can install @samp{info-reader}),
1811@samp{PKG_CONFIG_PATH} (install @samp{pkg-config}), etc.
1812
1813@node Default profile
1814@subsection Default profile
1815
1816What about the default profile that Guix keeps in @samp{~/.guix-profile}?
1817
1818You can assign it the role you want. Typically you would install the manifest
1819of the packages you want to use all the time.
1820
1821Alternatively, you could keep it "manifest-less" for throw-away packages
1822that you would just use for a couple of days.
1823This way makes it convenient to run
1824
1825@example
1826guix install package-foo
1827guix upgrade package-bar
1828@end example
1829
1830without having to specify the path to a profile.
1831
1832@node The benefits of manifests
1833@subsection The benefits of manifests
1834
1835Manifests are a convenient way to keep your package lists around and, say,
1836to synchronize them across multiple machines using a version control system.
1837
1838A common complaint about manifests is that they can be slow to install when they
1839contain large number of packages. This is especially cumbersome when you just
1840want get an upgrade for one package within a big manifest.
1841
1842This is one more reason to use multiple profiles, which happen to be just
1843perfect to break down manifests into multiple sets of semantically connected
1844packages. Using multiple, small profiles provides more flexibility and
1845usability.
1846
1847Manifests come with multiple benefits. In particular, they ease maintenance:
1848
1849@itemize
1850@item
1851When a profile is set up from a manifest, the manifest itself is
1852self-sufficient to keep a "package listing" around and reinstall the profile
1853later or on a different system. For ad-hoc profiles, we would need to
1854generate a manifest specification manually and maintain the package versions
1855for the packages that don't use the default version.
1856
1857@item
1858@code{guix package --upgrade} always tries to update the packages that have
1859propagated inputs, even if there is nothing to do. Guix manifests remove this
1860problem.
1861
1862@item
1863When partially upgrading a profile, conflicts may arise (due to diverging
1864dependencies between the updated and the non-updated packages) and they can be
1865annoying to resolve manually. Manifests remove this problem altogether since
1866all packages are always upgraded at once.
1867
1868@item
1869As mentioned above, manifests allow for reproducible profiles, while the
1870imperative @code{guix install}, @code{guix upgrade}, etc. do not, since they produce
1871different profiles every time even when they hold the same packages. See
1872@uref{https://issues.guix.gnu.org/issue/33285, the related discussion on the matter}.
1873
1874@item
1875Manifest specifications are usable by other @samp{guix} commands. For example, you
1876can run @code{guix weather -m manifest.scm} to see how many substitutes are
1877available, which can help you decide whether you want to try upgrading today
1878or wait a while. Another example: you can run @code{guix pack -m manifest.scm} to
1879create a pack containing all the packages in the manifest (and their
1880transitive references).
1881
1882@item
1883Finally, manifests have a Scheme representation, the @samp{<manifest>} record type.
1884They can be manipulated in Scheme and passed to the various Guix @uref{https://en.wikipedia.org/wiki/Api, APIs}.
1885@end itemize
1886
1887It's important to understand that while manifests can be used to declare
1888profiles, they are not strictly equivalent: profiles have the side effect that
1889they "pin" packages in the store, which prevents them from being
1890garbage-collected (@pxref{Invoking guix gc,,, guix, GNU Guix Reference Manual})
1891and ensures that they will still be available at any point in
1892the future.
1893
1894Let's take an example:
1895
1896@enumerate
1897@item
1898We have an environment for hacking on a project for which there isn't a Guix
1899package yet. We build the environment using a manifest, and then run @code{guix
1900 environment -m manifest.scm}. So far so good.
1901
1902@item
1903Many weeks pass and we have run a couple of @code{guix pull} in the mean time.
1904Maybe a dependency from our manifest has been updated; or we may have run
1905@code{guix gc} and some packages needed by our manifest have been
1906garbage-collected.
1907
1908@item
1909Eventually, we set to work on that project again, so we run @code{guix environment
1910 -m manifest.scm}. But now we have to wait for Guix to build and install
1911stuff!
1912@end enumerate
1913
1914Ideally, we could spare the rebuild time. And indeed we can, all we need is to
1915install the manifest to a profile and use @code{GUIX_PROFILE=/the/profile;
1916. "$GUIX_PROFILE"/etc/profile} as explained above: this guarantees that our
1917hacking environment will be available at all times.
1918
1919@emph{Security warning:} While keeping old profiles around can be convenient, keep in
1920mind that outdated packages may not have received the latest security fixes.
1921
1922@node Reproducible profiles
1923@subsection Reproducible profiles
1924
1925To reproduce a profile bit-for-bit, we need two pieces of information:
1926
1927@itemize
1928@item
1929a manifest,
1930@item
1931a Guix channel specification.
1932@end itemize
1933
1934Indeed, manifests alone might not be enough: different Guix versions (or
1935different channels) can produce different outputs for a given manifest.
1936
1937You can output the Guix channel specification with @samp{guix describe
1938--format=channels}.
1939Save this to a file, say @samp{channel-specs.scm}.
1940
1941On another computer, you can use the channel specification file and the manifest
1942to reproduce the exact same profile:
1943
1944@example
1945GUIX_EXTRA_PROFILES=$HOME/.guix-extra-profiles
1946GUIX_EXTRA=$HOME/.guix-extra
1947
1948mkdir "$GUIX_EXTRA"/my-project
1949guix pull --channels=channel-specs.scm --profile "$GUIX_EXTRA/my-project/guix"
1950
1951mkdir -p "$GUIX_EXTRA_PROFILES/my-project"
1952"$GUIX_EXTRA"/my-project/guix/bin/guix package --manifest=/path/to/guix-my-project-manifest.scm --profile="$GUIX_EXTRA_PROFILES"/my-project/my-project
1953@end example
1954
1955It's safe to delete the Guix channel profile you've just installed with the
1956channel specification, the project profile does not depend on it.
1957
7bc46ecc
RW
1958@c *********************************************************************
1959@node Acknowledgments
1960@chapter Acknowledgments
1961
1962Guix is based on the @uref{https://nixos.org/nix/, Nix package manager},
1963which was designed and
1964implemented by Eelco Dolstra, with contributions from other people (see
1965the @file{nix/AUTHORS} file in Guix.) Nix pioneered functional package
1966management, and promoted unprecedented features, such as transactional
1967package upgrades and rollbacks, per-user profiles, and referentially
1968transparent build processes. Without this work, Guix would not exist.
1969
1970The Nix-based software distributions, Nixpkgs and NixOS, have also been
1971an inspiration for Guix.
1972
1973GNU@tie{}Guix itself is a collective work with contributions from a
1974number of people. See the @file{AUTHORS} file in Guix for more
1975information on these fine people. The @file{THANKS} file lists people
1976who have helped by reporting bugs, taking care of the infrastructure,
1977providing artwork and themes, making suggestions, and more---thank you!
1978
1979This document includes adapted sections from articles that have previously
1980been published on the Guix blog at @uref{https://guix.gnu.org/blog}.
1981
1982
1983@c *********************************************************************
1984@node GNU Free Documentation License
1985@appendix GNU Free Documentation License
1986@cindex license, GNU Free Documentation License
1987@include fdl-1.3.texi
1988
1989@c *********************************************************************
1990@node Concept Index
1991@unnumbered Concept Index
1992@printindex cp
1993
1994@bye
1995
1996@c Local Variables:
1997@c ispell-local-dictionary: "american";
1998@c End: