gnu: csound: Update to 6.16.2.
[jackhill/guix/guix.git] / gnu / system.scm
CommitLineData
033adfe7 1;;; GNU Guix --- Functional package management for GNU
f43dce6e 2;;; Copyright © 2013-2022 Ludovic Courtès <ludo@gnu.org>
5e738ac2 3;;; Copyright © 2015 Mark H Weaver <mhw@netris.org>
5dccaffe 4;;; Copyright © 2015, 2016 Alex Kost <alezost@gmail.com>
1ef8b72a 5;;; Copyright © 2016 Chris Marusich <cmmarusich@gmail.com>
c76b3046 6;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
5144df2c 7;;; Copyright © 2019 Meiyo Peng <meiyo.peng@gmail.com>
f00e68ac 8;;; Copyright © 2019, 2020 Miguel Ángel Arruga Vivas <rosen644835@gmail.com>
5c79f238 9;;; Copyright © 2020 Danny Milosavljevic <dannym@scratchpost.org>
a7ac1985 10;;; Copyright © 2020, 2021 Brice Waegeneire <brice@waegenei.re>
e06664da 11;;; Copyright © 2020 Florian Pelz <pelzflorian@pelzflorian.de>
4a3b8f4d 12;;; Copyright © 2020, 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com>
45b2cb43 13;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <jannek@gnu.org>
34ba6e06 14;;; Copyright © 2020, 2022 Efraim Flashner <efraim@flashner.co.il>
95f72dcd 15;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
a3df3825 16;;; Copyright © 2021 raid5atemyhomework <raid5atemyhomework@protonmail.com>
033adfe7
LC
17;;;
18;;; This file is part of GNU Guix.
19;;;
20;;; GNU Guix is free software; you can redistribute it and/or modify it
21;;; under the terms of the GNU General Public License as published by
22;;; the Free Software Foundation; either version 3 of the License, or (at
23;;; your option) any later version.
24;;;
25;;; GNU Guix is distributed in the hope that it will be useful, but
26;;; WITHOUT ANY WARRANTY; without even the implied warranty of
27;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28;;; GNU General Public License for more details.
29;;;
30;;; You should have received a copy of the GNU General Public License
31;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
32
33(define-module (gnu system)
bdc61ff9 34 #:use-module (guix inferior)
033adfe7 35 #:use-module (guix store)
39a9404c 36 #:use-module (guix memoization)
033adfe7 37 #:use-module (guix monads)
02100028 38 #:use-module (guix gexp)
033adfe7
LC
39 #:use-module (guix records)
40 #:use-module (guix packages)
41 #:use-module (guix derivations)
29fce8b6 42 #:use-module (guix profiles)
a5e2fc73
LC
43 #:use-module ((guix utils) #:select (substitute-keyword-arguments))
44 #:use-module (guix i18n)
45 #:use-module (guix diagnostics)
39a9404c 46 #:use-module (guix ui)
e6e07628 47 #:use-module (gnu packages admin)
033adfe7
LC
48 #:use-module (gnu packages base)
49 #:use-module (gnu packages bash)
e6e07628 50 #:use-module (gnu packages compression)
912b857e 51 #:use-module (gnu packages cross-base)
e6e07628
EF
52 #:use-module (gnu packages cryptsetup)
53 #:use-module (gnu packages disk)
54 #:use-module (gnu packages file-systems)
55 #:use-module (gnu packages firmware)
56 #:use-module (gnu packages gawk)
bdb36958 57 #:use-module (gnu packages guile)
01ac0e6b 58 #:use-module (gnu packages guile-xyz)
912b857e 59 #:use-module (gnu packages hurd)
6f436c54 60 #:use-module (gnu packages less)
e6e07628 61 #:use-module (gnu packages linux)
18316d86 62 #:use-module (gnu packages man)
e6e07628 63 #:use-module (gnu packages nano)
4170af49 64 #:use-module (gnu packages nvi)
e6e07628
EF
65 #:use-module (gnu packages package-management)
66 #:use-module (gnu packages pciutils)
939c5c31 67 #:use-module (gnu packages texinfo)
74168d99 68 #:use-module (gnu packages text-editors)
7a65beff 69 #:use-module (gnu packages wget)
db4fdc04 70 #:use-module (gnu services)
0190c1c0 71 #:use-module (gnu services shepherd)
db4fdc04 72 #:use-module (gnu services base)
b09a8da4 73 #:use-module (gnu bootloader)
033adfe7 74 #:use-module (gnu system shadow)
996ed739 75 #:use-module (gnu system nss)
598e19dc 76 #:use-module (gnu system locale)
6e828634 77 #:use-module (gnu system pam)
735c6dd7 78 #:use-module (gnu system linux-initrd)
a7ac1985 79 #:use-module (gnu system setuid)
9b336338 80 #:use-module (gnu system uuid)
c5df1839 81 #:use-module (gnu system file-systems)
060d62a7 82 #:use-module (gnu system mapped-devices)
39a9404c 83 #:use-module (ice-9 format)
033adfe7
LC
84 #:use-module (ice-9 match)
85 #:use-module (srfi srfi-1)
86 #:use-module (srfi srfi-26)
598e19dc
LC
87 #:use-module (srfi srfi-34)
88 #:use-module (srfi srfi-35)
39a9404c 89 #:use-module (srfi srfi-71)
3382bfe9 90 #:use-module (rnrs bytevectors)
033adfe7
LC
91 #:export (operating-system
92 operating-system?
d8bead6c 93 this-operating-system
d5b429ab
LC
94
95 operating-system-bootloader
033adfe7 96 operating-system-services
69cae3d3 97 operating-system-essential-services
f8885eca 98 operating-system-default-essential-services
217a5b85 99 operating-system-user-services
033adfe7 100 operating-system-packages
fd3bfc44 101 operating-system-host-name
c65e1834 102 operating-system-hosts-file
2018fb2a 103 operating-system-hurd
fd3bfc44 104 operating-system-kernel
44d5f54e 105 operating-system-kernel-file
33f0aa88 106 operating-system-kernel-arguments
3f03a198
LC
107 operating-system-label
108 operating-system-default-label
bc499b11 109 operating-system-initrd-modules
fd3bfc44
LC
110 operating-system-initrd
111 operating-system-users
112 operating-system-groups
548d4c13 113 operating-system-issue
fd3bfc44
LC
114 operating-system-timezone
115 operating-system-locale
598e19dc 116 operating-system-locale-definitions
34760ae7 117 operating-system-locale-libcs
5dae0186 118 operating-system-mapped-devices
83bcd0b8 119 operating-system-file-systems
6b779207 120 operating-system-store-file-system
2bdd7ac1
LC
121 operating-system-user-mapped-devices
122 operating-system-boot-mapped-devices
f00e68ac 123 operating-system-bootloader-crypto-devices
b25937e3 124 operating-system-activation-script
b2fef041
LC
125 operating-system-user-accounts
126 operating-system-shepherd-service-names
20abb8c4 127 operating-system-user-kernel-arguments
9ef37e81
BW
128 operating-system-firmware
129 operating-system-keyboard-layout
130 operating-system-name-service-switch
131 operating-system-pam-services
132 operating-system-setuid-programs
133 operating-system-skeletons
134 operating-system-sudoers-file
135 operating-system-swap-devices
a9f2c210 136 operating-system-kernel-loadable-modules
9e12da31 137 operating-system-location
033adfe7 138
1aa0033b 139 operating-system-derivation
83bcd0b8 140 operating-system-profile
c76b3046 141 operating-system-bootcfg
239db054
DT
142 operating-system-etc-directory
143 operating-system-locale-directory
144 operating-system-boot-script
78fbf2bd 145 operating-system-uuid
239db054 146
43fe431c 147 system-linux-image-file-name
9fcfe30d 148 operating-system-with-gc-roots
33b7cb7a 149 operating-system-with-provenance
43fe431c 150
45b2cb43
JN
151 hurd-default-essential-services
152
b8300494
AK
153 boot-parameters
154 boot-parameters?
155 boot-parameters-label
156 boot-parameters-root-device
f96752e3 157 boot-parameters-bootloader-name
a28cfee8 158 boot-parameters-bootloader-menu-entries
f00e68ac 159 boot-parameters-store-crypto-devices
1ef8b72a 160 boot-parameters-store-device
582cf925 161 boot-parameters-store-directory-prefix
1ef8b72a 162 boot-parameters-store-mount-point
9d449b94 163 boot-parameters-locale
b8300494
AK
164 boot-parameters-kernel
165 boot-parameters-kernel-arguments
d7b342d8 166 boot-parameters-initrd
912b857e 167 boot-parameters-multiboot-modules
4a3b8f4d
MC
168 boot-parameters-version
169 %boot-parameters-version
4e4e0185 170 read-boot-parameters
9530e73b 171 read-boot-parameters-file
1975c754 172 boot-parameters->menu-entry
b8300494 173
568841d4 174 local-host-aliases
d0f3a672 175 %root-account
df5ce088 176 %setuid-programs
f6b95031 177 %sudoers-specification
5dae0186 178 %base-packages
53a1cebc 179 %base-packages-artwork
93664fee
BW
180 %base-packages-interactive
181 %base-packages-linux
182 %base-packages-networking
e6e07628 183 %base-packages-disk-utilities
93664fee 184 %base-packages-utils
e06664da
FP
185 %base-firmware
186 %default-kernel-arguments))
033adfe7
LC
187
188;;; Commentary:
189;;;
190;;; This module supports whole-system configuration.
191;;;
192;;; Code:
193
0dc019e1
MC
194(define* (bootable-kernel-arguments system root-device version)
195 "Return a list of kernel arguments (gexps) to boot SYSTEM from ROOT-DEVICE.
196VERSION is the target version of the boot-parameters record."
197 ;; If the version is newer than 0, we use the new style initrd parameter
198 ;; names, otherwise we use the legacy ones. This is to maintain backward
199 ;; compatibility when producing bootloader configurations for older
200 ;; generations.
201 (define version>0? (> version 0))
202 (list (string-append (if version>0? "root=" "--root=")
99e676db 203 ;; Note: Always use the DCE format because that's what
0dc019e1 204 ;; (gnu build linux-boot) expects for the 'root'
99e676db
MC
205 ;; kernel command-line option.
206 (file-system-device->string root-device
207 #:uuid-type 'dce))
0dc019e1
MC
208 #~(string-append (if #$version>0? "gnu.system=" "--system=") #$system)
209 #~(string-append (if #$version>0? "gnu.load=" "--load=")
210 #$system "/boot")))
33f0aa88 211
033adfe7
LC
212;; System-wide configuration.
213;; TODO: Add per-field docstrings/stexi.
214(define-record-type* <operating-system> operating-system
215 make-operating-system
216 operating-system?
d8bead6c
LC
217 this-operating-system
218
033adfe7 219 (kernel operating-system-kernel ; package
57082417 220 (default linux-libre))
5c79f238
DM
221 (kernel-loadable-modules operating-system-kernel-loadable-modules
222 (default '())) ; list of packages
af98d25a 223 (kernel-arguments operating-system-user-kernel-arguments
e06664da 224 (default %default-kernel-arguments)) ; list of gexps/strings
2018fb2a
JN
225 (hurd operating-system-hurd
226 (default #f)) ; package
b09a8da4 227 (bootloader operating-system-bootloader) ; <bootloader-configuration>
3f03a198
LC
228 (label operating-system-label ; string
229 (thunked)
230 (default (operating-system-default-label this-operating-system)))
d5b429ab 231
ae7a316b
LC
232 (keyboard-layout operating-system-keyboard-layout ;#f | <keyboard-layout>
233 (default #f))
e34ae75d 234 (initrd operating-system-initrd ; (list fs) -> file-like
060238ae 235 (default base-initrd))
bc499b11
LC
236 (initrd-modules operating-system-initrd-modules ; list of strings
237 (thunked) ; it's system-dependent
238 (default %base-initrd-modules))
239
f34c56be
LC
240 (firmware operating-system-firmware ; list of packages
241 (default %base-firmware))
033adfe7
LC
242
243 (host-name operating-system-host-name) ; string
24e02c28 244 (hosts-file operating-system-hosts-file ; file-like | #f
c65e1834 245 (default #f))
033adfe7 246
5dae0186
LC
247 (mapped-devices operating-system-mapped-devices ; list of <mapped-device>
248 (default '()))
8a6d2731 249 (file-systems operating-system-file-systems) ; list of fs
133a61ae
JP
250 (swap-devices operating-system-swap-devices ; list of string | <swap-space>
251 (default '())
f574dbd1
JP
252 (delayed)
253 (sanitize warn-swap-devices-change))
033adfe7
LC
254
255 (users operating-system-users ; list of user accounts
bf87f38a 256 (default %base-user-accounts))
033adfe7 257 (groups operating-system-groups ; list of user groups
773e956d 258 (default %base-groups))
033adfe7 259
ac3c14fb 260 (skeletons operating-system-skeletons ; list of name/file-like value
40281c54 261 (default (default-skeletons)))
548d4c13
LC
262 (issue operating-system-issue ; string
263 (default %default-issue))
40281c54 264
033adfe7 265 (packages operating-system-packages ; list of (PACKAGE OUTPUT...)
6f436c54 266 (default %base-packages)) ; or just PACKAGE
033adfe7
LC
267
268 (timezone operating-system-timezone) ; string
8a6d2731 269 (locale operating-system-locale ; string
598e19dc
LC
270 (default "en_US.utf8"))
271 (locale-definitions operating-system-locale-definitions ; list of <locale-definition>
272 (default %default-locale-definitions))
34760ae7
LC
273 (locale-libcs operating-system-locale-libcs ; list of <packages>
274 (default %default-locale-libcs))
996ed739
LC
275 (name-service-switch operating-system-name-service-switch ; <name-service-switch>
276 (default %default-nss))
033adfe7 277
69cae3d3
LC
278 (essential-services operating-system-essential-services ; list of services
279 (thunked)
f8885eca
LC
280 (default (operating-system-default-essential-services
281 this-operating-system)))
ac3c14fb 282 (services operating-system-user-services ; list of services
24ead149 283 (thunked) ;allow for system-dependent services
09e028f4
LC
284 (default %base-services))
285
286 (pam-services operating-system-pam-services ; list of PAM services
287 (default (base-pam-services)))
e0bd47b4
LC
288 (setuid-programs operating-system-setuid-programs
289 (default %setuid-programs) ; list of <setuid-program>
290 (sanitize ensure-setuid-program-list))
033adfe7 291
f5a9ffa0 292 (sudoers-file operating-system-sudoers-file ; file-like
9e12da31
LC
293 (default %sudoers-specification))
294
295 (location operating-system-location ; <location>
296 (default (and=> (current-source-location)
297 source-properties->location))
298 (innate)))
033adfe7 299
0dc019e1
MC
300(define* (operating-system-kernel-arguments
301 os root-device #:key (version %boot-parameters-version))
302 "Return all the kernel arguments, including the ones not specified directly
1d0d46b1 303by the user. VERSION should match that of the target <boot-parameters> record
0dc019e1
MC
304object that will contain the kernel parameters."
305 (append (bootable-kernel-arguments os root-device version)
a7ef45d9 306 (operating-system-user-kernel-arguments os)))
33f0aa88 307
2717a89a 308\f
8e815c5b
LC
309;;;
310;;; Boot parameters
311;;;
312
0dc019e1
MC
313;;; Version 1 was introduced early 2022 to mark the departure from long option
314;;; names such as '--load' to the more conventional initrd option names like
315;;; 'gnu.load'.
316;;;
4a3b8f4d 317;;; When bumping the boot-parameters version, increment it by one (1).
0dc019e1 318(define %boot-parameters-version 1)
4a3b8f4d 319
8e815c5b
LC
320(define-record-type* <boot-parameters>
321 boot-parameters make-boot-parameters boot-parameters?
322 (label boot-parameters-label)
323 ;; Because we will use the 'store-device' to create the GRUB search command,
324 ;; the 'store-device' has slightly different semantics than 'root-device'.
325 ;; The 'store-device' can be a file system uuid, a file system label, or #f,
2df44e93
MÁAV
326 ;; but it cannot be a device file name such as "/dev/sda3", since GRUB would
327 ;; not understand that. The 'root-device', on the other hand, corresponds
8e815c5b 328 ;; exactly to the device field of the <file-system> object representing the
2df44e93
MÁAV
329 ;; OS's root file system, so it might be a device file name like
330 ;; "/dev/sda3". The 'store-directory-prefix' field contains #f or the store
331 ;; file name inside the 'store-device' as it is seen by GRUB, e.g. it would
332 ;; contain "/storefs" if the store is located in that subvolume of a btrfs
582cf925 333 ;; partition.
8e815c5b 334 (root-device boot-parameters-root-device)
f96752e3 335 (bootloader-name boot-parameters-bootloader-name)
a28cfee8
LC
336 (bootloader-menu-entries ;list of <menu-entry>
337 boot-parameters-bootloader-menu-entries)
8e815c5b
LC
338 (store-device boot-parameters-store-device)
339 (store-mount-point boot-parameters-store-mount-point)
582cf925 340 (store-directory-prefix boot-parameters-store-directory-prefix)
f00e68ac
MÁAV
341 (store-crypto-devices boot-parameters-store-crypto-devices
342 (default '()))
9d449b94 343 (locale boot-parameters-locale)
8e815c5b
LC
344 (kernel boot-parameters-kernel)
345 (kernel-arguments boot-parameters-kernel-arguments)
912b857e 346 (initrd boot-parameters-initrd)
4a3b8f4d
MC
347 (multiboot-modules boot-parameters-multiboot-modules)
348 (version boot-parameters-version ;positive integer
349 (default %boot-parameters-version)))
8e815c5b 350
90d23ed9
LC
351(define (ensure-not-/dev device)
352 "If DEVICE starts with a slash, return #f. This is meant to filter out
353Linux device names such as /dev/sda, and to preserve GRUB device names and
354file system labels."
355 (if (and (string? device) (string-prefix? "/" device))
356 #f
357 device))
358
8e815c5b
LC
359(define (read-boot-parameters port)
360 "Read boot parameters from PORT and return the corresponding
47960b55 361<boot-parameters> object. Raise an error if the format is unrecognized."
075681d3
LC
362 (define device-sexp->device
363 (match-lambda
364 (('uuid (? symbol? type) (? bytevector? bv))
365 (bytevector->uuid bv type))
a5acc17a
LC
366 (('file-system-label (? string? label))
367 (file-system-label label))
075681d3
LC
368 ((? bytevector? bv) ;old format
369 (bytevector->uuid bv 'dce))
370 ((? string? device)
1c3b709e
S
371 (if (string-contains device ":/")
372 device ; nfs-root
373 ;; It used to be that we would not distinguish between labels and
374 ;; device names. Try to infer the right thing here.
375 (if (string-prefix? "/" device)
376 device
377 (file-system-label device))))))
f00e68ac
MÁAV
378 (define uuid-sexp->uuid
379 (match-lambda
380 (('uuid (? symbol? type) (? bytevector? bv))
381 (bytevector->uuid bv type))
382 (x
383 (warning (G_ "unrecognized uuid ~a at '~a'~%") x (port-filename port))
384 #f)))
075681d3 385
4a3b8f4d
MC
386 ;; New versions are not backward-compatible, so only accept past and current
387 ;; versions, not future ones.
388 (define (version? n)
389 (member n (iota (1+ %boot-parameters-version))))
390
8e815c5b 391 (match (read port)
4a3b8f4d 392 (('boot-parameters ('version (? version? version))
8e815c5b 393 ('label label) ('root-device root)
912b857e 394 ('kernel kernel)
8e815c5b
LC
395 rest ...)
396 (boot-parameters
4a3b8f4d 397 (version version)
8e815c5b 398 (label label)
7940188e 399 (root-device (device-sexp->device root))
8e815c5b 400
f96752e3
MO
401 (bootloader-name
402 (match (assq 'bootloader-name rest)
bcaf67c4
MO
403 ((_ args) args)
404 (#f 'grub))) ; for compatibility reasons.
405
a28cfee8
LC
406 (bootloader-menu-entries
407 (match (assq 'bootloader-menu-entries rest)
408 ((_ entries) (map sexp->menu-entry entries))
409 (#f '())))
410
912b857e
JN
411 ;; In the past, we would store the directory name of linux instead of
412 ;; the absolute file name of its image. Detect that and correct it.
413 (kernel (if (string=? kernel (direct-store-path kernel))
414 (string-append kernel "/"
8e815c5b 415 (system-linux-image-file-name))
912b857e 416 kernel))
8e815c5b
LC
417
418 (kernel-arguments
419 (match (assq 'kernel-arguments rest)
420 ((_ args) args)
421 (#f '()))) ;the old format
422
423 (initrd
424 (match (assq 'initrd rest)
425 (('initrd ('string-append directory file)) ;the old format
426 (string-append directory file))
427 (('initrd (? string? file))
12906d3e
JN
428 file)
429 (#f #f)))
8e815c5b 430
aa864ebd
JN
431 (multiboot-modules
432 (match (assq 'multiboot-modules rest)
433 ((_ args) args)
434 (#f '())))
912b857e 435
9d449b94
MÁAV
436 (locale
437 (match (assq 'locale rest)
438 ((_ locale) locale)
439 (#f #f)))
440
8e815c5b 441 (store-device
db4e8fd5
LC
442 ;; Linux device names like "/dev/sda1" are not suitable GRUB device
443 ;; identifiers, so we just filter them out.
444 (ensure-not-/dev
445 (match (assq 'store rest)
446 (('store ('device #f) _ ...)
447 root-device)
448 (('store ('device device) _ ...)
449 (device-sexp->device device))
450 (_ ;the old format
451 root-device))))
8e815c5b 452
582cf925
MÁAV
453 (store-directory-prefix
454 (match (assq 'store rest)
455 (('store . store-data)
456 (match (assq 'directory-prefix store-data)
457 (('directory-prefix prefix) prefix)
458 ;; No directory-prefix found.
459 (_ #f)))
460 (_
461 ;; No store found, old format.
462 #f)))
463
f00e68ac
MÁAV
464 (store-crypto-devices
465 (match (assq 'store rest)
466 (('store . store-data)
467 (match (assq 'crypto-devices store-data)
468 (('crypto-devices (devices ...))
469 (map uuid-sexp->uuid devices))
470 (('crypto-devices dev)
471 (warning (G_ "unrecognized crypto-devices ~S at '~a'~%")
472 dev (port-filename port))
473 '())
474 (_
475 ;; No crypto-devices found.
476 '())))
477 (_
478 ;; No store found, old format.
479 '())))
480
8e815c5b
LC
481 (store-mount-point
482 (match (assq 'store rest)
483 (('store ('device _) ('mount-point mount-point) _ ...)
484 mount-point)
485 (_ ;the old format
486 "/")))))
487 (x ;unsupported format
47960b55
LC
488 (raise
489 (make-compound-condition
490 (formatted-message
491 (G_ "unrecognized boot parameters at '~a'~%")
492 (port-filename port))
493 (condition
494 (&fix-hint (hint (format #f (G_ "This probably means that this version
495of Guix is older than the one that created @file{~a}. To address this, you
496need to update Guix:
497
498@example
499guix pull
500@end example")
501 (port-filename port))))))))))
8e815c5b
LC
502
503(define (read-boot-parameters-file system)
504 "Read boot parameters from SYSTEM's (system or generation) \"parameters\"
505file and returns the corresponding <boot-parameters> object or #f if the
506format is unrecognized.
507The object has its kernel-arguments extended in order to make it bootable."
508 (let* ((file (string-append system "/parameters"))
509 (params (call-with-input-file file read-boot-parameters))
0dc019e1
MC
510 (root (boot-parameters-root-device params))
511 (version (boot-parameters-version params)))
a7ef45d9
LC
512 (boot-parameters
513 (inherit params)
0dc019e1 514 (kernel-arguments (append (bootable-kernel-arguments system root version)
a7ef45d9 515 (boot-parameters-kernel-arguments params))))))
8b22107e 516
1975c754 517(define (boot-parameters->menu-entry conf)
1d0d46b1 518 "Return a <menu-entry> instance given CONF, a <boot-parameters> instance."
912b857e
JN
519 (let* ((kernel (boot-parameters-kernel conf))
520 (multiboot-modules (boot-parameters-multiboot-modules conf))
521 (multiboot? (pair? multiboot-modules)))
522 (menu-entry
523 (label (boot-parameters-label conf))
524 (device (boot-parameters-store-device conf))
525 (device-mount-point (boot-parameters-store-mount-point conf))
526 (linux (and (not multiboot?) kernel))
535a6be2 527 (linux-arguments (if (not multiboot?)
912b857e
JN
528 (boot-parameters-kernel-arguments conf)
529 '()))
530 (initrd (boot-parameters-initrd conf))
531 (multiboot-kernel (and multiboot? kernel))
532 (multiboot-arguments (if multiboot?
533 (boot-parameters-kernel-arguments conf)
534 '()))
535 (multiboot-modules (if multiboot?
536 (boot-parameters-multiboot-modules conf)
537 '())))))
8b22107e 538
8e815c5b 539\f
40281c54
LC
540;;;
541;;; Services.
542;;;
543
aa1145df
LC
544(define (non-boot-file-system-service os)
545 "Return the file system service for the file systems of OS that are not
546marked as 'needed-for-boot'."
023f391c 547 (define file-systems
4d6b879c 548 (remove file-system-needed-for-boot?
023f391c
LC
549 (operating-system-file-systems os)))
550
68a58775
LC
551 (define mapped-devices-for-boot
552 (operating-system-boot-mapped-devices os))
553
5dae0186 554 (define (device-mappings fs)
ab64483f 555 (let ((device (file-system-device fs)))
29824d80 556 (if (string? device) ;title is 'device
ab64483f 557 (filter (lambda (md)
788df2ec
MT
558 (any (cut string=? device <>)
559 (map (cut string-append "/dev/mapper" <>)
560 (mapped-device-targets md))))
ab64483f
LC
561 (operating-system-mapped-devices os))
562 '())))
5dae0186 563
e502bf89
LC
564 (define (add-dependencies fs)
565 ;; Add the dependencies due to device mappings to FS.
566 (file-system
567 (inherit fs)
568 (dependencies
68a58775
LC
569 (delete-duplicates
570 (remove (cut member <> mapped-devices-for-boot)
571 (append (device-mappings fs)
572 (file-system-dependencies fs)))
573 eq?))))
e502bf89 574
aa1145df
LC
575 (service file-system-service-type
576 (map add-dependencies file-systems)))
023f391c 577
45eac6cd
BW
578(define (boot-file-system-service os)
579 "Return a service which adds, to the system profile, packages providing the
580utilites for the file systems marked as 'needed-for-boot' in OS."
581 (let ((file-systems (filter file-system-needed-for-boot?
582 (operating-system-file-systems os))))
583 (simple-service 'boot-file-system-utilities profile-service-type
584 (file-system-utilities file-systems))))
585
68a58775
LC
586(define (mapped-device-users device file-systems)
587 "Return the subset of FILE-SYSTEMS that use DEVICE."
788df2ec
MT
588 (let ((targets (map (cut string-append "/dev/mapper/" <>)
589 (mapped-device-targets device))))
68a58775
LC
590 (filter (lambda (fs)
591 (or (member device (file-system-dependencies fs))
592 (and (string? (file-system-device fs))
788df2ec 593 (any (cut string=? (file-system-device fs) <>) targets))))
68a58775 594 file-systems)))
de1c158f
LC
595
596(define (operating-system-user-mapped-devices os)
597 "Return the subset of mapped devices that can be installed in
598user-land--i.e., those not needed during boot."
9cb426b8
LC
599 (let ((devices (operating-system-mapped-devices os))
600 (file-systems (operating-system-file-systems os)))
601 (filter (lambda (md)
68a58775
LC
602 (let ((users (mapped-device-users md file-systems)))
603 (not (any file-system-needed-for-boot? users))))
9cb426b8 604 devices)))
de1c158f
LC
605
606(define (operating-system-boot-mapped-devices os)
607 "Return the subset of mapped devices that must be installed during boot,
608from the initrd."
9cb426b8
LC
609 (let ((devices (operating-system-mapped-devices os))
610 (file-systems (operating-system-file-systems os)))
611 (filter (lambda (md)
68a58775
LC
612 (let ((users (mapped-device-users md file-systems)))
613 (any file-system-needed-for-boot? users)))
9cb426b8 614 devices)))
de1c158f 615
39a9404c
MC
616(define operating-system-bootloader-crypto-devices
617 (mlambdaq (os) ;to avoid duplicated output
618 "Return the sources of the LUKS mapped devices specified by UUID."
619 ;; XXX: Device ordering is important, we trust the returned one.
620 (let* ((luks-devices (filter (lambda (m)
621 (eq? luks-device-mapping
622 (mapped-device-type m)))
623 (operating-system-boot-mapped-devices os)))
624 (uuid-crypto-devices non-uuid-crypto-devices
625 (partition (compose uuid? mapped-device-source)
626 luks-devices)))
627 (when (not (null? non-uuid-crypto-devices))
628 (for-each (lambda (dev)
629 (warning
630 (source-properties->location (mapped-device-location dev))
631 (G_ "mapped device '~a' may be ignored by bootloader~%")
632 (mapped-device-source dev)))
633 non-uuid-crypto-devices)
634 (display-hint "Specify mapped device sources via their LUKS UUID."))
635 (map mapped-device-source uuid-crypto-devices))))
f00e68ac 636
5dae0186 637(define (device-mapping-services os)
be1c2c54 638 "Return the list of device-mapping services for OS as a list."
4da8c19e 639 (map device-mapping-service
be1c2c54 640 (operating-system-user-mapped-devices os)))
5dae0186 641
f574dbd1
JP
642(define-syntax-rule (warn-swap-devices-change value)
643 (%warn-swap-devices-change value (current-source-location)))
644
645(define (%warn-swap-devices-change value location)
646 (map (lambda (x)
647 (unless (swap-space? x)
648 (warning
649 (source-properties->location
650 location)
651 (G_ "List elements of the field 'swap-devices' should \
652now use the <swap-space> record, as the old method is deprecated. \
653See \"(guix) operating-system Reference\" for more details.~%")))
654 x) value))
655
2a13d05e 656(define (swap-services os)
be1c2c54 657 "Return the list of swap services for OS."
4af3262d
JP
658 (define early-userspace-file-systems
659 (filter file-system-needed-for-boot?
660 (operating-system-file-systems os)))
661
662 (define early-userspace-mapped-devices
663 (operating-system-boot-mapped-devices os))
664
665 (define (filter-deps swap)
666 (if (swap-space? swap)
667 (swap-space
668 (inherit swap)
669 (dependencies (remove (lambda (dep)
670 (or (member dep early-userspace-mapped-devices)
671 (member dep early-userspace-file-systems)))
672 (swap-space-dependencies swap))))
673 swap))
674
675 (map (compose swap-service filter-deps)
676 (operating-system-swap-devices os)))
2a13d05e 677
0c053a39
LC
678(define* (system-linux-image-file-name #:optional
679 (target (or (%current-target-system)
680 (%current-system))))
681 "Return the basename of the kernel image file for TARGET."
682 (cond
683 ((string-prefix? "arm" target) "zImage")
684 ((string-prefix? "mips" target) "vmlinuz")
685 ((string-prefix? "aarch64" target) "Image")
34ba6e06 686 ((string-prefix? "riscv64" target) "Image")
0c053a39 687 (else "bzImage")))
44d5f54e
LC
688
689(define (operating-system-kernel-file os)
690 "Return an object representing the absolute file name of the kernel image of
691OS."
912b857e
JN
692 (if (operating-system-hurd os)
693 (file-append (operating-system-kernel os) "/boot/gnumach")
694 (file-append (operating-system-kernel os)
695 "/" (system-linux-image-file-name))))
44d5f54e 696
e06664da
FP
697(define %default-modprobe-blacklist
698 ;; List of kernel modules to blacklist by default.
fd31731b
FP
699 '("usbmouse" ;races with bcm5974, see <https://bugs.gnu.org/35574>
700 "usbkbd")) ;races with usbhid, see <https://issues.guix.gnu.org/35574#18>
e06664da
FP
701
702(define %default-kernel-arguments
703 ;; Default arguments passed to the kernel.
704 (list (string-append "modprobe.blacklist="
705 (string-join %default-modprobe-blacklist ","))
706 "quiet"))
707
69cae3d3 708(define* (operating-system-directory-base-entries os)
d62e201c
LC
709 "Return the basic entries of the 'system' directory of OS for use as the
710value of the SYSTEM-SERVICE-TYPE service."
cda75110
LC
711 (let* ((locale (operating-system-locale-directory os))
712 (kernel (operating-system-kernel os))
2b76179e 713 (hurd (operating-system-hurd os))
2b76179e 714 (initrd (and (not hurd) (operating-system-initrd-file os)))
cda75110 715 (params (operating-system-boot-parameters-file os)))
a3df3825 716 `(,@(if hurd
717 `(("hurd" ,hurd)
718 ("kernel" ,kernel))
719 '())
0e5c2d5e 720 ("parameters" ,params)
2b76179e 721 ,@(if initrd `(("initrd" ,initrd)) '())
0e5c2d5e 722 ("locale" ,locale)))) ;used by libc
69cae3d3 723
f8885eca 724(define (operating-system-default-essential-services os)
217a5b85
LC
725 "Return the list of essential services for OS. These are special services
726that implement part of what's declared in OS are responsible for low-level
69cae3d3 727bookkeeping."
d6e2a622
LC
728 (define known-fs
729 (map file-system-mount-point (operating-system-file-systems os)))
730
45eac6cd
BW
731 (let* ((mappings (device-mapping-services os))
732 (root-fs (root-file-system-service))
733 (boot-fs (boot-file-system-service os))
734 (non-boot-fs (non-boot-file-system-service os))
735 (swaps (swap-services os))
736 (procs (service user-processes-service-type))
737 (host-name (host-name-service (operating-system-host-name os)))
738 (entries (operating-system-directory-base-entries os)))
d62e201c 739 (cons* (service system-service-type entries)
a3df3825 740 (service linux-builder-service-type
741 (linux-builder-configuration
742 (kernel (operating-system-kernel os))
743 (modules (operating-system-kernel-loadable-modules os))))
d62e201c 744 %boot-service
0adfe95a 745
661c237b 746 ;; %SHEPHERD-ROOT-SERVICE must come last so that the gexp that
d4053c71 747 ;; execs shepherd comes last in the boot script (XXX). Likewise,
661c237b 748 ;; the cleanup service must come first so that its gexp runs before
d4053c71 749 ;; activation code.
be7be9e8 750 (service cleanup-service-type #f)
661c237b
LC
751 %activation-service
752 %shepherd-root-service
0adfe95a
LC
753
754 (pam-root-service (operating-system-pam-services os))
755 (account-service (append (operating-system-accounts os)
756 (operating-system-groups os))
757 (operating-system-skeletons os))
758 (operating-system-etc-service os)
aea1a42e
LC
759 (service fstab-service-type
760 (filter file-system-needed-for-boot?
761 (operating-system-file-systems os)))
6bad7524
SB
762 (session-environment-service
763 (operating-system-environment-variables os))
6c445817 764 host-name procs root-fs
0adfe95a 765 (service setuid-program-service-type
e0bd47b4 766 (operating-system-setuid-programs os))
af4c3fd5
LC
767 (service profile-service-type
768 (operating-system-packages os))
45eac6cd 769 boot-fs non-boot-fs
aa1145df 770 (append mappings swaps
0adfe95a 771
69cae3d3
LC
772 ;; Add the firmware service.
773 (list %linux-bare-metal-service
774 (service firmware-service-type
775 (operating-system-firmware os)))))))
776
45b2cb43 777(define (hurd-default-essential-services os)
2b76179e
JN
778 (let ((entries (operating-system-directory-base-entries os)))
779 (list (service system-service-type entries)
780 %boot-service
781 %hurd-startup-service
782 %activation-service
400c9ed3
LC
783 (service shepherd-root-service-type
784 (shepherd-configuration
785 (shepherd shepherd-0.8))) ;no Fibers
786
2b76179e
JN
787 (service user-processes-service-type)
788 (account-service (append (operating-system-accounts os)
789 (operating-system-groups os))
790 (operating-system-skeletons os))
791 (root-file-system-service)
792 (service file-system-service-type '())
793 (service fstab-service-type
794 (filter file-system-needed-for-boot?
795 (operating-system-file-systems os)))
796 (pam-root-service (operating-system-pam-services os))
797 (operating-system-etc-service os)
16f8ea06 798 (service setuid-program-service-type
e0bd47b4 799 (operating-system-setuid-programs os))
2b76179e 800 (service profile-service-type (operating-system-packages os)))))
45b2cb43 801
69cae3d3
LC
802(define* (operating-system-services os)
803 "Return all the services of OS, including \"essential\" services."
d466b1fc
LC
804 (instantiate-missing-services
805 (append (operating-system-user-services os)
69cae3d3 806 (operating-system-essential-services os))))
217a5b85 807
9fcfe30d
LC
808(define (operating-system-with-gc-roots os roots)
809 "Return a variant of OS where ROOTS are registered as GC roots."
810 (operating-system
811 (inherit os)
812
813 ;; We use this procedure for the installation OS, which already defines GC
814 ;; roots. Add ROOTS to those.
815 (services (cons (simple-service 'extra-root
816 gc-root-service-type roots)
817 (operating-system-user-services os)))))
818
12a3d7d6
LC
819(define (operating-system-configuration-file os)
820 "Return the configuration file of OS, based on its 'location' field, or #f
821if it could not be determined."
822 (let ((file (and=> (operating-system-location os)
823 location-file)))
824 (and file
825 (or (and (string-prefix? "/" file) file)
826 (search-path %load-path file)))))
827
828(define* (operating-system-with-provenance os
829 #:optional
830 (config-file
831 (operating-system-configuration-file
832 os)))
33b7cb7a
LC
833 "Return a variant of OS that stores its own provenance information,
834including CONFIG-FILE, if available. This is achieved by adding an instance
835of PROVENANCE-SERVICE-TYPE to its services."
836 (operating-system
837 (inherit os)
838 (services (cons (service provenance-service-type config-file)
839 (operating-system-user-services os)))))
840
40281c54
LC
841\f
842;;;
843;;; /etc.
844;;;
845
f34c56be
LC
846(define %base-firmware
847 ;; Firmware usable by default.
52db41af
EB
848 (list ath9k-htc-firmware
849 openfwwf-firmware))
f34c56be 850
53a1cebc
MO
851(define %base-packages-artwork
852 ;; Default set of artwork packages.
853 (list guix-icons))
854
93664fee
BW
855(define %base-packages-utils
856 ;; Default set of utilities packages.
857 (cons* procps psmisc which
f43dce6e 858 (@ (gnu packages admin) shadow-with-man-pages) ;for 'passwd'
93664fee 859
275b37e8 860 guile-3.0-latest
93664fee
BW
861
862 ;; The packages below are also in %FINAL-INPUTS, so take them from
863 ;; there to avoid duplication.
030f6f48
MB
864 (list bash coreutils findutils grep sed
865 diffutils patch gawk tar gzip bzip2 xz lzip)))
93664fee
BW
866
867(define %base-packages-linux
868 ;; Default set of linux specific packages.
869 (list pciutils usbutils
870 util-linux+udev
871 ;; Get 'insmod' & co. from kmod, not module-init-tools, since udev
872 ;; already depends on it anyway.
873 kmod eudev))
874
875(define %base-packages-interactive
876 ;; Default set of common interactive packages.
74168d99 877 (list less mg nano
4170af49 878 nvi
93664fee
BW
879 man-db
880 info-reader ;the standalone Info reader (no Perl)
881 bash-completion
882 kbd
883 ;; The 'sudo' command is already in %SETUID-PROGRAMS, but we also
884 ;; want the other commands and the man pages (notably because
885 ;; auto-completion in Emacs shell relies on man pages.)
886 sudo
887 guile-readline guile-colorized))
888
889(define %base-packages-networking
890 ;; Default set of networking packages.
891 (list inetutils isc-dhcp
892 iproute
7a65beff 893 wget
93664fee
BW
894 ;; wireless-tools is deprecated in favor of iw, but it's still what
895 ;; many people are familiar with, so keep it around.
896 iw wireless-tools))
897
e6e07628 898(define %base-packages-disk-utilities
45eac6cd
BW
899 ;; A well-rounded set of packages for interacting with disks,
900 ;; partitions and filesystems, included with the Guix installation
901 ;; image.
e6e07628
EF
902 (list parted gptfdisk ddrescue
903 ;; We used to provide fdisk from GNU fdisk, but as of version 2.0.0a
904 ;; it pulls Guile 1.8, which takes unreasonable space; furthermore
905 ;; util-linux's fdisk is already available, in %base-packages-linux.
906 cryptsetup mdadm
907 dosfstools
908 btrfs-progs
909 f2fs-tools
9e0509f9
TGR
910 jfsutils
911 xfsprogs))
e6e07628 912
6f436c54
LC
913(define %base-packages
914 ;; Default set of packages globally visible. It should include anything
915 ;; required for basic administrator tasks.
45eac6cd 916 (append %base-packages-artwork
93664fee
BW
917 %base-packages-interactive
918 %base-packages-linux
919 %base-packages-networking
920 %base-packages-utils))
6f436c54 921
548d4c13
LC
922(define %default-issue
923 ;; Default contents for /etc/issue.
924 "
925This is the GNU system. Welcome.\n")
926
568841d4
LC
927(define (local-host-aliases host-name)
928 "Return aliases for HOST-NAME, to be used in /etc/hosts."
929 (string-append "127.0.0.1 localhost " host-name "\n"
930 "::1 localhost " host-name "\n"))
931
c65e1834
LC
932(define (default-/etc/hosts host-name)
933 "Return the default /etc/hosts file."
24e02c28 934 (plain-file "hosts" (local-host-aliases host-name)))
c65e1834 935
38437763
LC
936(define (validated-sudoers-file file)
937 "Return a copy of FILE, a sudoers file, after checking that it is
938syntactically correct."
939 (computed-file "sudoers"
940 (with-imported-modules '((guix build utils))
941 #~(begin
942 (use-modules (guix build utils))
943
944 (invoke #+(file-append sudo "/sbin/visudo")
945 "--check" "--file" #$file)
946 (copy-file #$file #$output)))))
947
24560260
MO
948(define (os-release)
949 (plain-file "os-release"
950 "\
951NAME=\"Guix System\"
952ID=guix
953PRETTY_NAME=\"Guix System\"
954LOGO=guix-icon
955HOME_URL=\"https://guix.gnu.org\"
956DOCUMENTATION_URL=\"https://guix.gnu.org/en/manual\"
957SUPPORT_URL=\"https://guix.gnu.org/en/help\"
958BUG_REPORT_URL=\"https://lists.gnu.org/mailman/listinfo/bug-guix\"
959"))
960
0adfe95a 961(define* (operating-system-etc-service os)
211a5035
LC
962 "Return a <service> that builds a directory containing the static part of
963the /etc directory."
f5ca79d2 964 (let* ((login.defs
e453da13
LF
965 (plain-file "login.defs"
966 (string-append
967 "# Default paths for non-login shells started by su(1).\n"
968 "ENV_PATH /run/setuid-programs:"
969 "/run/current-system/profile/bin:"
970 "/run/current-system/profile/sbin\n"
971 "ENV_SUPATH /run/setuid-programs:"
972 "/run/current-system/profile/bin:"
671e6a81
LC
973 "/run/current-system/profile/sbin\n"
974
975 "\n"
976 "# Allow 'chfn' to change the full name,\n"
977 "# room number, and so on.\n"
978 "CHFN_RESTRICT frwh\n")))
0adfe95a 979
f5ca79d2
JN
980 (hurd (operating-system-hurd os))
981 (issue (plain-file "issue" (operating-system-issue os)))
982 (nsswitch (operating-system-name-service-switch os))
983 (nsswitch (and nsswitch
984 (plain-file "nsswitch.conf"
985 (name-service-switch->string nsswitch))))
986 (sudoers (operating-system-sudoers-file os))
0adfe95a
LC
987
988 ;; Startup file for POSIX-compliant login shells, which set system-wide
989 ;; environment variables.
990 (profile (mixed-text-file "profile" "\
c05c4321 991# Crucial variables that could be missing in the profiles' 'etc/profile'
d9959421
LC
992# because they would require combining both profiles.
993# FIXME: See <http://bugs.gnu.org/20255>.
97ab2c0f 994export MANPATH=$HOME/.guix-profile/share/man:/run/current-system/profile/share/man
8d09bfe2 995export INFOPATH=$HOME/.guix-profile/share/info:/run/current-system/profile/share/info
00239d05
SB
996export XDG_DATA_DIRS=$HOME/.guix-profile/share:/run/current-system/profile/share
997export XDG_CONFIG_DIRS=$HOME/.guix-profile/etc/xdg:/run/current-system/profile/etc/xdg
998
ce380150
TD
999# Make sure libXcursor finds cursors installed into user or system profiles. See <http://bugs.gnu.org/24445>
1000export XCURSOR_PATH=$HOME/.icons:$HOME/.guix-profile/share/icons:/run/current-system/profile/share/icons
1001
d9959421
LC
1002# Ignore the default value of 'PATH'.
1003unset PATH
1004
1005# Load the system profile's settings.
bd7e136d 1006GUIX_PROFILE=/run/current-system/profile ; \\
669786da 1007. /run/current-system/profile/etc/profile
d9959421 1008
cad7e6ab
CSLL
1009# Since 'lshd' does not use pam_env, /etc/environment must be explicitly
1010# loaded when someone logs in via SSH. See <http://bugs.gnu.org/22175>.
1011# We need 'PATH' to be defined here, for 'cat' and 'cut'. Do this before
1012# reading the user's 'etc/profile' to allow variables to be overridden.
1013if [ -f /etc/environment -a -n \"$SSH_CLIENT\" \\
1014 -a -z \"$LINUX_MODULE_DIRECTORY\" ]
1015then
1016 . /etc/environment
1017 export `cat /etc/environment | cut -d= -f1`
1018fi
1019
8d09bfe2
LC
1020# Arrange so that ~/.config/guix/current comes first.
1021for profile in \"$HOME/.guix-profile\" \"$HOME/.config/guix/current\"
cdc5b932
LC
1022do
1023 if [ -f \"$profile/etc/profile\" ]
1024 then
1025 # Load the user profile's settings.
1026 GUIX_PROFILE=\"$profile\" ; \\
1027 . \"$profile/etc/profile\"
1028 else
1029 # At least define this one so that basic things just work
1030 # when the user installs their first package.
1031 export PATH=\"$profile/bin:$PATH\"
1032 fi
1033done
d9959421 1034
a854525a
LC
1035# Prepend setuid programs.
1036export PATH=/run/setuid-programs:$PATH
1037
8d09bfe2
LC
1038# Arrange so that ~/.config/guix/current/share/info comes first.
1039export INFOPATH=\"$HOME/.config/guix/current/share/info:$INFOPATH\"
1040
11202482
LC
1041# Set the umask, notably for users logging in via 'lsh'.
1042# See <http://bugs.gnu.org/22650>.
1043umask 022
2a5f0db4 1044
c08da2ee
LC
1045# Allow Hunspell-based applications (IceCat, LibreOffice, etc.) to
1046# find dictionaries.
1047export DICPATH=\"$HOME/.guix-profile/share/hunspell:/run/current-system/profile/share/hunspell\"
1048
4af7c83b
LC
1049# Allow GStreamer-based applications to find plugins.
1050export GST_PLUGIN_PATH=\"$HOME/.guix-profile/lib/gstreamer-1.0\"
1051
1d167b6e
LC
1052if [ -n \"$BASH_VERSION\" -a -f /etc/bashrc ]
1053then
1054 # Load Bash-specific initialization code.
669786da 1055 . /etc/bashrc
1d167b6e 1056fi
40281c54 1057"))
1d167b6e 1058
0adfe95a 1059 (bashrc (plain-file "bashrc" "\
1d167b6e
LC
1060# Bash-specific initialization.
1061
1062# The 'bash-completion' package.
1063if [ -f /run/current-system/profile/etc/profile.d/bash_completion.sh ]
1064then
1065 # Bash-completion sources ~/.bash_completion. It installs a dynamic
1066 # completion loader that searches its own completion files as well
1067 # as those in ~/.guix-profile and /run/current-system/profile.
1068 source /run/current-system/profile/etc/profile.d/bash_completion.sh
0adfe95a
LC
1069fi\n")))
1070 (etc-service
24560260
MO
1071 `(("os-release" ,#~#$(os-release))
1072 ("services" ,(file-append net-base "/etc/services"))
9e41130b
LC
1073 ("protocols" ,(file-append net-base "/etc/protocols"))
1074 ("rpc" ,(file-append net-base "/etc/rpc"))
0adfe95a
LC
1075 ("login.defs" ,#~#$login.defs)
1076 ("issue" ,#~#$issue)
f5ca79d2 1077 ,@(if nsswitch `(("nsswitch.conf" ,#~#$nsswitch)) '())
0adfe95a
LC
1078 ("profile" ,#~#$profile)
1079 ("bashrc" ,#~#$bashrc)
1080 ("hosts" ,#~#$(or (operating-system-hosts-file os)
1081 (default-/etc/hosts (operating-system-host-name os))))
c694520b
TD
1082 ;; Write the operating-system-host-name to /etc/hostname to prevent
1083 ;; NetworkManager from changing the system's hostname when connecting
1084 ;; to certain networks. Some discussion at
1085 ;; https://lists.gnu.org/archive/html/help-guix/2017-09/msg00037.html
1086 ("hostname" ,(plain-file "hostname" (operating-system-host-name os)))
2a80d9e5
TS
1087 ;; Some programs (e.g., GLib) look at /etc/timezone to find the
1088 ;; name of the current timezone. For details, see
1089 ;; https://lists.gnu.org/archive/html/guix-devel/2019-07/msg00166.html
580984f2
LC
1090 ;; Some programs expect a terminating newline.
1091 ("timezone" ,(plain-file "timezone"
1092 (string-append
1093 (string-trim-both
1094 (operating-system-timezone os))
1095 "\n")))
9e41130b
LC
1096 ("localtime" ,(file-append tzdata "/share/zoneinfo/"
1097 (operating-system-timezone os)))
38437763
LC
1098 ,@(if sudoers
1099 `(("sudoers" ,(validated-sudoers-file sudoers)))
1100 '())
f5ca79d2
JN
1101 ,@(if hurd
1102 `(("login" ,(file-append hurd "/etc/login"))
5681ce50
JN
1103 ("motd" ,(file-append hurd "/etc/motd"))
1104 ("ttys" ,(file-append hurd "/etc/ttys")))
f5ca79d2 1105 '())))))
033adfe7 1106
ab6a279a
LC
1107(define %root-account
1108 ;; Default root account.
1109 (user-account
1110 (name "root")
1111 (password "")
1112 (uid 0) (group "root")
1113 (comment "System administrator")
1114 (home-directory "/root")))
1115
0b6f49ef 1116(define (operating-system-accounts os)
0adfe95a
LC
1117 "Return the user accounts for OS, including an obligatory 'root' account,
1118and excluding accounts requested by services."
1119 ;; Make sure there's a root account.
1120 (if (find (lambda (user)
1121 (and=> (user-account-uid user) zero?))
1122 (operating-system-users os))
1123 (operating-system-users os)
1124 (cons %root-account (operating-system-users os))))
0b6f49ef 1125
84765839
LC
1126(define (maybe-string->file file-name thing)
1127 "If THING is a string, return a <plain-file> with THING as its content.
1128Otherwise just return THING.
1129
1130This is for backward-compatibility of fields that used to be strings and are
1131now file-like objects.."
1132 (match thing
1133 ((? string?)
69daee23 1134 (warning (G_ "using a string for file '~a' is deprecated; \
84765839
LC
1135use 'plain-file' instead~%")
1136 file-name)
1137 (plain-file file-name thing))
1138 (x
1139 x)))
1140
24e02c28
LC
1141(define (maybe-file->monadic file-name thing)
1142 "If THING is a value in %STORE-MONAD, return it as is; otherwise return
1143THING in the %STORE-MONAD.
1144
1145This is for backward-compatibility of fields that used to be monadic values
1146and are now file-like objects."
1147 (with-monad %store-monad
1148 (match thing
1149 ((? procedure?)
69daee23 1150 (warning (G_ "using a monadic value for '~a' is deprecated; \
24e02c28
LC
1151use 'plain-file' instead~%")
1152 file-name)
1153 thing)
1154 (x
1155 (return x)))))
1156
0b6f49ef
LC
1157(define (operating-system-etc-directory os)
1158 "Return that static part of the /etc directory of OS."
0adfe95a
LC
1159 (etc-directory
1160 (fold-services (operating-system-services os)
1161 #:target-type etc-service-type)))
033adfe7 1162
6bad7524
SB
1163(define (operating-system-environment-variables os)
1164 "Return the environment variables of OS for
1165@var{session-environment-service-type}, to be used in @file{/etc/environment}."
1166 `(("LANG" . ,(operating-system-locale os))
54757499
LC
1167 ;; Note: No need to set 'TZ' since (1) we provide /etc/localtime, and (2)
1168 ;; it doesn't work for setuid binaries. See <https://bugs.gnu.org/29212>.
9e41130b 1169 ("TZDIR" . ,(file-append tzdata "/share/zoneinfo"))
6bad7524
SB
1170 ;; Tell 'modprobe' & co. where to look for modules.
1171 ("LINUX_MODULE_DIRECTORY" . "/run/booted-system/kernel/lib/modules")
1172 ;; These variables are honored by OpenSSL (libssl) and Git.
1173 ("SSL_CERT_DIR" . "/etc/ssl/certs")
1174 ("SSL_CERT_FILE" . "/etc/ssl/certs/ca-certificates.crt")
1175 ("GIT_SSL_CAINFO" . "/etc/ssl/certs/ca-certificates.crt")
ae05e366
LC
1176
1177 ;; 'GTK_DATA_PREFIX' must name one directory where GTK+ themes are
1178 ;; searched for.
1179 ("GTK_DATA_PREFIX" . "/run/current-system/profile")
1180
6bad7524
SB
1181 ;; By default, applications that use D-Bus, such as Emacs, abort at startup
1182 ;; when /etc/machine-id is missing. Make sure these warnings are non-fatal.
946465bb
LC
1183 ("DBUS_FATAL_WARNINGS" . "0")
1184
1185 ;; XXX: Normally we wouldn't need to do this, but our glibc@2.23 package
1186 ;; used to look things up in 'PREFIX/lib/locale' instead of
1187 ;; '/run/current-system/locale' as was intended. Keep this hack around so
1188 ;; that people who still have glibc@2.23-using packages in their profiles
1189 ;; can use them correctly.
1190 ;; TODO: Remove when glibc@2.23 is long gone.
1191 ("GUIX_LOCPATH" . "/run/current-system/locale")))
6bad7524 1192
7c414262
JP
1193;; Ensure LST is a list of <setuid-program> records and warn otherwise.
1194(define-with-syntax-properties (ensure-setuid-program-list (lst properties))
1195 (%ensure-setuid-program-list lst properties))
e0bd47b4 1196
7c414262
JP
1197;; We want to be able to use defines, so define a procedure.
1198(define (%ensure-setuid-program-list lst properties)
e0bd47b4
LC
1199 (define warned? #f)
1200
1201 (define (warn-once)
1202 (unless warned?
7c414262 1203 (warning (source-properties->location properties)
e0bd47b4
LC
1204 (G_ "representing setuid programs with file-like objects is \
1205deprecated; use 'setuid-program' instead~%"))
1206 (set! warned? #t)))
1207
1208 (map (match-lambda
e0bd47b4 1209 ((? setuid-program? program)
2826f488
LC
1210 program)
1211 (program
1212 ;; PROGRAM is a file-like or a gexp like #~(string-append #$foo
1213 ;; "/bin/bar").
1214 (warn-once)
1215 (setuid-program (program program))))
e0bd47b4 1216 lst))
a7ac1985 1217
09e028f4
LC
1218(define %setuid-programs
1219 ;; Default set of setuid-root programs.
3b65abac 1220 (let ((shadow (@ (gnu packages admin) shadow)))
a85ec0bf
BW
1221 (map file-like->setuid-program
1222 (list (file-append shadow "/bin/passwd")
671e6a81 1223 (file-append shadow "/bin/chfn")
a85ec0bf
BW
1224 (file-append shadow "/bin/sg")
1225 (file-append shadow "/bin/su")
1226 (file-append shadow "/bin/newgrp")
1227 (file-append shadow "/bin/newuidmap")
1228 (file-append shadow "/bin/newgidmap")
1229 (file-append inetutils "/bin/ping")
1230 (file-append inetutils "/bin/ping6")
1231 (file-append sudo "/bin/sudo")
1232 (file-append sudo "/bin/sudoedit")
1233 (file-append fuse "/bin/fusermount")
cbdfa54c 1234 (file-append fuse-3 "/bin/fusermount3")
a85ec0bf
BW
1235
1236 ;; To allow mounts with the "user" option, "mount" and "umount" must
1237 ;; be setuid-root.
1238 (file-append util-linux "/bin/mount")
1239 (file-append util-linux "/bin/umount")))))
69689380
LC
1240
1241(define %sudoers-specification
1242 ;; Default /etc/sudoers contents: 'root' and all members of the 'wheel'
1243 ;; group can do anything. See
1244 ;; <http://www.sudo.ws/sudo/man/1.8.10/sudoers.man.html>.
1245 ;; TODO: Add a declarative API.
84765839
LC
1246 (plain-file "sudoers" "\
1247root ALL=(ALL) ALL
1248%wheel ALL=(ALL) ALL\n"))
09e028f4 1249
69cae3d3 1250(define* (operating-system-activation-script os)
484a2b3a
LC
1251 "Return the activation script for OS---i.e., the code that \"activates\" the
1252stateful part of OS, including user accounts and groups, special directories,
1253etc."
69cae3d3 1254 (let* ((services (operating-system-services os))
0adfe95a
LC
1255 (activation (fold-services services
1256 #:target-type activation-service-type)))
1257 (activation-service->script activation)))
484a2b3a 1258
69cae3d3 1259(define* (operating-system-boot-script os)
484a2b3a 1260 "Return the boot script for OS---i.e., the code started by the initrd once
69cae3d3
LC
1261we're running in the final root."
1262 (let* ((services (operating-system-services os))
d62e201c 1263 (boot (fold-services services #:target-type boot-service-type)))
efe7d19a 1264 (service-value boot)))
2106d3fc 1265
b2fef041
LC
1266(define (operating-system-user-accounts os)
1267 "Return the list of user accounts of OS."
1268 (let* ((services (operating-system-services os))
1269 (account (fold-services services
1270 #:target-type account-service-type)))
1271 (filter user-account?
efe7d19a 1272 (service-value account))))
b2fef041
LC
1273
1274(define (operating-system-shepherd-service-names os)
1275 "Return the list of Shepherd service names for OS."
1276 (append-map shepherd-service-provision
95f72dcd
MD
1277 (shepherd-configuration-services
1278 (service-value
1279 (fold-services (operating-system-services os)
1280 #:target-type
1281 shepherd-root-service-type)))))
b2fef041 1282
69cae3d3 1283(define* (operating-system-derivation os)
d62e201c 1284 "Return a derivation that builds OS."
69cae3d3 1285 (let* ((services (operating-system-services os))
d62e201c
LC
1286 (system (fold-services services)))
1287 ;; SYSTEM contains the derivation as a monadic value.
efe7d19a 1288 (service-value system)))
d62e201c 1289
69cae3d3 1290(define* (operating-system-profile os)
af4c3fd5
LC
1291 "Return a derivation that builds the system profile of OS."
1292 (mlet* %store-monad
69cae3d3 1293 ((services -> (operating-system-services os))
af4c3fd5
LC
1294 (profile (fold-services services
1295 #:target-type profile-service-type)))
1296 (match profile
1297 (("profile" profile)
1298 (return profile)))))
1299
83bcd0b8
LC
1300(define (operating-system-root-file-system os)
1301 "Return the root file system of OS."
d7e9e0bb
LC
1302 (or (find (lambda (fs)
1303 (string=? "/" (file-system-mount-point fs)))
1304 (operating-system-file-systems os))
1305 (raise (condition
1306 (&message (message "missing root file system"))
1307 (&error-location
1308 (location (operating-system-location os)))))))
83bcd0b8 1309
b4140694
LC
1310(define (operating-system-initrd-file os)
1311 "Return a gexp denoting the initrd file of OS."
83bcd0b8 1312 (define boot-file-systems
4d6b879c 1313 (filter file-system-needed-for-boot?
83bcd0b8
LC
1314 (operating-system-file-systems os)))
1315
de1c158f
LC
1316 (define mapped-devices
1317 (operating-system-boot-mapped-devices os))
1318
1319 (define make-initrd
1320 (operating-system-initrd os))
1321
d422cbb3
LC
1322 (make-initrd boot-file-systems
1323 #:linux (operating-system-kernel os)
1324 #:linux-modules
1325 (operating-system-initrd-modules os)
ae7a316b
LC
1326 #:mapped-devices mapped-devices
1327 #:keyboard-layout (operating-system-keyboard-layout os)))
b4140694 1328
78fbf2bd
MO
1329(define* (operating-system-uuid os #:optional (type 'dce))
1330 "Compute UUID object with a deterministic \"UUID\" for OS, of the given
1331TYPE (one of 'iso9660 or 'dce). Return a UUID object."
1332 ;; Note: For this to be deterministic, we must not hash things that contains
1333 ;; (directly or indirectly) procedures, for example. That rules out
1334 ;; anything that contains gexps, thunk or delayed record fields, etc.
1335
1336 (define service-name
1337 (compose service-type-name service-kind))
1338
1339 (define (file-system-digest fs)
1340 ;; Return a hashable digest that does not contain 'dependencies' since
1341 ;; this field can contain procedures.
1342 (let ((device (file-system-device fs)))
1343 (list (file-system-mount-point fs)
1344 (file-system-type fs)
1345 (file-system-device->string device)
1346 (file-system-options fs))))
1347
1348 (if (eq? type 'iso9660)
1349 (let ((pad (compose (cut string-pad <> 2 #\0)
1350 number->string))
1351 (h (hash (map service-name (operating-system-services os))
1352 3600)))
1353 (bytevector->uuid
1354 (string->iso9660-uuid
1355 (string-append "1970-01-01-"
1356 (pad (hash (operating-system-host-name os) 24)) "-"
1357 (pad (quotient h 60)) "-"
1358 (pad (modulo h 60)) "-"
1359 (pad (hash (map file-system-digest
1360 (operating-system-file-systems os))
1361 100))))
1362 'iso9660))
1363 (bytevector->uuid
1364 (uint-list->bytevector
1365 (list (hash (map file-system-digest
1366 (operating-system-file-systems os))
1367 (- (expt 2 32) 1))
1368 (hash (operating-system-host-name os)
1369 (- (expt 2 32) 1))
1370 (hash (map service-name (operating-system-services os))
1371 (- (expt 2 32) 1))
1372 (hash (map file-system-digest (operating-system-file-systems os))
1373 (- (expt 2 32) 1)))
1374 (endianness little)
1375 4)
1376 type)))
1377
f5582b2c
LC
1378(define (locale-name->definition* name)
1379 "Variant of 'locale-name->definition' that raises an error upon failure."
1380 (match (locale-name->definition name)
1381 (#f
d51bfe24 1382 (raise (formatted-message (G_ "~a: invalid locale name") name)))
f5582b2c
LC
1383 (def def)))
1384
598e19dc
LC
1385(define (operating-system-locale-directory os)
1386 "Return the directory containing the locales compiled for the definitions
1387listed in OS. The C library expects to find it under
1388/run/current-system/locale."
f5582b2c
LC
1389 (define name
1390 (operating-system-locale os))
1391
1392 (define definitions
1393 ;; While we're at it, check whether NAME is defined and add it if needed.
1394 (if (member name (map locale-definition-name
1395 (operating-system-locale-definitions os)))
1396 (operating-system-locale-definitions os)
1397 (cons (locale-name->definition* name)
1398 (operating-system-locale-definitions os))))
1399
1400 (locale-directory definitions
34760ae7 1401 #:libcs (operating-system-locale-libcs os)))
598e19dc 1402
e6cd8581 1403(define* (kernel->boot-label kernel #:key hurd)
c2e9942b 1404 "Return a label for the bootloader menu entry that boots KERNEL."
e6cd8581
JN
1405 (cond ((package? hurd)
1406 (string-append "GNU with the "
1407 (string-titlecase (package-name hurd)) " "
1408 (package-version hurd)))
1409 ((package? kernel)
bdc61ff9
P
1410 (string-append "GNU with "
1411 (string-titlecase (package-name kernel)) " "
4ce3a326 1412 (package-version kernel)))
bdc61ff9
P
1413 ((inferior-package? kernel)
1414 (string-append "GNU with "
b12f8720 1415 (string-titlecase (inferior-package-name kernel)) " "
4ce3a326 1416 (inferior-package-version kernel)))
bdc61ff9 1417 (else "GNU")))
2d23e6f0 1418
3f03a198
LC
1419(define (operating-system-default-label os)
1420 "Return the default label for OS, as it will appear in the bootloader menu
1421entry."
e6cd8581
JN
1422 (kernel->boot-label (operating-system-kernel os)
1423 #:hurd (operating-system-hurd os)))
3f03a198 1424
6b779207
LC
1425(define (store-file-system file-systems)
1426 "Return the file system object among FILE-SYSTEMS that contains the store."
1427 (match (filter (lambda (fs)
1428 (and (file-system-mount? fs)
1429 (not (memq 'bind-mount (file-system-flags fs)))
1430 (string-prefix? (file-system-mount-point fs)
1431 (%store-prefix))))
1432 file-systems)
1433 ((and candidates (head . tail))
1434 (reduce (lambda (fs1 fs2)
1435 (if (> (string-length (file-system-mount-point fs1))
1436 (string-length (file-system-mount-point fs2)))
1437 fs1
1438 fs2))
1439 head
1440 candidates))))
1441
1442(define (operating-system-store-file-system os)
1443 "Return the file system that contains the store of OS."
1444 (store-file-system (operating-system-file-systems os)))
1445
c76b3046 1446(define* (operating-system-bootcfg os #:optional (old-entries '()))
5ece56dc
LC
1447 "Return the bootloader configuration file for OS. Use OLD-ENTRIES,
1448a list of <menu-entry>, to populate the \"old entries\" menu."
b460ba79
MC
1449 (let* ((file-systems (operating-system-file-systems os))
1450 (root-fs (operating-system-root-file-system os))
9782c822 1451 (root-device (file-system-device root-fs))
eaf09639 1452 (locale (operating-system-locale os))
f00e68ac 1453 (crypto-devices (operating-system-bootloader-crypto-devices os))
9782c822
LC
1454 (params (operating-system-boot-parameters
1455 os root-device
1456 #:system-kernel-arguments? #t))
1457 (entry (boot-parameters->menu-entry params))
1458 (bootloader-conf (operating-system-bootloader os)))
b460ba79 1459
46c296dc
LC
1460 (define generate-config-file
1461 (bootloader-configuration-file-generator
1462 (bootloader-configuration-bootloader bootloader-conf)))
1463
9782c822 1464 (generate-config-file bootloader-conf (list entry)
b460ba79 1465 #:old-entries old-entries
eaf09639 1466 #:locale locale
f00e68ac 1467 #:store-crypto-devices crypto-devices
e7b86a0d 1468 #:store-directory-prefix
b460ba79 1469 (btrfs-store-subvolume-file-name file-systems))))
b4140694 1470
912b857e
JN
1471(define (operating-system-multiboot-modules os)
1472 (if (operating-system-hurd os) (hurd-multiboot-modules os) '()))
1473
1474(define (hurd-multiboot-modules os)
1475 (let* ((hurd (operating-system-hurd os))
1476 (root-file-system-command
1477 (list (file-append hurd "/hurd/ext2fs.static")
1478 "ext2fs"
1479 "--multiboot-command-line='${kernel-command-line}'"
1480 "--host-priv-port='${host-port}'"
1481 "--device-master-port='${device-port}'"
1482 "--exec-server-task='${exec-task}'"
1483 "--store-type=typed"
f25e8f76 1484 "--x-xattr-translator-records"
912b857e
JN
1485 "'${root}'" "'$(task-create)'" "'$(task-resume)'"))
1486 (target (%current-target-system))
1487 (libc (if target
1488 (with-parameters ((%current-target-system #f))
1489 ;; TODO: cross-libc has extra patches for the Hurd;
1490 ;; remove in next rebuild cycle
1491 (cross-libc target))
1492 glibc))
1493 (exec-server-command
1494 (list (file-append libc "/lib/ld.so.1") "exec"
1495 (file-append hurd "/hurd/exec") "'$(exec-task=task-create)'")))
1496 (list root-file-system-command exec-server-command)))
1497
a7ef45d9
LC
1498(define* (operating-system-boot-parameters os root-device
1499 #:key system-kernel-arguments?)
1500 "Return a monadic <boot-parameters> record that describes the boot
0dc019e1
MC
1501parameters of OS. When SYSTEM-KERNEL-ARGUMENTS? is true, add the kernel
1502arguments 'root', 'gnu.load' and 'gnu.system' to <boot-parameters>. The
1503SYSTEM-KERNEL-ARGUMENTS? should only be used in necessity, as the 'gnu.load'
1504and 'gnu.system' values are self-referential (they refer to the system), thus
91755fe6 1505susceptible to introduce a cyclic dependency."
395782f2 1506 (let* ((initrd (and (not (operating-system-hurd os))
912b857e 1507 (operating-system-initrd-file os)))
35b44681 1508 (store (operating-system-store-file-system os))
582cf925 1509 (file-systems (operating-system-file-systems os))
f00e68ac 1510 (crypto-devices (operating-system-bootloader-crypto-devices os))
9d449b94 1511 (locale (operating-system-locale os))
35b44681
LC
1512 (bootloader (bootloader-configuration-bootloader
1513 (operating-system-bootloader os)))
1514 (bootloader-name (bootloader-name bootloader))
912b857e
JN
1515 (label (operating-system-label os))
1516 (multiboot-modules (operating-system-multiboot-modules os)))
35b44681
LC
1517 (boot-parameters
1518 (label label)
1519 (root-device root-device)
1520 (kernel (operating-system-kernel-file os))
1521 (kernel-arguments
1522 (if system-kernel-arguments?
1523 (operating-system-kernel-arguments os root-device)
1524 (operating-system-user-kernel-arguments os)))
1525 (initrd initrd)
912b857e 1526 (multiboot-modules multiboot-modules)
35b44681 1527 (bootloader-name bootloader-name)
a28cfee8
LC
1528 (bootloader-menu-entries
1529 (bootloader-configuration-menu-entries (operating-system-bootloader os)))
9d449b94 1530 (locale locale)
35b44681 1531 (store-device (ensure-not-/dev (file-system-device store)))
582cf925 1532 (store-directory-prefix (btrfs-store-subvolume-file-name file-systems))
f00e68ac 1533 (store-crypto-devices crypto-devices)
35b44681 1534 (store-mount-point (file-system-mount-point store)))))
40fad1c2 1535
9b336338
LC
1536(define (device->sexp device)
1537 "Serialize DEVICE as an sexp (really, as an object with a read syntax.)"
1538 (match device
1539 ((? uuid? uuid)
075681d3 1540 `(uuid ,(uuid-type uuid) ,(uuid-bytevector uuid)))
a5acc17a
LC
1541 ((? file-system-label? label)
1542 `(file-system-label ,(file-system-label->string label)))
9b336338
LC
1543 (_
1544 device)))
1545
91755fe6
MC
1546(define* (operating-system-boot-parameters-file os)
1547 "Return a file that describes the boot parameters of OS. The primary use
1548of this file is the reconstruction of GRUB menu entries for old
1549configurations."
35b44681
LC
1550 (let* ((root (operating-system-root-file-system os))
1551 (device (file-system-device root))
91755fe6 1552 (params (operating-system-boot-parameters os device)))
2e37d158
LC
1553 (scheme-file "parameters"
1554 #~(boot-parameters
4a3b8f4d 1555 (version #$(boot-parameters-version params))
2e37d158
LC
1556 (label #$(boot-parameters-label params))
1557 (root-device
1558 #$(device->sexp
1559 (boot-parameters-root-device params)))
1560 (kernel #$(boot-parameters-kernel params))
1561 (kernel-arguments
1562 #$(boot-parameters-kernel-arguments params))
2b76179e
JN
1563 #$@(if (boot-parameters-initrd params)
1564 #~((initrd #$(boot-parameters-initrd params)))
1565 #~())
1566 #$@(if (pair? (boot-parameters-multiboot-modules params))
1567 #~((multiboot-modules
1568 #$(boot-parameters-multiboot-modules params)))
1569 #~())
2e37d158
LC
1570 (bootloader-name #$(boot-parameters-bootloader-name params))
1571 (bootloader-menu-entries
1572 #$(map menu-entry->sexp
1573 (or (and=> (operating-system-bootloader os)
1574 bootloader-configuration-menu-entries)
1575 '())))
9d449b94 1576 (locale #$(boot-parameters-locale params))
2e37d158
LC
1577 (store
1578 (device
1579 #$(device->sexp (boot-parameters-store-device params)))
1580 (mount-point #$(boot-parameters-store-mount-point
582cf925
MÁAV
1581 params))
1582 (directory-prefix
f00e68ac
MÁAV
1583 #$(boot-parameters-store-directory-prefix params))
1584 (crypto-devices
1585 #$(map device->sexp
1586 (boot-parameters-store-crypto-devices params)))))
2e37d158 1587 #:set-load-path? #f)))
64e40dbb 1588
96da5d62
LC
1589(define-gexp-compiler (operating-system-compiler (os <operating-system>)
1590 system target)
1591 ((store-lift
1592 (lambda (store)
1593 ;; XXX: This is not super elegant but we can't pass SYSTEM and TARGET to
1594 ;; 'operating-system-derivation'.
7046e777
LC
1595 (parameterize ((%current-system system)
1596 (%current-target-system target))
1597 (run-with-store store
1598 (mbegin %store-monad
1599 (set-guile-for-build (default-guile))
1600 (operating-system-derivation os))
1601 #:system system
1602 #:target target))))))
96da5d62 1603
033adfe7 1604;;; system.scm ends here