system: hurd: Populate services.
[jackhill/guix/guix.git] / gnu / system.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
3 ;;; Copyright © 2015 Mark H Weaver <mhw@netris.org>
4 ;;; Copyright © 2015, 2016 Alex Kost <alezost@gmail.com>
5 ;;; Copyright © 2016 Chris Marusich <cmmarusich@gmail.com>
6 ;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
7 ;;; Copyright © 2019 Meiyo Peng <meiyo.peng@gmail.com>
8 ;;; Copyright © 2020 Danny Milosavljevic <dannym@scratchpost.org>
9 ;;; Copyright © 2020 Brice Waegeneire <brice@waegenei.re>
10 ;;; Copyright © 2020 Florian Pelz <pelzflorian@pelzflorian.de>
11 ;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com>
12 ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <jannek@gnu.org>
13 ;;;
14 ;;; This file is part of GNU Guix.
15 ;;;
16 ;;; GNU Guix is free software; you can redistribute it and/or modify it
17 ;;; under the terms of the GNU General Public License as published by
18 ;;; the Free Software Foundation; either version 3 of the License, or (at
19 ;;; your option) any later version.
20 ;;;
21 ;;; GNU Guix is distributed in the hope that it will be useful, but
22 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
23 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 ;;; GNU General Public License for more details.
25 ;;;
26 ;;; You should have received a copy of the GNU General Public License
27 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
28
29 (define-module (gnu system)
30 #:use-module (guix inferior)
31 #:use-module (guix store)
32 #:use-module (guix monads)
33 #:use-module (guix gexp)
34 #:use-module (guix records)
35 #:use-module (guix packages)
36 #:use-module (guix derivations)
37 #:use-module (guix profiles)
38 #:use-module (guix ui)
39 #:use-module (guix utils)
40 #:use-module (gnu packages base)
41 #:use-module (gnu packages bash)
42 #:use-module (gnu packages cross-base)
43 #:use-module (gnu packages guile)
44 #:use-module (gnu packages guile-xyz)
45 #:use-module (gnu packages admin)
46 #:use-module (gnu packages hurd)
47 #:use-module (gnu packages linux)
48 #:use-module (gnu packages pciutils)
49 #:use-module (gnu packages package-management)
50 #:use-module (gnu packages less)
51 #:use-module (gnu packages zile)
52 #:use-module (gnu packages nano)
53 #:use-module (gnu packages gawk)
54 #:use-module (gnu packages man)
55 #:use-module (gnu packages texinfo)
56 #:use-module (gnu packages compression)
57 #:use-module (gnu packages firmware)
58 #:use-module (gnu services)
59 #:use-module (gnu services shepherd)
60 #:use-module (gnu services base)
61 #:use-module (gnu bootloader)
62 #:use-module (gnu system shadow)
63 #:use-module (gnu system nss)
64 #:use-module (gnu system locale)
65 #:use-module (gnu system pam)
66 #:use-module (gnu system linux-initrd)
67 #:use-module (gnu system uuid)
68 #:use-module (gnu system file-systems)
69 #:use-module (gnu system mapped-devices)
70 #:use-module (ice-9 match)
71 #:use-module (srfi srfi-1)
72 #:use-module (srfi srfi-26)
73 #:use-module (srfi srfi-34)
74 #:use-module (srfi srfi-35)
75 #:use-module (rnrs bytevectors)
76 #:export (operating-system
77 operating-system?
78 this-operating-system
79
80 operating-system-bootloader
81 operating-system-services
82 operating-system-essential-services
83 operating-system-default-essential-services
84 operating-system-user-services
85 operating-system-packages
86 operating-system-host-name
87 operating-system-hosts-file
88 operating-system-hurd
89 operating-system-kernel
90 operating-system-kernel-file
91 operating-system-kernel-arguments
92 operating-system-label
93 operating-system-default-label
94 operating-system-initrd-modules
95 operating-system-initrd
96 operating-system-users
97 operating-system-groups
98 operating-system-issue
99 operating-system-timezone
100 operating-system-locale
101 operating-system-locale-definitions
102 operating-system-locale-libcs
103 operating-system-mapped-devices
104 operating-system-file-systems
105 operating-system-store-file-system
106 operating-system-user-mapped-devices
107 operating-system-boot-mapped-devices
108 operating-system-activation-script
109 operating-system-user-accounts
110 operating-system-shepherd-service-names
111 operating-system-user-kernel-arguments
112 operating-system-firmware
113 operating-system-keyboard-layout
114 operating-system-name-service-switch
115 operating-system-pam-services
116 operating-system-setuid-programs
117 operating-system-skeletons
118 operating-system-sudoers-file
119 operating-system-swap-devices
120 operating-system-kernel-loadable-modules
121
122 operating-system-derivation
123 operating-system-profile
124 operating-system-bootcfg
125 operating-system-etc-directory
126 operating-system-locale-directory
127 operating-system-boot-script
128 operating-system-uuid
129
130 system-linux-image-file-name
131 operating-system-with-gc-roots
132 operating-system-with-provenance
133
134 hurd-default-essential-services
135
136 boot-parameters
137 boot-parameters?
138 boot-parameters-label
139 boot-parameters-root-device
140 boot-parameters-bootloader-name
141 boot-parameters-bootloader-menu-entries
142 boot-parameters-store-device
143 boot-parameters-store-mount-point
144 boot-parameters-kernel
145 boot-parameters-kernel-arguments
146 boot-parameters-initrd
147 boot-parameters-multiboot-modules
148 read-boot-parameters
149 read-boot-parameters-file
150 boot-parameters->menu-entry
151
152 local-host-aliases
153 %root-account
154 %setuid-programs
155 %sudoers-specification
156 %base-packages
157 %base-packages-interactive
158 %base-packages-linux
159 %base-packages-networking
160 %base-packages-utils
161 %base-firmware
162 %default-kernel-arguments))
163
164 ;;; Commentary:
165 ;;;
166 ;;; This module supports whole-system configuration.
167 ;;;
168 ;;; Code:
169
170 (define (bootable-kernel-arguments system root-device)
171 "Return a list of kernel arguments (gexps) to boot SYSTEM from ROOT-DEVICE."
172 (list (string-append "--root="
173 ;; Note: Always use the DCE format because that's what
174 ;; (gnu build linux-boot) expects for the '--root'
175 ;; kernel command-line option.
176 (file-system-device->string root-device
177 #:uuid-type 'dce))
178 #~(string-append "--system=" #$system)
179 #~(string-append "--load=" #$system "/boot")))
180
181 ;; System-wide configuration.
182 ;; TODO: Add per-field docstrings/stexi.
183 (define-record-type* <operating-system> operating-system
184 make-operating-system
185 operating-system?
186 this-operating-system
187
188 (kernel operating-system-kernel ; package
189 (default linux-libre))
190 (kernel-loadable-modules operating-system-kernel-loadable-modules
191 (default '())) ; list of packages
192 (kernel-arguments operating-system-user-kernel-arguments
193 (default %default-kernel-arguments)) ; list of gexps/strings
194 (hurd operating-system-hurd
195 (default #f)) ; package
196 (bootloader operating-system-bootloader) ; <bootloader-configuration>
197 (label operating-system-label ; string
198 (thunked)
199 (default (operating-system-default-label this-operating-system)))
200
201 (keyboard-layout operating-system-keyboard-layout ;#f | <keyboard-layout>
202 (default #f))
203 (initrd operating-system-initrd ; (list fs) -> file-like
204 (default base-initrd))
205 (initrd-modules operating-system-initrd-modules ; list of strings
206 (thunked) ; it's system-dependent
207 (default %base-initrd-modules))
208
209 (firmware operating-system-firmware ; list of packages
210 (default %base-firmware))
211
212 (host-name operating-system-host-name) ; string
213 (hosts-file operating-system-hosts-file ; file-like | #f
214 (default #f))
215
216 (mapped-devices operating-system-mapped-devices ; list of <mapped-device>
217 (default '()))
218 (file-systems operating-system-file-systems) ; list of fs
219 (swap-devices operating-system-swap-devices ; list of strings
220 (default '()))
221
222 (users operating-system-users ; list of user accounts
223 (default %base-user-accounts))
224 (groups operating-system-groups ; list of user groups
225 (default %base-groups))
226
227 (skeletons operating-system-skeletons ; list of name/file-like value
228 (default (default-skeletons)))
229 (issue operating-system-issue ; string
230 (default %default-issue))
231
232 (packages operating-system-packages ; list of (PACKAGE OUTPUT...)
233 (default %base-packages)) ; or just PACKAGE
234
235 (timezone operating-system-timezone) ; string
236 (locale operating-system-locale ; string
237 (default "en_US.utf8"))
238 (locale-definitions operating-system-locale-definitions ; list of <locale-definition>
239 (default %default-locale-definitions))
240 (locale-libcs operating-system-locale-libcs ; list of <packages>
241 (default %default-locale-libcs))
242 (name-service-switch operating-system-name-service-switch ; <name-service-switch>
243 (default %default-nss))
244
245 (essential-services operating-system-essential-services ; list of services
246 (thunked)
247 (default (operating-system-default-essential-services
248 this-operating-system)))
249 (services operating-system-user-services ; list of services
250 (default %base-services))
251
252 (pam-services operating-system-pam-services ; list of PAM services
253 (default (base-pam-services)))
254 (setuid-programs operating-system-setuid-programs
255 (default %setuid-programs)) ; list of string-valued gexps
256
257 (sudoers-file operating-system-sudoers-file ; file-like
258 (default %sudoers-specification)))
259
260 (define (operating-system-kernel-arguments os root-device)
261 "Return all the kernel arguments, including the ones not specified
262 directly by the user."
263 (append (bootable-kernel-arguments os root-device)
264 (operating-system-user-kernel-arguments os)))
265
266 \f
267 ;;;
268 ;;; Boot parameters
269 ;;;
270
271 (define-record-type* <boot-parameters>
272 boot-parameters make-boot-parameters boot-parameters?
273 (label boot-parameters-label)
274 ;; Because we will use the 'store-device' to create the GRUB search command,
275 ;; the 'store-device' has slightly different semantics than 'root-device'.
276 ;; The 'store-device' can be a file system uuid, a file system label, or #f,
277 ;; but it cannot be a device path such as "/dev/sda3", since GRUB would not
278 ;; understand that. The 'root-device', on the other hand, corresponds
279 ;; exactly to the device field of the <file-system> object representing the
280 ;; OS's root file system, so it might be a device path like "/dev/sda3".
281 (root-device boot-parameters-root-device)
282 (bootloader-name boot-parameters-bootloader-name)
283 (bootloader-menu-entries ;list of <menu-entry>
284 boot-parameters-bootloader-menu-entries)
285 (store-device boot-parameters-store-device)
286 (store-mount-point boot-parameters-store-mount-point)
287 (kernel boot-parameters-kernel)
288 (kernel-arguments boot-parameters-kernel-arguments)
289 (initrd boot-parameters-initrd)
290 (multiboot-modules boot-parameters-multiboot-modules))
291
292 (define (ensure-not-/dev device)
293 "If DEVICE starts with a slash, return #f. This is meant to filter out
294 Linux device names such as /dev/sda, and to preserve GRUB device names and
295 file system labels."
296 (if (and (string? device) (string-prefix? "/" device))
297 #f
298 device))
299
300 (define (read-boot-parameters port)
301 "Read boot parameters from PORT and return the corresponding
302 <boot-parameters> object or #f if the format is unrecognized."
303 (define device-sexp->device
304 (match-lambda
305 (('uuid (? symbol? type) (? bytevector? bv))
306 (bytevector->uuid bv type))
307 (('file-system-label (? string? label))
308 (file-system-label label))
309 ((? bytevector? bv) ;old format
310 (bytevector->uuid bv 'dce))
311 ((? string? device)
312 ;; It used to be that we would not distinguish between labels and
313 ;; device names. Try to infer the right thing here.
314 (if (string-prefix? "/dev/" device)
315 device
316 (file-system-label device)))))
317
318 (match (read port)
319 (('boot-parameters ('version 0)
320 ('label label) ('root-device root)
321 ('kernel kernel)
322 rest ...)
323 (boot-parameters
324 (label label)
325 (root-device (device-sexp->device root))
326
327 (bootloader-name
328 (match (assq 'bootloader-name rest)
329 ((_ args) args)
330 (#f 'grub))) ; for compatibility reasons.
331
332 (bootloader-menu-entries
333 (match (assq 'bootloader-menu-entries rest)
334 ((_ entries) (map sexp->menu-entry entries))
335 (#f '())))
336
337 ;; In the past, we would store the directory name of linux instead of
338 ;; the absolute file name of its image. Detect that and correct it.
339 (kernel (if (string=? kernel (direct-store-path kernel))
340 (string-append kernel "/"
341 (system-linux-image-file-name))
342 kernel))
343
344 (kernel-arguments
345 (match (assq 'kernel-arguments rest)
346 ((_ args) args)
347 (#f '()))) ;the old format
348
349 (initrd
350 (match (assq 'initrd rest)
351 (('initrd ('string-append directory file)) ;the old format
352 (string-append directory file))
353 (('initrd (? string? file))
354 file)))
355
356 (multiboot-modules (or (assq 'multiboot-modules rest) '()))
357
358 (store-device
359 ;; Linux device names like "/dev/sda1" are not suitable GRUB device
360 ;; identifiers, so we just filter them out.
361 (ensure-not-/dev
362 (match (assq 'store rest)
363 (('store ('device #f) _ ...)
364 root-device)
365 (('store ('device device) _ ...)
366 (device-sexp->device device))
367 (_ ;the old format
368 root-device))))
369
370 (store-mount-point
371 (match (assq 'store rest)
372 (('store ('device _) ('mount-point mount-point) _ ...)
373 mount-point)
374 (_ ;the old format
375 "/")))))
376 (x ;unsupported format
377 (warning (G_ "unrecognized boot parameters at '~a'~%")
378 (port-filename port))
379 #f)))
380
381 (define (read-boot-parameters-file system)
382 "Read boot parameters from SYSTEM's (system or generation) \"parameters\"
383 file and returns the corresponding <boot-parameters> object or #f if the
384 format is unrecognized.
385 The object has its kernel-arguments extended in order to make it bootable."
386 (let* ((file (string-append system "/parameters"))
387 (params (call-with-input-file file read-boot-parameters))
388 (root (boot-parameters-root-device params)))
389 (boot-parameters
390 (inherit params)
391 (kernel-arguments (append (bootable-kernel-arguments system root)
392 (boot-parameters-kernel-arguments params))))))
393
394 (define (boot-parameters->menu-entry conf)
395 (let* ((kernel (boot-parameters-kernel conf))
396 (multiboot-modules (boot-parameters-multiboot-modules conf))
397 (multiboot? (pair? multiboot-modules)))
398 (menu-entry
399 (label (boot-parameters-label conf))
400 (device (boot-parameters-store-device conf))
401 (device-mount-point (boot-parameters-store-mount-point conf))
402 (linux (and (not multiboot?) kernel))
403 (linux-arguments (if (not multiboot?) '
404 (boot-parameters-kernel-arguments conf)
405 '()))
406 (initrd (boot-parameters-initrd conf))
407 (multiboot-kernel (and multiboot? kernel))
408 (multiboot-arguments (if multiboot?
409 (boot-parameters-kernel-arguments conf)
410 '()))
411 (multiboot-modules (if multiboot?
412 (boot-parameters-multiboot-modules conf)
413 '())))))
414
415 \f
416 ;;;
417 ;;; Services.
418 ;;;
419
420 (define (non-boot-file-system-service os)
421 "Return the file system service for the file systems of OS that are not
422 marked as 'needed-for-boot'."
423 (define file-systems
424 (remove file-system-needed-for-boot?
425 (operating-system-file-systems os)))
426
427 (define mapped-devices-for-boot
428 (operating-system-boot-mapped-devices os))
429
430 (define (device-mappings fs)
431 (let ((device (file-system-device fs)))
432 (if (string? device) ;title is 'device
433 (filter (lambda (md)
434 (string=? (string-append "/dev/mapper/"
435 (mapped-device-target md))
436 device))
437 (operating-system-mapped-devices os))
438 '())))
439
440 (define (add-dependencies fs)
441 ;; Add the dependencies due to device mappings to FS.
442 (file-system
443 (inherit fs)
444 (dependencies
445 (delete-duplicates
446 (remove (cut member <> mapped-devices-for-boot)
447 (append (device-mappings fs)
448 (file-system-dependencies fs)))
449 eq?))))
450
451 (service file-system-service-type
452 (map add-dependencies file-systems)))
453
454 (define (mapped-device-users device file-systems)
455 "Return the subset of FILE-SYSTEMS that use DEVICE."
456 (let ((target (string-append "/dev/mapper/" (mapped-device-target device))))
457 (filter (lambda (fs)
458 (or (member device (file-system-dependencies fs))
459 (and (string? (file-system-device fs))
460 (string=? (file-system-device fs) target))))
461 file-systems)))
462
463 (define (operating-system-user-mapped-devices os)
464 "Return the subset of mapped devices that can be installed in
465 user-land--i.e., those not needed during boot."
466 (let ((devices (operating-system-mapped-devices os))
467 (file-systems (operating-system-file-systems os)))
468 (filter (lambda (md)
469 (let ((users (mapped-device-users md file-systems)))
470 (not (any file-system-needed-for-boot? users))))
471 devices)))
472
473 (define (operating-system-boot-mapped-devices os)
474 "Return the subset of mapped devices that must be installed during boot,
475 from the initrd."
476 (let ((devices (operating-system-mapped-devices os))
477 (file-systems (operating-system-file-systems os)))
478 (filter (lambda (md)
479 (let ((users (mapped-device-users md file-systems)))
480 (any file-system-needed-for-boot? users)))
481 devices)))
482
483 (define (device-mapping-services os)
484 "Return the list of device-mapping services for OS as a list."
485 (map device-mapping-service
486 (operating-system-user-mapped-devices os)))
487
488 (define (swap-services os)
489 "Return the list of swap services for OS."
490 (map swap-service (operating-system-swap-devices os)))
491
492 (define* (system-linux-image-file-name #:optional
493 (target (or (%current-target-system)
494 (%current-system))))
495 "Return the basename of the kernel image file for TARGET."
496 (cond
497 ((string-prefix? "arm" target) "zImage")
498 ((string-prefix? "mips" target) "vmlinuz")
499 ((string-prefix? "aarch64" target) "Image")
500 (else "bzImage")))
501
502 (define (operating-system-kernel-file os)
503 "Return an object representing the absolute file name of the kernel image of
504 OS."
505 (if (operating-system-hurd os)
506 (file-append (operating-system-kernel os) "/boot/gnumach")
507 (file-append (operating-system-kernel os)
508 "/" (system-linux-image-file-name))))
509
510 (define (package-for-kernel target-kernel module-package)
511 "Return a package like MODULE-PACKAGE, adapted for TARGET-KERNEL, if
512 possible (that is if there's a LINUX keyword argument in the build system)."
513 (package
514 (inherit module-package)
515 (arguments
516 (substitute-keyword-arguments (package-arguments module-package)
517 ((#:linux kernel #f)
518 target-kernel)))))
519
520 (define %default-modprobe-blacklist
521 ;; List of kernel modules to blacklist by default.
522 '("usbmouse" ;races with bcm5974, see <https://bugs.gnu.org/35574>
523 "usbkbd")) ;races with usbhid, see <https://issues.guix.gnu.org/35574#18>
524
525 (define %default-kernel-arguments
526 ;; Default arguments passed to the kernel.
527 (list (string-append "modprobe.blacklist="
528 (string-join %default-modprobe-blacklist ","))
529 "quiet"))
530
531 (define* (operating-system-directory-base-entries os)
532 "Return the basic entries of the 'system' directory of OS for use as the
533 value of the SYSTEM-SERVICE-TYPE service."
534 (let* ((locale (operating-system-locale-directory os))
535 (kernel (operating-system-kernel os))
536 (modules (operating-system-kernel-loadable-modules os))
537 (kernel (profile
538 (content (packages->manifest
539 (cons kernel
540 (map (lambda (module)
541 (if (package? module)
542 (package-for-kernel kernel
543 module)
544 module))
545 modules))))
546 (hooks (list linux-module-database))))
547 (initrd (operating-system-initrd-file os))
548 (params (operating-system-boot-parameters-file os)))
549 `(("kernel" ,kernel)
550 ("parameters" ,params)
551 ("initrd" ,initrd)
552 ("locale" ,locale)))) ;used by libc
553
554 (define (operating-system-default-essential-services os)
555 "Return the list of essential services for OS. These are special services
556 that implement part of what's declared in OS are responsible for low-level
557 bookkeeping."
558 (define known-fs
559 (map file-system-mount-point (operating-system-file-systems os)))
560
561 (let* ((mappings (device-mapping-services os))
562 (root-fs (root-file-system-service))
563 (other-fs (non-boot-file-system-service os))
564 (swaps (swap-services os))
565 (procs (service user-processes-service-type))
566 (host-name (host-name-service (operating-system-host-name os)))
567 (entries (operating-system-directory-base-entries os)))
568 (cons* (service system-service-type entries)
569 %boot-service
570
571 ;; %SHEPHERD-ROOT-SERVICE must come last so that the gexp that
572 ;; execs shepherd comes last in the boot script (XXX). Likewise,
573 ;; the cleanup service must come first so that its gexp runs before
574 ;; activation code.
575 (service cleanup-service-type #f)
576 %activation-service
577 %shepherd-root-service
578
579 (pam-root-service (operating-system-pam-services os))
580 (account-service (append (operating-system-accounts os)
581 (operating-system-groups os))
582 (operating-system-skeletons os))
583 (operating-system-etc-service os)
584 (service fstab-service-type
585 (filter file-system-needed-for-boot?
586 (operating-system-file-systems os)))
587 (session-environment-service
588 (operating-system-environment-variables os))
589 host-name procs root-fs
590 (service setuid-program-service-type
591 (operating-system-setuid-programs os))
592 (service profile-service-type
593 (operating-system-packages os))
594 other-fs
595 (append mappings swaps
596
597 ;; Add the firmware service.
598 (list %linux-bare-metal-service
599 (service firmware-service-type
600 (operating-system-firmware os)))))))
601
602 (define (hurd-default-essential-services os)
603 (list (service system-service-type '())
604 %boot-service
605 %activation-service
606 %shepherd-root-service
607 (service user-processes-service-type)
608 (account-service (append (operating-system-accounts os)
609 (operating-system-groups os))
610 (operating-system-skeletons os))
611 (root-file-system-service)
612 (service file-system-service-type '())
613 (service fstab-service-type
614 (filter file-system-needed-for-boot?
615 (operating-system-file-systems os)))
616 (pam-root-service (operating-system-pam-services os))
617 (operating-system-etc-service os)
618 (service profile-service-type (operating-system-packages os))))
619
620 (define* (operating-system-services os)
621 "Return all the services of OS, including \"essential\" services."
622 (instantiate-missing-services
623 (append (operating-system-user-services os)
624 (operating-system-essential-services os))))
625
626 (define (operating-system-with-gc-roots os roots)
627 "Return a variant of OS where ROOTS are registered as GC roots."
628 (operating-system
629 (inherit os)
630
631 ;; We use this procedure for the installation OS, which already defines GC
632 ;; roots. Add ROOTS to those.
633 (services (cons (simple-service 'extra-root
634 gc-root-service-type roots)
635 (operating-system-user-services os)))))
636
637 (define* (operating-system-with-provenance os #:optional config-file)
638 "Return a variant of OS that stores its own provenance information,
639 including CONFIG-FILE, if available. This is achieved by adding an instance
640 of PROVENANCE-SERVICE-TYPE to its services."
641 (operating-system
642 (inherit os)
643 (services (cons (service provenance-service-type config-file)
644 (operating-system-user-services os)))))
645
646 \f
647 ;;;
648 ;;; /etc.
649 ;;;
650
651 (define %base-firmware
652 ;; Firmware usable by default.
653 (list ath9k-htc-firmware
654 openfwwf-firmware))
655
656 (define %base-packages-utils
657 ;; Default set of utilities packages.
658 (cons* procps psmisc which
659 (@ (gnu packages admin) shadow) ;for 'passwd'
660
661 guile-3.0
662
663 ;; The packages below are also in %FINAL-INPUTS, so take them from
664 ;; there to avoid duplication.
665 (list bash coreutils findutils grep sed
666 diffutils patch gawk tar gzip bzip2 xz lzip)))
667
668 (define %base-packages-linux
669 ;; Default set of linux specific packages.
670 (list pciutils usbutils
671 util-linux+udev
672 ;; Get 'insmod' & co. from kmod, not module-init-tools, since udev
673 ;; already depends on it anyway.
674 kmod eudev))
675
676 (define %base-packages-interactive
677 ;; Default set of common interactive packages.
678 (list less zile nano
679 man-db
680 info-reader ;the standalone Info reader (no Perl)
681 bash-completion
682 kbd
683 ;; The 'sudo' command is already in %SETUID-PROGRAMS, but we also
684 ;; want the other commands and the man pages (notably because
685 ;; auto-completion in Emacs shell relies on man pages.)
686 sudo
687 guile-readline guile-colorized))
688
689 (define %base-packages-networking
690 ;; Default set of networking packages.
691 (list inetutils isc-dhcp
692 iproute
693 ;; wireless-tools is deprecated in favor of iw, but it's still what
694 ;; many people are familiar with, so keep it around.
695 iw wireless-tools))
696
697 (define %base-packages
698 ;; Default set of packages globally visible. It should include anything
699 ;; required for basic administrator tasks.
700 (append (list e2fsprogs)
701 %base-packages-interactive
702 %base-packages-linux
703 %base-packages-networking
704 %base-packages-utils))
705
706 (define %default-issue
707 ;; Default contents for /etc/issue.
708 "
709 This is the GNU system. Welcome.\n")
710
711 (define (local-host-aliases host-name)
712 "Return aliases for HOST-NAME, to be used in /etc/hosts."
713 (string-append "127.0.0.1 localhost " host-name "\n"
714 "::1 localhost " host-name "\n"))
715
716 (define (default-/etc/hosts host-name)
717 "Return the default /etc/hosts file."
718 (plain-file "hosts" (local-host-aliases host-name)))
719
720 (define* (operating-system-etc-service os)
721 "Return a <service> that builds containing the static part of the /etc
722 directory."
723 (let* ((login.defs
724 (plain-file "login.defs"
725 (string-append
726 "# Default paths for non-login shells started by su(1).\n"
727 "ENV_PATH /run/setuid-programs:"
728 "/run/current-system/profile/bin:"
729 "/run/current-system/profile/sbin\n"
730 "ENV_SUPATH /run/setuid-programs:"
731 "/run/current-system/profile/bin:"
732 "/run/current-system/profile/sbin\n")))
733
734 (hurd (operating-system-hurd os))
735 (issue (plain-file "issue" (operating-system-issue os)))
736 (nsswitch (operating-system-name-service-switch os))
737 (nsswitch (and nsswitch
738 (plain-file "nsswitch.conf"
739 (name-service-switch->string nsswitch))))
740 (sudoers (operating-system-sudoers-file os))
741
742 ;; Startup file for POSIX-compliant login shells, which set system-wide
743 ;; environment variables.
744 (profile (mixed-text-file "profile" "\
745 # Crucial variables that could be missing in the profiles' 'etc/profile'
746 # because they would require combining both profiles.
747 # FIXME: See <http://bugs.gnu.org/20255>.
748 export MANPATH=$HOME/.guix-profile/share/man:/run/current-system/profile/share/man
749 export INFOPATH=$HOME/.guix-profile/share/info:/run/current-system/profile/share/info
750 export XDG_DATA_DIRS=$HOME/.guix-profile/share:/run/current-system/profile/share
751 export XDG_CONFIG_DIRS=$HOME/.guix-profile/etc/xdg:/run/current-system/profile/etc/xdg
752
753 # Make sure libXcursor finds cursors installed into user or system profiles. See <http://bugs.gnu.org/24445>
754 export XCURSOR_PATH=$HOME/.icons:$HOME/.guix-profile/share/icons:/run/current-system/profile/share/icons
755
756 # Ignore the default value of 'PATH'.
757 unset PATH
758
759 # Load the system profile's settings.
760 GUIX_PROFILE=/run/current-system/profile ; \\
761 . /run/current-system/profile/etc/profile
762
763 # Since 'lshd' does not use pam_env, /etc/environment must be explicitly
764 # loaded when someone logs in via SSH. See <http://bugs.gnu.org/22175>.
765 # We need 'PATH' to be defined here, for 'cat' and 'cut'. Do this before
766 # reading the user's 'etc/profile' to allow variables to be overridden.
767 if [ -f /etc/environment -a -n \"$SSH_CLIENT\" \\
768 -a -z \"$LINUX_MODULE_DIRECTORY\" ]
769 then
770 . /etc/environment
771 export `cat /etc/environment | cut -d= -f1`
772 fi
773
774 # Arrange so that ~/.config/guix/current comes first.
775 for profile in \"$HOME/.guix-profile\" \"$HOME/.config/guix/current\"
776 do
777 if [ -f \"$profile/etc/profile\" ]
778 then
779 # Load the user profile's settings.
780 GUIX_PROFILE=\"$profile\" ; \\
781 . \"$profile/etc/profile\"
782 else
783 # At least define this one so that basic things just work
784 # when the user installs their first package.
785 export PATH=\"$profile/bin:$PATH\"
786 fi
787 done
788
789 # Prepend setuid programs.
790 export PATH=/run/setuid-programs:$PATH
791
792 # Arrange so that ~/.config/guix/current/share/info comes first.
793 export INFOPATH=\"$HOME/.config/guix/current/share/info:$INFOPATH\"
794
795 # Set the umask, notably for users logging in via 'lsh'.
796 # See <http://bugs.gnu.org/22650>.
797 umask 022
798
799 # Allow Hunspell-based applications (IceCat, LibreOffice, etc.) to
800 # find dictionaries.
801 export DICPATH=\"$HOME/.guix-profile/share/hunspell:/run/current-system/profile/share/hunspell\"
802
803 # Allow GStreamer-based applications to find plugins.
804 export GST_PLUGIN_PATH=\"$HOME/.guix-profile/lib/gstreamer-1.0\"
805
806 if [ -n \"$BASH_VERSION\" -a -f /etc/bashrc ]
807 then
808 # Load Bash-specific initialization code.
809 . /etc/bashrc
810 fi
811 "))
812
813 (bashrc (plain-file "bashrc" "\
814 # Bash-specific initialization.
815
816 # The 'bash-completion' package.
817 if [ -f /run/current-system/profile/etc/profile.d/bash_completion.sh ]
818 then
819 # Bash-completion sources ~/.bash_completion. It installs a dynamic
820 # completion loader that searches its own completion files as well
821 # as those in ~/.guix-profile and /run/current-system/profile.
822 source /run/current-system/profile/etc/profile.d/bash_completion.sh
823 fi\n")))
824 (etc-service
825 `(("services" ,(file-append net-base "/etc/services"))
826 ("protocols" ,(file-append net-base "/etc/protocols"))
827 ("rpc" ,(file-append net-base "/etc/rpc"))
828 ("login.defs" ,#~#$login.defs)
829 ("issue" ,#~#$issue)
830 ,@(if nsswitch `(("nsswitch.conf" ,#~#$nsswitch)) '())
831 ("profile" ,#~#$profile)
832 ("bashrc" ,#~#$bashrc)
833 ("hosts" ,#~#$(or (operating-system-hosts-file os)
834 (default-/etc/hosts (operating-system-host-name os))))
835 ;; Write the operating-system-host-name to /etc/hostname to prevent
836 ;; NetworkManager from changing the system's hostname when connecting
837 ;; to certain networks. Some discussion at
838 ;; https://lists.gnu.org/archive/html/help-guix/2017-09/msg00037.html
839 ("hostname" ,(plain-file "hostname" (operating-system-host-name os)))
840 ;; Some programs (e.g., GLib) look at /etc/timezone to find the
841 ;; name of the current timezone. For details, see
842 ;; https://lists.gnu.org/archive/html/guix-devel/2019-07/msg00166.html
843 ("timezone" ,(plain-file "timezone" (operating-system-timezone os)))
844 ("localtime" ,(file-append tzdata "/share/zoneinfo/"
845 (operating-system-timezone os)))
846 ,@(if sudoers `(("sudoers" ,sudoers)) '())
847 ,@(if hurd
848 `(("login" ,(file-append hurd "/etc/login"))
849 ("motd" ,(file-append hurd "/etc/motd")))
850 '())))))
851
852 (define %root-account
853 ;; Default root account.
854 (user-account
855 (name "root")
856 (password "")
857 (uid 0) (group "root")
858 (comment "System administrator")
859 (home-directory "/root")))
860
861 (define (operating-system-accounts os)
862 "Return the user accounts for OS, including an obligatory 'root' account,
863 and excluding accounts requested by services."
864 ;; Make sure there's a root account.
865 (if (find (lambda (user)
866 (and=> (user-account-uid user) zero?))
867 (operating-system-users os))
868 (operating-system-users os)
869 (cons %root-account (operating-system-users os))))
870
871 (define (maybe-string->file file-name thing)
872 "If THING is a string, return a <plain-file> with THING as its content.
873 Otherwise just return THING.
874
875 This is for backward-compatibility of fields that used to be strings and are
876 now file-like objects.."
877 (match thing
878 ((? string?)
879 (warning (G_ "using a string for file '~a' is deprecated; \
880 use 'plain-file' instead~%")
881 file-name)
882 (plain-file file-name thing))
883 (x
884 x)))
885
886 (define (maybe-file->monadic file-name thing)
887 "If THING is a value in %STORE-MONAD, return it as is; otherwise return
888 THING in the %STORE-MONAD.
889
890 This is for backward-compatibility of fields that used to be monadic values
891 and are now file-like objects."
892 (with-monad %store-monad
893 (match thing
894 ((? procedure?)
895 (warning (G_ "using a monadic value for '~a' is deprecated; \
896 use 'plain-file' instead~%")
897 file-name)
898 thing)
899 (x
900 (return x)))))
901
902 (define (operating-system-etc-directory os)
903 "Return that static part of the /etc directory of OS."
904 (etc-directory
905 (fold-services (operating-system-services os)
906 #:target-type etc-service-type)))
907
908 (define (operating-system-environment-variables os)
909 "Return the environment variables of OS for
910 @var{session-environment-service-type}, to be used in @file{/etc/environment}."
911 `(("LANG" . ,(operating-system-locale os))
912 ;; Note: No need to set 'TZ' since (1) we provide /etc/localtime, and (2)
913 ;; it doesn't work for setuid binaries. See <https://bugs.gnu.org/29212>.
914 ("TZDIR" . ,(file-append tzdata "/share/zoneinfo"))
915 ;; Tell 'modprobe' & co. where to look for modules.
916 ("LINUX_MODULE_DIRECTORY" . "/run/booted-system/kernel/lib/modules")
917 ;; These variables are honored by OpenSSL (libssl) and Git.
918 ("SSL_CERT_DIR" . "/etc/ssl/certs")
919 ("SSL_CERT_FILE" . "/etc/ssl/certs/ca-certificates.crt")
920 ("GIT_SSL_CAINFO" . "/etc/ssl/certs/ca-certificates.crt")
921
922 ;; 'GTK_DATA_PREFIX' must name one directory where GTK+ themes are
923 ;; searched for.
924 ("GTK_DATA_PREFIX" . "/run/current-system/profile")
925
926 ;; By default, applications that use D-Bus, such as Emacs, abort at startup
927 ;; when /etc/machine-id is missing. Make sure these warnings are non-fatal.
928 ("DBUS_FATAL_WARNINGS" . "0")
929
930 ;; XXX: Normally we wouldn't need to do this, but our glibc@2.23 package
931 ;; used to look things up in 'PREFIX/lib/locale' instead of
932 ;; '/run/current-system/locale' as was intended. Keep this hack around so
933 ;; that people who still have glibc@2.23-using packages in their profiles
934 ;; can use them correctly.
935 ;; TODO: Remove when glibc@2.23 is long gone.
936 ("GUIX_LOCPATH" . "/run/current-system/locale")))
937
938 (define %setuid-programs
939 ;; Default set of setuid-root programs.
940 (let ((shadow (@ (gnu packages admin) shadow)))
941 (list (file-append shadow "/bin/passwd")
942 (file-append shadow "/bin/su")
943 (file-append shadow "/bin/newuidmap")
944 (file-append shadow "/bin/newgidmap")
945 (file-append inetutils "/bin/ping")
946 (file-append inetutils "/bin/ping6")
947 (file-append sudo "/bin/sudo")
948 (file-append sudo "/bin/sudoedit")
949 (file-append fuse "/bin/fusermount")
950
951 ;; To allow mounts with the "user" option, "mount" and "umount" must
952 ;; be setuid-root.
953 (file-append util-linux "/bin/mount")
954 (file-append util-linux "/bin/umount"))))
955
956 (define %sudoers-specification
957 ;; Default /etc/sudoers contents: 'root' and all members of the 'wheel'
958 ;; group can do anything. See
959 ;; <http://www.sudo.ws/sudo/man/1.8.10/sudoers.man.html>.
960 ;; TODO: Add a declarative API.
961 (plain-file "sudoers" "\
962 root ALL=(ALL) ALL
963 %wheel ALL=(ALL) ALL\n"))
964
965 (define* (operating-system-activation-script os)
966 "Return the activation script for OS---i.e., the code that \"activates\" the
967 stateful part of OS, including user accounts and groups, special directories,
968 etc."
969 (let* ((services (operating-system-services os))
970 (activation (fold-services services
971 #:target-type activation-service-type)))
972 (activation-service->script activation)))
973
974 (define* (operating-system-boot-script os)
975 "Return the boot script for OS---i.e., the code started by the initrd once
976 we're running in the final root."
977 (let* ((services (operating-system-services os))
978 (boot (fold-services services #:target-type boot-service-type)))
979 (service-value boot)))
980
981 (define (operating-system-user-accounts os)
982 "Return the list of user accounts of OS."
983 (let* ((services (operating-system-services os))
984 (account (fold-services services
985 #:target-type account-service-type)))
986 (filter user-account?
987 (service-value account))))
988
989 (define (operating-system-shepherd-service-names os)
990 "Return the list of Shepherd service names for OS."
991 (append-map shepherd-service-provision
992 (service-value
993 (fold-services (operating-system-services os)
994 #:target-type
995 shepherd-root-service-type))))
996
997 (define* (operating-system-derivation os)
998 "Return a derivation that builds OS."
999 (let* ((services (operating-system-services os))
1000 (system (fold-services services)))
1001 ;; SYSTEM contains the derivation as a monadic value.
1002 (service-value system)))
1003
1004 (define* (operating-system-profile os)
1005 "Return a derivation that builds the system profile of OS."
1006 (mlet* %store-monad
1007 ((services -> (operating-system-services os))
1008 (profile (fold-services services
1009 #:target-type profile-service-type)))
1010 (match profile
1011 (("profile" profile)
1012 (return profile)))))
1013
1014 (define (operating-system-root-file-system os)
1015 "Return the root file system of OS."
1016 (find (lambda (fs)
1017 (string=? "/" (file-system-mount-point fs)))
1018 (operating-system-file-systems os)))
1019
1020 (define (operating-system-initrd-file os)
1021 "Return a gexp denoting the initrd file of OS."
1022 (define boot-file-systems
1023 (filter file-system-needed-for-boot?
1024 (operating-system-file-systems os)))
1025
1026 (define mapped-devices
1027 (operating-system-boot-mapped-devices os))
1028
1029 (define make-initrd
1030 (operating-system-initrd os))
1031
1032 (make-initrd boot-file-systems
1033 #:linux (operating-system-kernel os)
1034 #:linux-modules
1035 (operating-system-initrd-modules os)
1036 #:mapped-devices mapped-devices
1037 #:keyboard-layout (operating-system-keyboard-layout os)))
1038
1039 (define* (operating-system-uuid os #:optional (type 'dce))
1040 "Compute UUID object with a deterministic \"UUID\" for OS, of the given
1041 TYPE (one of 'iso9660 or 'dce). Return a UUID object."
1042 ;; Note: For this to be deterministic, we must not hash things that contains
1043 ;; (directly or indirectly) procedures, for example. That rules out
1044 ;; anything that contains gexps, thunk or delayed record fields, etc.
1045
1046 (define service-name
1047 (compose service-type-name service-kind))
1048
1049 (define (file-system-digest fs)
1050 ;; Return a hashable digest that does not contain 'dependencies' since
1051 ;; this field can contain procedures.
1052 (let ((device (file-system-device fs)))
1053 (list (file-system-mount-point fs)
1054 (file-system-type fs)
1055 (file-system-device->string device)
1056 (file-system-options fs))))
1057
1058 (if (eq? type 'iso9660)
1059 (let ((pad (compose (cut string-pad <> 2 #\0)
1060 number->string))
1061 (h (hash (map service-name (operating-system-services os))
1062 3600)))
1063 (bytevector->uuid
1064 (string->iso9660-uuid
1065 (string-append "1970-01-01-"
1066 (pad (hash (operating-system-host-name os) 24)) "-"
1067 (pad (quotient h 60)) "-"
1068 (pad (modulo h 60)) "-"
1069 (pad (hash (map file-system-digest
1070 (operating-system-file-systems os))
1071 100))))
1072 'iso9660))
1073 (bytevector->uuid
1074 (uint-list->bytevector
1075 (list (hash (map file-system-digest
1076 (operating-system-file-systems os))
1077 (- (expt 2 32) 1))
1078 (hash (operating-system-host-name os)
1079 (- (expt 2 32) 1))
1080 (hash (map service-name (operating-system-services os))
1081 (- (expt 2 32) 1))
1082 (hash (map file-system-digest (operating-system-file-systems os))
1083 (- (expt 2 32) 1)))
1084 (endianness little)
1085 4)
1086 type)))
1087
1088 (define (locale-name->definition* name)
1089 "Variant of 'locale-name->definition' that raises an error upon failure."
1090 (match (locale-name->definition name)
1091 (#f
1092 (raise (condition
1093 (&message
1094 (message (format #f (G_ "~a: invalid locale name") name))))))
1095 (def def)))
1096
1097 (define (operating-system-locale-directory os)
1098 "Return the directory containing the locales compiled for the definitions
1099 listed in OS. The C library expects to find it under
1100 /run/current-system/locale."
1101 (define name
1102 (operating-system-locale os))
1103
1104 (define definitions
1105 ;; While we're at it, check whether NAME is defined and add it if needed.
1106 (if (member name (map locale-definition-name
1107 (operating-system-locale-definitions os)))
1108 (operating-system-locale-definitions os)
1109 (cons (locale-name->definition* name)
1110 (operating-system-locale-definitions os))))
1111
1112 (locale-directory definitions
1113 #:libcs (operating-system-locale-libcs os)))
1114
1115 (define* (kernel->boot-label kernel #:key hurd)
1116 "Return a label for the bootloader menu entry that boots KERNEL."
1117 (cond ((package? hurd)
1118 (string-append "GNU with the "
1119 (string-titlecase (package-name hurd)) " "
1120 (package-version hurd)))
1121 ((package? kernel)
1122 (string-append "GNU with "
1123 (string-titlecase (package-name kernel)) " "
1124 (package-version kernel)))
1125 ((inferior-package? kernel)
1126 (string-append "GNU with "
1127 (string-titlecase (inferior-package-name kernel)) " "
1128 (inferior-package-version kernel)))
1129 (else "GNU")))
1130
1131 (define (operating-system-default-label os)
1132 "Return the default label for OS, as it will appear in the bootloader menu
1133 entry."
1134 (kernel->boot-label (operating-system-kernel os)
1135 #:hurd (operating-system-hurd os)))
1136
1137 (define (store-file-system file-systems)
1138 "Return the file system object among FILE-SYSTEMS that contains the store."
1139 (match (filter (lambda (fs)
1140 (and (file-system-mount? fs)
1141 (not (memq 'bind-mount (file-system-flags fs)))
1142 (string-prefix? (file-system-mount-point fs)
1143 (%store-prefix))))
1144 file-systems)
1145 ((and candidates (head . tail))
1146 (reduce (lambda (fs1 fs2)
1147 (if (> (string-length (file-system-mount-point fs1))
1148 (string-length (file-system-mount-point fs2)))
1149 fs1
1150 fs2))
1151 head
1152 candidates))))
1153
1154 (define (operating-system-store-file-system os)
1155 "Return the file system that contains the store of OS."
1156 (store-file-system (operating-system-file-systems os)))
1157
1158 (define* (operating-system-bootcfg os #:optional (old-entries '()))
1159 "Return the bootloader configuration file for OS. Use OLD-ENTRIES,
1160 a list of <menu-entry>, to populate the \"old entries\" menu."
1161 (let* ((file-systems (operating-system-file-systems os))
1162 (root-fs (operating-system-root-file-system os))
1163 (root-device (file-system-device root-fs))
1164 (params (operating-system-boot-parameters
1165 os root-device
1166 #:system-kernel-arguments? #t))
1167 (entry (boot-parameters->menu-entry params))
1168 (bootloader-conf (operating-system-bootloader os)))
1169
1170 (define generate-config-file
1171 (bootloader-configuration-file-generator
1172 (bootloader-configuration-bootloader bootloader-conf)))
1173
1174 (generate-config-file bootloader-conf (list entry)
1175 #:old-entries old-entries
1176 #:store-directory-prefix
1177 (btrfs-store-subvolume-file-name file-systems))))
1178
1179 (define (operating-system-multiboot-modules os)
1180 (if (operating-system-hurd os) (hurd-multiboot-modules os) '()))
1181
1182 (define (hurd-multiboot-modules os)
1183 (let* ((hurd (operating-system-hurd os))
1184 (root-file-system-command
1185 (list (file-append hurd "/hurd/ext2fs.static")
1186 "ext2fs"
1187 "--multiboot-command-line='${kernel-command-line}'"
1188 "--host-priv-port='${host-port}'"
1189 "--device-master-port='${device-port}'"
1190 "--exec-server-task='${exec-task}'"
1191 "--store-type=typed"
1192 "'${root}'" "'$(task-create)'" "'$(task-resume)'"))
1193 (target (%current-target-system))
1194 (libc (if target
1195 (with-parameters ((%current-target-system #f))
1196 ;; TODO: cross-libc has extra patches for the Hurd;
1197 ;; remove in next rebuild cycle
1198 (cross-libc target))
1199 glibc))
1200 (exec-server-command
1201 (list (file-append libc "/lib/ld.so.1") "exec"
1202 (file-append hurd "/hurd/exec") "'$(exec-task=task-create)'")))
1203 (list root-file-system-command exec-server-command)))
1204
1205 (define* (operating-system-boot-parameters os root-device
1206 #:key system-kernel-arguments?)
1207 "Return a monadic <boot-parameters> record that describes the boot
1208 parameters of OS. When SYSTEM-KERNEL-ARGUMENTS? is true, add kernel arguments
1209 such as '--root' and '--load' to <boot-parameters>."
1210 (let* ((initrd (and (not (hurd-target?))
1211 (operating-system-initrd-file os)))
1212 (store (operating-system-store-file-system os))
1213 (bootloader (bootloader-configuration-bootloader
1214 (operating-system-bootloader os)))
1215 (bootloader-name (bootloader-name bootloader))
1216 (label (operating-system-label os))
1217 (multiboot-modules (operating-system-multiboot-modules os)))
1218 (boot-parameters
1219 (label label)
1220 (root-device root-device)
1221 (kernel (operating-system-kernel-file os))
1222 (kernel-arguments
1223 (if system-kernel-arguments?
1224 (operating-system-kernel-arguments os root-device)
1225 (operating-system-user-kernel-arguments os)))
1226 (initrd initrd)
1227 (multiboot-modules multiboot-modules)
1228 (bootloader-name bootloader-name)
1229 (bootloader-menu-entries
1230 (bootloader-configuration-menu-entries (operating-system-bootloader os)))
1231 (store-device (ensure-not-/dev (file-system-device store)))
1232 (store-mount-point (file-system-mount-point store)))))
1233
1234 (define (device->sexp device)
1235 "Serialize DEVICE as an sexp (really, as an object with a read syntax.)"
1236 (match device
1237 ((? uuid? uuid)
1238 `(uuid ,(uuid-type uuid) ,(uuid-bytevector uuid)))
1239 ((? file-system-label? label)
1240 `(file-system-label ,(file-system-label->string label)))
1241 (_
1242 device)))
1243
1244 (define* (operating-system-boot-parameters-file os
1245 #:key system-kernel-arguments?)
1246 "Return a file that describes the boot parameters of OS. The primary use of
1247 this file is the reconstruction of GRUB menu entries for old configurations.
1248
1249 When SYSTEM-KERNEL-ARGUMENTS? is true, add kernel arguments such as '--root'
1250 and '--load' to the returned file (since the returned file is then usually
1251 stored into the content-addressed \"system\" directory, it's usually not a
1252 good idea to give it because the content hash would change by the content hash
1253 being stored into the \"parameters\" file)."
1254 (let* ((root (operating-system-root-file-system os))
1255 (device (file-system-device root))
1256 (params (operating-system-boot-parameters
1257 os device
1258 #:system-kernel-arguments?
1259 system-kernel-arguments?)))
1260 (scheme-file "parameters"
1261 #~(boot-parameters
1262 (version 0)
1263 (label #$(boot-parameters-label params))
1264 (root-device
1265 #$(device->sexp
1266 (boot-parameters-root-device params)))
1267 (kernel #$(boot-parameters-kernel params))
1268 (kernel-arguments
1269 #$(boot-parameters-kernel-arguments params))
1270 (initrd #$(boot-parameters-initrd params))
1271 (bootloader-name #$(boot-parameters-bootloader-name params))
1272 (bootloader-menu-entries
1273 #$(map menu-entry->sexp
1274 (or (and=> (operating-system-bootloader os)
1275 bootloader-configuration-menu-entries)
1276 '())))
1277 (store
1278 (device
1279 #$(device->sexp (boot-parameters-store-device params)))
1280 (mount-point #$(boot-parameters-store-mount-point
1281 params))))
1282 #:set-load-path? #f)))
1283
1284 (define-gexp-compiler (operating-system-compiler (os <operating-system>)
1285 system target)
1286 ((store-lift
1287 (lambda (store)
1288 ;; XXX: This is not super elegant but we can't pass SYSTEM and TARGET to
1289 ;; 'operating-system-derivation'.
1290 (run-with-store store (operating-system-derivation os)
1291 #:system system
1292 #:target target)))))
1293
1294 ;;; system.scm ends here