system: Fix the default /etc/hosts.
[jackhill/guix/guix.git] / gnu / system.scm
CommitLineData
033adfe7 1;;; GNU Guix --- Functional package management for GNU
6ce206cb 2;;; Copyright © 2013, 2014 Ludovic Courtès <ludo@gnu.org>
033adfe7
LC
3;;;
4;;; This file is part of GNU Guix.
5;;;
6;;; GNU Guix is free software; you can redistribute it and/or modify it
7;;; under the terms of the GNU General Public License as published by
8;;; the Free Software Foundation; either version 3 of the License, or (at
9;;; your option) any later version.
10;;;
11;;; GNU Guix is distributed in the hope that it will be useful, but
12;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14;;; GNU General Public License for more details.
15;;;
16;;; You should have received a copy of the GNU General Public License
17;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
18
19(define-module (gnu system)
20 #:use-module (guix store)
21 #:use-module (guix monads)
02100028 22 #:use-module (guix gexp)
033adfe7
LC
23 #:use-module (guix records)
24 #:use-module (guix packages)
25 #:use-module (guix derivations)
29fce8b6 26 #:use-module (guix profiles)
033adfe7
LC
27 #:use-module (gnu packages base)
28 #:use-module (gnu packages bash)
bdb36958 29 #:use-module (gnu packages guile)
89a0d00a 30 #:use-module (gnu packages which)
9de46ffb 31 #:use-module (gnu packages admin)
8a07c289 32 #:use-module (gnu packages linux)
033adfe7 33 #:use-module (gnu packages package-management)
6f436c54
LC
34 #:use-module (gnu packages which)
35 #:use-module (gnu packages less)
36 #:use-module (gnu packages zile)
55e70e65
LC
37 #:use-module (gnu packages nano)
38 #:use-module (gnu packages lsof)
db4fdc04
LC
39 #:use-module (gnu services)
40 #:use-module (gnu services dmd)
41 #:use-module (gnu services base)
033adfe7
LC
42 #:use-module (gnu system grub)
43 #:use-module (gnu system shadow)
44 #:use-module (gnu system linux)
735c6dd7 45 #:use-module (gnu system linux-initrd)
c5df1839 46 #:use-module (gnu system file-systems)
5dae0186 47 #:autoload (gnu packages cryptsetup) (cryptsetup)
033adfe7
LC
48 #:use-module (ice-9 match)
49 #:use-module (srfi srfi-1)
50 #:use-module (srfi srfi-26)
51 #:export (operating-system
52 operating-system?
d5b429ab
LC
53
54 operating-system-bootloader
033adfe7 55 operating-system-services
217a5b85 56 operating-system-user-services
033adfe7 57 operating-system-packages
fd3bfc44 58 operating-system-host-name
c65e1834 59 operating-system-hosts-file
fd3bfc44
LC
60 operating-system-kernel
61 operating-system-initrd
62 operating-system-users
63 operating-system-groups
548d4c13 64 operating-system-issue
fd3bfc44
LC
65 operating-system-packages
66 operating-system-timezone
67 operating-system-locale
5dae0186 68 operating-system-mapped-devices
83bcd0b8 69 operating-system-file-systems
b25937e3 70 operating-system-activation-script
033adfe7 71
1aa0033b 72 operating-system-derivation
83bcd0b8 73 operating-system-profile
6f436c54
LC
74 operating-system-grub.cfg
75
df5ce088 76 %setuid-programs
5dae0186
LC
77 %base-packages
78
79 luks-device-mapping))
033adfe7
LC
80
81;;; Commentary:
82;;;
83;;; This module supports whole-system configuration.
84;;;
85;;; Code:
86
87;; System-wide configuration.
88;; TODO: Add per-field docstrings/stexi.
89(define-record-type* <operating-system> operating-system
90 make-operating-system
91 operating-system?
92 (kernel operating-system-kernel ; package
93 (default linux-libre))
d5b429ab
LC
94 (bootloader operating-system-bootloader) ; <grub-configuration>
95
83bcd0b8 96 (initrd operating-system-initrd ; (list fs) -> M derivation
060238ae 97 (default base-initrd))
033adfe7
LC
98
99 (host-name operating-system-host-name) ; string
c65e1834
LC
100 (hosts-file operating-system-hosts-file ; M item | #f
101 (default #f))
033adfe7 102
5dae0186
LC
103 (mapped-devices operating-system-mapped-devices ; list of <mapped-device>
104 (default '()))
8a6d2731 105 (file-systems operating-system-file-systems) ; list of fs
033adfe7
LC
106
107 (users operating-system-users ; list of user accounts
108 (default '()))
109 (groups operating-system-groups ; list of user groups
773e956d 110 (default %base-groups))
033adfe7 111
40281c54
LC
112 (skeletons operating-system-skeletons ; list of name/monadic value
113 (default (default-skeletons)))
548d4c13
LC
114 (issue operating-system-issue ; string
115 (default %default-issue))
40281c54 116
033adfe7 117 (packages operating-system-packages ; list of (PACKAGE OUTPUT...)
6f436c54 118 (default %base-packages)) ; or just PACKAGE
033adfe7
LC
119
120 (timezone operating-system-timezone) ; string
8a6d2731
LC
121 (locale operating-system-locale ; string
122 (default "en_US.UTF-8"))
033adfe7 123
217a5b85 124 (services operating-system-user-services ; list of monadic services
09e028f4
LC
125 (default %base-services))
126
127 (pam-services operating-system-pam-services ; list of PAM services
128 (default (base-pam-services)))
129 (setuid-programs operating-system-setuid-programs
69689380 130 (default %setuid-programs)) ; list of string-valued gexps
033adfe7 131
69689380
LC
132 (sudoers operating-system-sudoers ; /etc/sudoers contents
133 (default %sudoers-specification)))
033adfe7 134
2717a89a 135\f
033adfe7
LC
136;;;
137;;; Derivation.
138;;;
139
23f6056b 140(define* (file-union name files)
033adfe7
LC
141 "Return a derivation that builds a directory containing all of FILES. Each
142item in FILES must be a list where the first element is the file name to use
23f6056b
LC
143in the new directory, and the second element is a gexp denoting the target
144file."
145 (define builder
146 #~(begin
147 (mkdir #$output)
148 (chdir #$output)
149 #$@(map (match-lambda
150 ((target source)
151 #~(symlink #$source #$target)))
152 files)))
033adfe7 153
23f6056b 154 (gexp->derivation name builder))
033adfe7 155
40281c54
LC
156\f
157;;;
158;;; Services.
159;;;
160
5dae0186
LC
161(define (luks-device-mapping source target)
162 "Return a gexp that maps SOURCE to TARGET as a LUKS device, using
163'cryptsetup'."
164 #~(zero? (system* (string-append #$cryptsetup "/sbin/cryptsetup")
165 "open" "--type" "luks"
166 #$source #$target)))
167
023f391c
LC
168(define (other-file-system-services os)
169 "Return file system services for the file systems of OS that are not marked
170as 'needed-for-boot'."
171 (define file-systems
172 (remove (lambda (fs)
173 (or (file-system-needed-for-boot? fs)
174 (string=? "/" (file-system-mount-point fs))))
175 (operating-system-file-systems os)))
176
5dae0186
LC
177 (define (device-mappings fs)
178 (filter (lambda (md)
179 (string=? (string-append "/dev/mapper/"
180 (mapped-device-target md))
181 (file-system-device fs)))
182 (operating-system-mapped-devices os)))
183
184 (define (requirements fs)
185 (map (lambda (md)
186 (symbol-append 'device-mapping-
187 (string->symbol (mapped-device-target md))))
188 (device-mappings fs)))
189
023f391c 190 (sequence %store-monad
5dae0186
LC
191 (map (lambda (fs)
192 (match fs
193 (($ <file-system> device title target type flags opts
194 #f check? create?)
195 (file-system-service device target type
196 #:title title
197 #:requirements (requirements fs)
198 #:check? check?
199 #:create-mount-point? create?
200 #:options opts
201 #:flags flags))))
023f391c
LC
202 file-systems)))
203
5dae0186
LC
204(define (device-mapping-services os)
205 "Return the list of device-mapping services for OS as a monadic list."
206 (sequence %store-monad
207 (map (lambda (md)
208 (let ((source (mapped-device-source md))
209 (target (mapped-device-target md))
210 (command (mapped-device-command md)))
211 (device-mapping-service target
212 (command source target))))
213 (operating-system-mapped-devices os))))
214
217a5b85
LC
215(define (essential-services os)
216 "Return the list of essential services for OS. These are special services
217that implement part of what's declared in OS are responsible for low-level
218bookkeeping."
5dae0186
LC
219 (mlet* %store-monad ((mappings (device-mapping-services os))
220 (root-fs (root-file-system-service))
023f391c
LC
221 (other-fs (other-file-system-services os))
222 (procs (user-processes-service
223 (map (compose first service-provision)
224 other-fs)))
225 (host-name (host-name-service
226 (operating-system-host-name os))))
5dae0186
LC
227 (return (cons* host-name procs root-fs
228 (append other-fs mappings)))))
217a5b85
LC
229
230(define (operating-system-services os)
231 "Return all the services of OS, including \"internal\" services that do not
232explicitly appear in OS."
233 (mlet %store-monad
234 ((user (sequence %store-monad (operating-system-user-services os)))
235 (essential (essential-services os)))
236 (return (append essential user))))
237
40281c54
LC
238\f
239;;;
240;;; /etc.
241;;;
242
6f436c54
LC
243(define %base-packages
244 ;; Default set of packages globally visible. It should include anything
245 ;; required for basic administrator tasks.
55e70e65 246 (cons* procps psmisc which less zile nano
bdb36958 247 (@ (gnu packages admin) dmd) guix
55e70e65 248 lsof ;for Guix's 'list-runtime-roots'
9b762b8d
LC
249 util-linux inetutils isc-dhcp
250 net-tools ; XXX: remove when Inetutils suffices
03e9998f
LC
251
252 ;; Get 'insmod' & co. from kmod, not module-init-tools, since udev
253 ;; already depends on it anyway.
254 kmod udev
255
b63dbd44 256 e2fsprogs kbd
9b762b8d
LC
257
258 ;; The packages below are also in %FINAL-INPUTS, so take them from
259 ;; there to avoid duplication.
260 (map canonical-package
bdb36958 261 (list guile-2.0 bash coreutils findutils grep sed))))
6f436c54 262
548d4c13
LC
263(define %default-issue
264 ;; Default contents for /etc/issue.
265 "
266This is the GNU system. Welcome.\n")
267
c65e1834
LC
268(define (default-/etc/hosts host-name)
269 "Return the default /etc/hosts file."
270 (text-file "hosts"
7d6a52c0
LC
271 (string-append "127.0.0.1 localhost " host-name "\n"
272 "::1 localhost " host-name "\n")))
c65e1834 273
033adfe7 274(define* (etc-directory #:key
3141a8bd 275 (locale "C") (timezone "Europe/Paris")
548d4c13 276 (issue "Hello!\n")
40281c54 277 (skeletons '())
033adfe7 278 (pam-services '())
b4140694 279 (profile "/run/current-system/profile")
c65e1834 280 hosts-file
69689380 281 (sudoers ""))
033adfe7
LC
282 "Return a derivation that builds the static part of the /etc directory."
283 (mlet* %store-monad
ab6a279a 284 ((pam.d (pam-services->directory pam-services))
69689380 285 (sudoers (text-file "sudoers" sudoers))
033adfe7 286 (login.defs (text-file "login.defs" "# Empty for now.\n"))
9038298c
LC
287 (shells (text-file "shells" ; used by xterm and others
288 "\
289/bin/sh
b4140694
LC
290/run/current-system/profile/bin/sh
291/run/current-system/profile/bin/bash\n"))
548d4c13 292 (issue (text-file "issue" issue))
033adfe7
LC
293
294 ;; TODO: Generate bashrc from packages' search-paths.
7aec3683 295 (bashrc (text-file* "bashrc" "
c851400b 296export PS1='\\u@\\h \\w\\$ '
3141a8bd
LC
297
298export LC_ALL=\"" locale "\"
299export TZ=\"" timezone "\"
7aec3683 300export TZDIR=\"" tzdata "/share/zoneinfo\"
3141a8bd 301
d3bbe992 302# Tell 'modprobe' & co. where to look for modules.
62f0a479 303export LINUX_MODULE_DIRECTORY=/run/booted-system/kernel/lib/modules
d3bbe992 304
585c6519
LC
305export PATH=$HOME/.guix-profile/bin:/run/current-system/profile/bin
306export PATH=/run/setuid-programs:/run/current-system/profile/sbin:$PATH
033adfe7
LC
307export CPATH=$HOME/.guix-profile/include:" profile "/include
308export LIBRARY_PATH=$HOME/.guix-profile/lib:" profile "/lib
309alias ls='ls -p --color'
310alias ll='ls -l'
40281c54
LC
311"))
312 (skel (skeleton-directory skeletons)))
23f6056b
LC
313 (file-union "etc"
314 `(("services" ,#~(string-append #$net-base "/etc/services"))
315 ("protocols" ,#~(string-append #$net-base "/etc/protocols"))
316 ("rpc" ,#~(string-append #$net-base "/etc/rpc"))
317 ("pam.d" ,#~#$pam.d)
318 ("login.defs" ,#~#$login.defs)
319 ("issue" ,#~#$issue)
40281c54 320 ("skel" ,#~#$skel)
23f6056b
LC
321 ("shells" ,#~#$shells)
322 ("profile" ,#~#$bashrc)
c65e1834 323 ("hosts" ,#~#$hosts-file)
23f6056b
LC
324 ("localtime" ,#~(string-append #$tzdata "/share/zoneinfo/"
325 #$timezone))
69689380 326 ("sudoers" ,#~#$sudoers)))))
033adfe7 327
1aa0033b 328(define (operating-system-profile os)
29fce8b6
LC
329 "Return a derivation that builds the system profile of OS."
330 (profile-derivation (manifest (map package->manifest-entry
331 (operating-system-packages os)))))
f6a9d048 332
ab6a279a
LC
333(define %root-account
334 ;; Default root account.
335 (user-account
336 (name "root")
337 (password "")
338 (uid 0) (group "root")
339 (comment "System administrator")
340 (home-directory "/root")))
341
0b6f49ef
LC
342(define (operating-system-accounts os)
343 "Return the user accounts for OS, including an obligatory 'root' account."
ab6a279a
LC
344 (define users
345 ;; Make sure there's a root account.
346 (if (find (lambda (user)
347 (and=> (user-account-uid user) zero?))
348 (operating-system-users os))
349 (operating-system-users os)
350 (cons %root-account (operating-system-users os))))
351
217a5b85 352 (mlet %store-monad ((services (operating-system-services os)))
ab6a279a
LC
353 (return (append users
354 (append-map service-user-accounts services)))))
0b6f49ef
LC
355
356(define (operating-system-etc-directory os)
357 "Return that static part of the /etc directory of OS."
033adfe7 358 (mlet* %store-monad
217a5b85 359 ((services (operating-system-services os))
033adfe7
LC
360 (pam-services ->
361 ;; Services known to PAM.
362 (delete-duplicates
09e028f4
LC
363 (append (operating-system-pam-services os)
364 (append-map service-pam-services services))))
40281c54 365 (profile-drv (operating-system-profile os))
c65e1834
LC
366 (skeletons (operating-system-skeletons os))
367 (/etc/hosts (or (operating-system-hosts-file os)
368 (default-/etc/hosts (operating-system-host-name os)))))
62f0a479 369 (etc-directory #:pam-services pam-services
40281c54 370 #:skeletons skeletons
548d4c13 371 #:issue (operating-system-issue os)
0b6f49ef
LC
372 #:locale (operating-system-locale os)
373 #:timezone (operating-system-timezone os)
c65e1834 374 #:hosts-file /etc/hosts
69689380 375 #:sudoers (operating-system-sudoers os)
0b6f49ef 376 #:profile profile-drv)))
033adfe7 377
09e028f4
LC
378(define %setuid-programs
379 ;; Default set of setuid-root programs.
380 (let ((shadow (@ (gnu packages admin) shadow)))
381 (list #~(string-append #$shadow "/bin/passwd")
382 #~(string-append #$shadow "/bin/su")
69689380 383 #~(string-append #$inetutils "/bin/ping")
8a07c289
LC
384 #~(string-append #$sudo "/bin/sudo")
385 #~(string-append #$fuse "/bin/fusermount"))))
69689380
LC
386
387(define %sudoers-specification
388 ;; Default /etc/sudoers contents: 'root' and all members of the 'wheel'
389 ;; group can do anything. See
390 ;; <http://www.sudo.ws/sudo/man/1.8.10/sudoers.man.html>.
391 ;; TODO: Add a declarative API.
392 "root ALL=(ALL) ALL
393%wheel ALL=(ALL) ALL\n")
09e028f4 394
ab6a279a
LC
395(define (user-group->gexp group)
396 "Turn GROUP, a <user-group> object, into a list-valued gexp suitable for
397'active-groups'."
398 #~(list #$(user-group-name group)
399 #$(user-group-password group)
c8fa3426
LC
400 #$(user-group-id group)
401 #$(user-group-system? group)))
ab6a279a
LC
402
403(define (user-account->gexp account)
404 "Turn ACCOUNT, a <user-account> object, into a list-valued gexp suitable for
405'activate-users'."
406 #~`(#$(user-account-name account)
407 #$(user-account-uid account)
408 #$(user-account-group account)
409 #$(user-account-supplementary-groups account)
410 #$(user-account-comment account)
411 #$(user-account-home-directory account)
412 ,#$(user-account-shell account) ; this one is a gexp
459dd9ea
LC
413 #$(user-account-password account)
414 #$(user-account-system? account)))
ab6a279a 415
484a2b3a
LC
416(define (operating-system-activation-script os)
417 "Return the activation script for OS---i.e., the code that \"activates\" the
418stateful part of OS, including user accounts and groups, special directories,
419etc."
09e028f4 420 (define %modules
548f7a8f 421 '((gnu build activation)
8a9e21d1 422 (gnu build linux-boot)
e2f4b305 423 (gnu build file-systems)
548f7a8f 424 (guix build utils)))
09e028f4 425
55ccc388
LC
426 (define (service-activations services)
427 ;; Return the activation scripts for SERVICES.
428 (let ((gexps (filter-map service-activate services)))
429 (sequence %store-monad (map (cut gexp->file "activate-service.scm" <>)
430 gexps))))
431
ab6a279a 432 (mlet* %store-monad ((services (operating-system-services os))
55ccc388 433 (actions (service-activations services))
ab6a279a
LC
434 (etc (operating-system-etc-directory os))
435 (modules (imported-modules %modules))
436 (compiled (compiled-modules %modules))
ab6a279a 437 (accounts (operating-system-accounts os)))
09e028f4
LC
438 (define setuid-progs
439 (operating-system-setuid-programs os))
440
ab6a279a
LC
441 (define user-specs
442 (map user-account->gexp accounts))
443
444 (define groups
445 (append (operating-system-groups os)
446 (append-map service-user-groups services)))
447
448 (define group-specs
449 (map user-group->gexp groups))
450
4654439b 451 (gexp->file "activate"
4dfe6c58
LC
452 #~(begin
453 (eval-when (expand load eval)
454 ;; Make sure 'use-modules' below succeeds.
455 (set! %load-path (cons #$modules %load-path))
456 (set! %load-compiled-path
457 (cons #$compiled %load-compiled-path)))
458
548f7a8f 459 (use-modules (gnu build activation))
4dfe6c58 460
ee248b6a
LC
461 ;; Make sure /bin/sh is valid and current.
462 (activate-/bin/sh
463 (string-append #$(canonical-package bash)
464 "/bin/sh"))
465
4dfe6c58
LC
466 ;; Populate /etc.
467 (activate-etc #$etc)
468
ab6a279a
LC
469 ;; Add users and user groups.
470 (setenv "PATH"
471 (string-append #$(@ (gnu packages admin) shadow)
472 "/sbin"))
473 (activate-users+groups (list #$@user-specs)
474 (list #$@group-specs))
475
09e028f4
LC
476 ;; Activate setuid programs.
477 (activate-setuid-programs (list #$@setuid-progs))
478
55ccc388
LC
479 ;; Run the services' activation snippets.
480 ;; TODO: Use 'load-compiled'.
481 (for-each primitive-load '#$actions)
482
b4140694 483 ;; Set up /run/current-system.
484a2b3a
LC
484 (activate-current-system)))))
485
486(define (operating-system-boot-script os)
487 "Return the boot script for OS---i.e., the code started by the initrd once
488we're running in the final root."
489 (mlet* %store-monad ((services (operating-system-services os))
490 (activate (operating-system-activation-script os))
491 (dmd-conf (dmd-configuration-file services)))
492 (gexp->file "boot"
493 #~(begin
494 ;; Activate the system.
495 ;; TODO: Use 'load-compiled'.
496 (primitive-load #$activate)
497
498 ;; Keep track of the booted system.
499 (false-if-exception (delete-file "/run/booted-system"))
500 (symlink (readlink "/run/current-system")
501 "/run/booted-system")
b4140694 502
26a728eb
LC
503 ;; Close any remaining open file descriptors to be on the
504 ;; safe side. This must be the very last thing we do,
505 ;; because Guile has internal FDs such as 'sleep_pipe'
506 ;; that need to be alive.
507 (let loop ((fd 3))
508 (when (< fd 1024)
509 (false-if-exception (close-fdes fd))
510 (loop (+ 1 fd))))
511
4dfe6c58
LC
512 ;; Start dmd.
513 (execl (string-append #$dmd "/bin/dmd")
514 "dmd" "--config" #$dmd-conf)))))
2106d3fc 515
83bcd0b8
LC
516(define (operating-system-root-file-system os)
517 "Return the root file system of OS."
518 (find (match-lambda
d4c87617 519 (($ <file-system> _ _ "/") #t)
83bcd0b8
LC
520 (_ #f))
521 (operating-system-file-systems os)))
522
b4140694
LC
523(define (operating-system-initrd-file os)
524 "Return a gexp denoting the initrd file of OS."
83bcd0b8
LC
525 (define boot-file-systems
526 (filter (match-lambda
d4c87617 527 (($ <file-system> device title "/")
3c05b4bc 528 #t)
d4c87617
LC
529 (($ <file-system> device title mount-point type flags
530 options boot?)
3c05b4bc 531 boot?))
83bcd0b8
LC
532 (operating-system-file-systems os)))
533
5dae0186
LC
534 ;; TODO: Pass the mapped devices required by boot-time file systems to the
535 ;; initrd.
b4140694
LC
536 (mlet %store-monad
537 ((initrd ((operating-system-initrd os) boot-file-systems)))
538 (return #~(string-append #$initrd "/initrd"))))
539
2d23e6f0
LC
540(define (kernel->grub-label kernel)
541 "Return a label for the GRUB menu entry that boots KERNEL."
542 (string-append "GNU system with "
543 (string-titlecase (package-name kernel)) " "
544 (package-version kernel)
545 " (technology preview)"))
546
fe6e3fe2
LC
547(define* (operating-system-grub.cfg os #:optional (old-entries '()))
548 "Return the GRUB configuration file for OS. Use OLD-ENTRIES to populate the
549\"old entries\" menu."
0b6f49ef 550 (mlet* %store-monad
b4140694 551 ((system (operating-system-derivation os))
83bcd0b8 552 (root-fs -> (operating-system-root-file-system os))
b4140694 553 (kernel -> (operating-system-kernel os))
033adfe7 554 (entries -> (list (menu-entry
2d23e6f0 555 (label (kernel->grub-label kernel))
033adfe7 556 (linux kernel)
f6a7b21d 557 (linux-arguments
83bcd0b8
LC
558 (list (string-append "--root="
559 (file-system-device root-fs))
b4140694
LC
560 #~(string-append "--system=" #$system)
561 #~(string-append "--load=" #$system
562 "/boot")))
563 (initrd #~(string-append #$system "/initrd"))))))
fe6e3fe2
LC
564 (grub-configuration-file (operating-system-bootloader os) entries
565 #:old-entries old-entries)))
b4140694 566
64e40dbb
LC
567(define (operating-system-parameters-file os)
568 "Return a file that describes the boot parameters of OS. The primary use of
569this file is the reconstruction of GRUB menu entries for old configurations."
570 (mlet %store-monad ((initrd (operating-system-initrd-file os))
571 (root -> (operating-system-root-file-system os))
572 (label -> (kernel->grub-label
573 (operating-system-kernel os))))
574 (gexp->file "parameters"
575 #~(boot-parameters (version 0)
576 (label #$label)
577 (root-device #$(file-system-device root))
578 (kernel #$(operating-system-kernel os))
579 (initrd #$initrd)))))
580
b4140694
LC
581(define (operating-system-derivation os)
582 "Return a derivation that builds OS."
583 (mlet* %store-monad
584 ((profile (operating-system-profile os))
585 (etc (operating-system-etc-directory os))
586 (boot (operating-system-boot-script os))
587 (kernel -> (operating-system-kernel os))
64e40dbb
LC
588 (initrd (operating-system-initrd-file os))
589 (params (operating-system-parameters-file os)))
23f6056b 590 (file-union "system"
f6a7b21d 591 `(("boot" ,#~#$boot)
23f6056b 592 ("kernel" ,#~#$kernel)
64e40dbb 593 ("parameters" ,#~#$params)
b4140694 594 ("initrd" ,initrd)
23f6056b 595 ("profile" ,#~#$profile)
23f6056b 596 ("etc" ,#~#$etc)))))
033adfe7
LC
597
598;;; system.scm ends here