1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021 Ludovic Courtès <ludo@gnu.org>
3 ;;; Copyright © 2015, 2016 Alex Kost <alezost@gmail.com>
4 ;;; Copyright © 2015, 2016, 2020 Mark H Weaver <mhw@netris.org>
5 ;;; Copyright © 2015 Sou Bunnbu <iyzsong@gmail.com>
6 ;;; Copyright © 2016, 2017 Leo Famulari <leo@famulari.name>
7 ;;; Copyright © 2016 David Craven <david@craven.ch>
8 ;;; Copyright © 2016 Ricardo Wurmus <rekado@elephly.net>
9 ;;; Copyright © 2018 Mathieu Othacehe <m.othacehe@gmail.com>
10 ;;; Copyright © 2019 Efraim Flashner <efraim@flashner.co.il>
11 ;;; Copyright © 2019 Tobias Geerinckx-Rice <me@tobias.gr>
12 ;;; Copyright © 2019 John Soo <jsoo1@asu.edu>
13 ;;; Copyright © 2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
14 ;;; Copyright © 2020 Florian Pelz <pelzflorian@pelzflorian.de>
15 ;;; Copyright © 2020, 2021 Brice Waegeneire <brice@waegenei.re>
16 ;;; Copyright © 2021 qblade <qblade@protonmail.com>
17 ;;; Copyright © 2021 Hui Lu <luhuins@163.com>
19 ;;; This file is part of GNU Guix.
21 ;;; GNU Guix is free software; you can redistribute it and/or modify it
22 ;;; under the terms of the GNU General Public License as published by
23 ;;; the Free Software Foundation; either version 3 of the License, or (at
24 ;;; your option) any later version.
26 ;;; GNU Guix is distributed in the hope that it will be useful, but
27 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
28 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29 ;;; GNU General Public License for more details.
31 ;;; You should have received a copy of the GNU General Public License
32 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
34 (define-module (gnu services base)
35 #:use-module (guix store)
36 #:use-module (guix deprecation)
37 #:use-module (gnu services)
38 #:use-module (gnu services admin)
39 #:use-module (gnu services shepherd)
40 #:use-module (gnu services sysctl)
41 #:use-module (gnu system pam)
42 #:use-module (gnu system shadow) ; 'user-account', etc.
43 #:use-module (gnu system uuid)
44 #:use-module (gnu system file-systems) ; 'file-system', etc.
45 #:use-module (gnu system keyboard)
46 #:use-module (gnu system mapped-devices)
47 #:use-module ((gnu system linux-initrd)
48 #:select (file-system-packages))
49 #:use-module (gnu packages admin)
50 #:use-module ((gnu packages linux)
51 #:select (alsa-utils crda eudev e2fsprogs fuse gpm kbd lvm2 rng-tools))
52 #:use-module (gnu packages bash)
53 #:use-module ((gnu packages base)
54 #:select (coreutils glibc glibc-utf8-locales))
55 #:use-module (gnu packages package-management)
56 #:use-module ((gnu packages gnupg) #:select (guile-gcrypt))
57 #:use-module (gnu packages linux)
58 #:use-module (gnu packages terminals)
59 #:use-module ((gnu build file-systems)
60 #:select (mount-flags->bit-mask))
61 #:use-module (guix gexp)
62 #:use-module (guix records)
63 #:use-module (guix modules)
64 #:use-module ((guix self) #:select (make-config.scm))
65 #:use-module (srfi srfi-1)
66 #:use-module (srfi srfi-26)
67 #:use-module (ice-9 match)
68 #:use-module (ice-9 format)
69 #:re-export (user-processes-service-type ;backwards compatibility
70 %default-substitute-urls)
71 #:export (fstab-service-type
72 root-file-system-service
73 file-system-service-type
77 console-font-service-type
79 virtual-terminal-service-type
84 static-networking-interface
86 static-networking-netmask
87 static-networking-gateway
88 static-networking-requirement
90 static-networking-service
91 static-networking-service-type
95 udev-configuration-rules
108 agetty-configuration?
112 mingetty-configuration
113 mingetty-configuration-tty
114 mingetty-configuration-auto-login
115 mingetty-configuration-login-program
116 mingetty-configuration-login-pause?
117 mingetty-configuration-clear-on-logout?
118 mingetty-configuration-mingetty
119 mingetty-configuration?
121 mingetty-service-type
124 %nscd-default-configuration
136 syslog-configuration?
141 %default-authorized-guix-keys
145 guix-configuration-guix
146 guix-configuration-build-group
147 guix-configuration-build-accounts
148 guix-configuration-authorize-key?
149 guix-configuration-authorized-keys
150 guix-configuration-use-substitutes?
151 guix-configuration-substitute-urls
152 guix-configuration-extra-options
153 guix-configuration-log-file
156 guix-publish-configuration
157 guix-publish-configuration?
158 guix-publish-configuration-guix
159 guix-publish-configuration-port
160 guix-publish-configuration-host
161 guix-publish-configuration-compression
162 guix-publish-configuration-compression-level ;deprecated
163 guix-publish-configuration-nar-path
164 guix-publish-configuration-cache
165 guix-publish-configuration-ttl
166 guix-publish-service-type
172 urandom-seed-service-type
180 kmscon-configuration?
183 pam-limits-service-type
192 ;;; Base system services---i.e., services that 99% of the users will want to
203 (define (file-system->fstab-entry file-system)
204 "Return a @file{/etc/fstab} entry for @var{file-system}."
205 (string-append (match (file-system-device file-system)
206 ((? file-system-label? label)
207 (string-append "LABEL="
208 (file-system-label->string label)))
210 (string-append "UUID=" (uuid->string uuid)))
214 (file-system-mount-point file-system) "\t"
215 (file-system-type file-system) "\t"
216 (or (file-system-options file-system) "defaults") "\t"
218 ;; XXX: Omit the 'fs_freq' and 'fs_passno' fields because we
219 ;; don't have anything sensible to put in there.
222 (define (file-systems->fstab file-systems)
223 "Return a @file{/etc} entry for an @file{fstab} describing
225 `(("fstab" ,(plain-file "fstab"
228 # This file was generated from your Guix configuration. Any changes
229 # will be lost upon reboot or reconfiguration.\n\n"
230 (string-join (map file-system->fstab-entry
235 (define fstab-service-type
236 ;; The /etc/fstab service.
237 (service-type (name 'fstab)
239 (list (service-extension etc-service-type
240 file-systems->fstab)))
241 (compose concatenate)
244 "Populate the @file{/etc/fstab} based on the given file
247 (define %root-file-system-shepherd-service
249 (documentation "Take care of the root file system.")
250 (provision '(root-file-system))
253 ;; Return #f if successfully stopped.
256 (call-with-blocked-asyncs
258 (let ((null (%make-void-port "w")))
259 ;; Close 'shepherd.log'.
260 (display "closing log\n")
261 ((@ (shepherd comm) stop-logging))
263 ;; Redirect the default output ports..
264 (set-current-output-port null)
265 (set-current-error-port null)
267 ;; Close /dev/console.
268 (for-each close-fdes '(0 1 2))
270 ;; At this point, there are no open files left, so the
271 ;; root file system can be re-mounted read-only.
273 (logior MS_REMOUNT MS_RDONLY)
279 (define root-file-system-service-type
280 (shepherd-service-type 'root-file-system
281 (const %root-file-system-shepherd-service)
282 (description "Take care of syncing the root file
283 system and of remounting it read-only when the system shuts down.")))
285 (define (root-file-system-service)
286 "Return a service whose sole purpose is to re-mount read-only the root file
287 system upon shutdown (aka. cleanly \"umounting\" root.)
289 This service must be the root of the service dependency graph so that its
290 'stop' action is invoked when shepherd is the only process left."
291 (service root-file-system-service-type #f))
293 (define (file-system->shepherd-service-name file-system)
294 "Return the symbol that denotes the service mounting and unmounting
296 (symbol-append 'file-system-
297 (string->symbol (file-system-mount-point file-system))))
299 (define (mapped-device->shepherd-service-name md)
300 "Return the symbol that denotes the shepherd service of MD, a <mapped-device>."
301 (symbol-append 'device-mapping-
302 (string->symbol (string-join
303 (mapped-device-targets md) "-"))))
305 (define dependency->shepherd-service-name
307 ((? mapped-device? md)
308 (mapped-device->shepherd-service-name md))
310 (file-system->shepherd-service-name fs))))
312 (define (file-system-shepherd-service file-system)
313 "Return the shepherd service for @var{file-system}, or @code{#f} if
314 @var{file-system} is not auto-mounted upon boot."
315 (let ((target (file-system-mount-point file-system))
316 (create? (file-system-create-mount-point? file-system))
317 (dependencies (file-system-dependencies file-system))
318 (packages (file-system-packages (list file-system))))
319 (and (file-system-mount? file-system)
320 (with-imported-modules (source-module-closure
321 '((gnu build file-systems)))
323 (provision (list (file-system->shepherd-service-name file-system)))
324 (requirement `(root-file-system udev
325 ,@(map dependency->shepherd-service-name dependencies)))
326 (documentation "Check, mount, and unmount the given file system.")
327 (start #~(lambda args
332 (let (($PATH (getenv "PATH")))
333 ;; Make sure fsck.ext2 & co. can be found.
336 ;; Don’t display the PATH settings.
337 (with-output-to-port (%make-void-port "w")
339 (set-path-environment-variable "PATH"
345 '#$(file-system->spec file-system))
348 (setenv "PATH" $PATH)))
351 ;; Normally there are no processes left at this point, so
352 ;; TARGET can be safely unmounted.
354 ;; Make sure PID 1 doesn't keep TARGET busy.
360 ;; We need additional modules.
361 (modules `(((gnu build file-systems)
362 #:select (mount-file-system))
363 (gnu system file-systems)
364 ,@%default-modules)))))))
366 (define (file-system-shepherd-services file-systems)
367 "Return the list of Shepherd services for FILE-SYSTEMS."
368 (let* ((file-systems (filter file-system-mount? file-systems)))
371 (provision '(file-systems))
372 (requirement (cons* 'root-file-system 'user-file-systems
373 (map file-system->shepherd-service-name
375 (documentation "Target for all the initially-mounted file systems")
377 (stop #~(const #f))))
379 (define known-mount-points
380 (map file-system-mount-point file-systems))
384 (documentation "Unmount manually-mounted file systems.")
385 (provision '(user-file-systems))
388 (define (known? mount-point)
390 (cons* "/proc" "/sys" '#$known-mount-points)))
392 ;; Make sure we don't keep the user's mount points busy.
395 (for-each (lambda (mount-point)
396 (format #t "unmounting '~a'...~%" mount-point)
399 (umount mount-point))
401 (let ((errno (system-error-errno args)))
402 (format #t "failed to unmount '~a': ~a~%"
403 mount-point (strerror errno))))))
404 (filter (negate known?) (mount-points)))
407 (cons* sink user-unmount
408 (map file-system-shepherd-service file-systems))))
410 (define (file-system-fstab-entries file-systems)
411 "Return the subset of @var{file-systems} that should have an entry in
413 ;; /etc/fstab is about telling fsck(8), mount(8), and umount(8) about
414 ;; relevant file systems they'll have to deal with. That excludes "pseudo"
417 ;; In particular, things like GIO (part of GLib) use it to determine the set
418 ;; of mounts, which is then used by graphical file managers and desktop
419 ;; environments to display "volume" icons. Thus, we really need to exclude
420 ;; those pseudo file systems from the list.
421 (remove (lambda (file-system)
422 (or (member (file-system-type file-system)
423 %pseudo-file-system-types)
424 (memq 'bind-mount (file-system-flags file-system))))
427 (define file-system-service-type
428 (service-type (name 'file-systems)
430 (list (service-extension shepherd-root-service-type
431 file-system-shepherd-services)
432 (service-extension fstab-service-type
433 file-system-fstab-entries)
435 ;; Have 'user-processes' depend on 'file-systems'.
436 (service-extension user-processes-service-type
437 (const '(file-systems)))))
438 (compose concatenate)
441 "Provide Shepherd services to mount and unmount the given
442 file systems, as well as corresponding @file{/etc/fstab} entries.")))
447 ;;; Preserve entropy to seed /dev/urandom on boot.
450 (define %random-seed-file
451 "/var/lib/random-seed")
453 (define (urandom-seed-shepherd-service _)
454 "Return a shepherd service for the /dev/urandom seed."
455 (list (shepherd-service
456 (documentation "Preserve entropy across reboots for /dev/urandom.")
457 (provision '(urandom-seed))
459 ;; Depend on udev so that /dev/hwrng is available.
460 (requirement '(file-systems udev))
463 ;; On boot, write random seed into /dev/urandom.
464 (when (file-exists? #$%random-seed-file)
465 (call-with-input-file #$%random-seed-file
467 (call-with-output-file "/dev/urandom"
469 (dump-port seed urandom)
471 ;; Writing SEED to URANDOM isn't enough: we must
472 ;; also tell the kernel to account for these
473 ;; extra bits of entropy.
474 (let ((bits (* 8 (stat:size (stat seed)))))
475 (add-to-entropy-count urandom bits)))))))
477 ;; Try writing from /dev/hwrng into /dev/urandom.
478 ;; It seems that the file /dev/hwrng always exists, even
479 ;; when there is no hardware random number generator
480 ;; available. So, we handle a failed read or any other error
481 ;; reported by the operating system.
482 (let ((buf (catch 'system-error
484 (call-with-input-file "/dev/hwrng"
486 (get-bytevector-n hwrng 512))))
487 ;; Silence is golden...
490 (call-with-output-file "/dev/urandom"
492 (put-bytevector urandom buf)
493 (let ((bits (* 8 (bytevector-length buf))))
494 (add-to-entropy-count urandom bits))))))
496 ;; Immediately refresh the seed in case the system doesn't
497 ;; shut down cleanly.
498 (call-with-input-file "/dev/urandom"
500 (let ((previous-umask (umask #o077))
501 (buf (make-bytevector 512)))
502 (mkdir-p (dirname #$%random-seed-file))
503 (get-bytevector-n! urandom buf 0 512)
504 (call-with-output-file #$%random-seed-file
506 (put-bytevector seed buf)))
507 (umask previous-umask))))
510 ;; During shutdown, write from /dev/urandom into random seed.
511 (let ((buf (make-bytevector 512)))
512 (call-with-input-file "/dev/urandom"
514 (let ((previous-umask (umask #o077)))
515 (get-bytevector-n! urandom buf 0 512)
516 (mkdir-p (dirname #$%random-seed-file))
517 (call-with-output-file #$%random-seed-file
519 (put-bytevector seed buf)))
520 (umask previous-umask))
522 (modules `((rnrs bytevectors)
524 ,@%default-modules)))))
526 (define urandom-seed-service-type
527 (service-type (name 'urandom-seed)
529 (list (service-extension shepherd-root-service-type
530 urandom-seed-shepherd-service)
532 ;; Have 'user-processes' depend on 'urandom-seed'.
533 ;; This ensures that user processes and daemons don't
534 ;; start until we have seeded the PRNG.
535 (service-extension user-processes-service-type
536 (const '(urandom-seed)))))
539 "Seed the @file{/dev/urandom} pseudo-random number
540 generator (RNG) with the value recorded when the system was last shut
545 ;;; Add hardware random number generator to entropy pool.
548 (define-record-type* <rngd-configuration>
549 rngd-configuration make-rngd-configuration
551 (rng-tools rngd-configuration-rng-tools) ;package
552 (device rngd-configuration-device)) ;string
554 (define rngd-service-type
555 (shepherd-service-type
558 (define rng-tools (rngd-configuration-rng-tools config))
559 (define device (rngd-configuration-device config))
562 (list (file-append rng-tools "/sbin/rngd")
566 (documentation "Add TRNG to entropy pool.")
567 (requirement '(udev))
569 (start #~(make-forkexec-constructor '#$rngd-command))
570 (stop #~(make-kill-destructor))))
571 (description "Run the @command{rngd} random number generation daemon to
572 supply entropy to the kernel's pool.")))
574 (define* (rngd-service #:key
575 (rng-tools rng-tools)
576 (device "/dev/hwrng"))
577 "Return a service that runs the @command{rngd} program from @var{rng-tools}
578 to add @var{device} to the kernel's entropy pool. The service will fail if
579 @var{device} does not exist."
580 (service rngd-service-type
582 (rng-tools rng-tools)
590 (define host-name-service-type
591 (shepherd-service-type
595 (documentation "Initialize the machine's host name.")
596 (provision '(host-name))
598 (sethostname #$name)))
600 (description "Initialize the machine's host name.")))
602 (define (host-name-service name)
603 "Return a service that sets the host name to @var{name}."
604 (service host-name-service-type name))
606 (define virtual-terminal-service-type
607 ;; Ensure that virtual terminals run in UTF-8 mode. This is the case by
608 ;; default with recent Linux kernels, but this service allows us to ensure
609 ;; this. This service must start before any 'term-' service so that newly
610 ;; created terminals inherit this property. See
611 ;; <https://bugs.gnu.org/30505> for a discussion.
612 (shepherd-service-type
615 (let ((knob "/sys/module/vt/parameters/default_utf8"))
617 (documentation "Set virtual terminals in UTF-8 module.")
618 (provision '(virtual-terminal))
619 (requirement '(root-file-system))
621 ;; In containers /sys is read-only so don't insist on
622 ;; writing to this file.
623 (unless (= 1 (call-with-input-file #$knob read))
624 (call-with-output-file #$knob
628 (stop #~(const #f)))))
630 (description "Ensure the Linux virtual terminals run in UTF-8 mode.")))
632 (define console-keymap-service-type
633 (shepherd-service-type
637 (documentation (string-append "Load console keymap (loadkeys)."))
638 (provision '(console-keymap))
640 (zero? (system* #$(file-append kbd "/bin/loadkeys")
643 (description "@emph{This service is deprecated in favor of the
644 @code{keyboard-layout} field of @code{operating-system}.} Load the given list
645 of console keymaps with @command{loadkeys}.")))
647 (define %default-console-font
648 ;; Note: 'LatGrkCyr-8x16' has the advantage of providing three common
649 ;; scripts as well as glyphs for em dash, quotation marks, and other Unicode
650 ;; codepoints notably found in the UTF-8 manual.
653 (define (console-font-shepherd-services tty+font)
654 "Return a list of Shepherd services for each pair in TTY+FONT."
657 (let ((device (string-append "/dev/" tty)))
659 (documentation "Load a Unicode console font.")
660 (provision (list (symbol-append 'console-font-
661 (string->symbol tty))))
663 ;; Start after mingetty has been started on TTY, otherwise the settings
665 (requirement (list (symbol-append 'term-
666 (string->symbol tty))))
669 ;; It could be that mingetty is not fully ready yet,
670 ;; which we check by calling 'ttyname'.
672 (unless (or (zero? i)
673 (call-with-input-file #$device
675 (false-if-exception (ttyname port)))))
679 ;; Assume the VT is already in UTF-8 mode, thanks to
680 ;; the 'virtual-terminal' service.
682 ;; 'setfont' returns EX_OSERR (71) when an
683 ;; KDFONTOP ioctl fails, for example. Like
684 ;; systemd's vconsole support, let's not treat
686 (case (status:exit-val
687 (system* #$(file-append kbd "/bin/setfont")
688 "-C" #$device #$font))
695 (define console-font-service-type
696 (service-type (name 'console-fonts)
698 (list (service-extension shepherd-root-service-type
699 console-font-shepherd-services)))
700 (compose concatenate)
703 "Install the given fonts on the specified ttys (fonts are per
704 virtual console on GNU/Linux). The value of this service is a list of
705 tty/font pairs. The font can be the name of a font provided by the @code{kbd}
706 package or any valid argument to @command{setfont}, as in this example:
709 `((\"tty1\" . \"LatGrkCyr-8x16\")
710 (\"tty2\" . ,(file-append
712 \"/share/kbd/consolefonts/TamzenForPowerline10x20.psf\"))
713 (\"tty3\" . ,(file-append
715 \"/share/consolefonts/ter-132n\"))) ; for HDPI
718 (define* (console-font-service tty #:optional (font "LatGrkCyr-8x16"))
719 "This procedure is deprecated in favor of @code{console-font-service-type}.
721 Return a service that sets up Unicode support in @var{tty} and loads
722 @var{font} for that tty (fonts are per virtual console in Linux.)"
723 (simple-service (symbol-append 'console-font- (string->symbol tty))
724 console-font-service-type `((,tty . ,font))))
726 (define %default-motd
727 (plain-file "motd" "This is the GNU operating system, welcome!\n\n"))
729 (define-record-type* <login-configuration>
730 login-configuration make-login-configuration
732 (motd login-configuration-motd ;file-like
733 (default %default-motd))
734 ;; Allow empty passwords by default so that first-time users can log in when
735 ;; the 'root' account has just been created.
736 (allow-empty-passwords? login-configuration-allow-empty-passwords?
737 (default #t))) ;Boolean
739 (define (login-pam-service config)
740 "Return the list of PAM service needed for CONF."
741 ;; Let 'login' be known to PAM.
742 (list (unix-pam-service "login"
744 #:allow-empty-passwords?
745 (login-configuration-allow-empty-passwords? config)
747 (login-configuration-motd config))))
749 (define login-service-type
750 (service-type (name 'login)
751 (extensions (list (service-extension pam-root-service-type
753 (default-value (login-configuration))
755 "Provide a console log-in service as specified by its
756 configuration value, a @code{login-configuration} object.")))
758 (define* (login-service #:optional (config (login-configuration)))
759 "Return a service configure login according to @var{config}, which specifies
760 the message of the day, among other things."
761 (service login-service-type config))
763 (define-record-type* <agetty-configuration>
764 agetty-configuration make-agetty-configuration
765 agetty-configuration?
766 (agetty agetty-configuration-agetty ;<package>
767 (default util-linux))
768 (tty agetty-configuration-tty) ;string | #f
769 (term agetty-term ;string | #f
771 (baud-rate agetty-baud-rate ;string | #f
773 (auto-login agetty-auto-login ;list of strings | #f
775 (login-program agetty-login-program ;gexp
776 (default (file-append shadow "/bin/login")))
777 (login-pause? agetty-login-pause? ;Boolean
779 (eight-bits? agetty-eight-bits? ;Boolean
781 (no-reset? agetty-no-reset? ;Boolean
783 (remote? agetty-remote? ;Boolean
785 (flow-control? agetty-flow-control? ;Boolean
787 (host agetty-host ;string | #f
789 (no-issue? agetty-no-issue? ;Boolean
791 (init-string agetty-init-string ;string | #f
793 (no-clear? agetty-no-clear? ;Boolean
795 (local-line agetty-local-line ;always | never | auto
797 (extract-baud? agetty-extract-baud? ;Boolean
799 (skip-login? agetty-skip-login? ;Boolean
801 (no-newline? agetty-no-newline? ;Boolean
803 (login-options agetty-login-options ;string | #f
805 (chroot agetty-chroot ;string | #f
807 (hangup? agetty-hangup? ;Boolean
809 (keep-baud? agetty-keep-baud? ;Boolean
811 (timeout agetty-timeout ;integer | #f
813 (detect-case? agetty-detect-case? ;Boolean
815 (wait-cr? agetty-wait-cr? ;Boolean
817 (no-hints? agetty-no-hints? ;Boolean
819 (no-hostname? agetty-no hostname? ;Boolean
821 (long-hostname? agetty-long-hostname? ;Boolean
823 (erase-characters agetty-erase-characters ;string | #f
825 (kill-characters agetty-kill-characters ;string | #f
827 (chdir agetty-chdir ;string | #f
829 (delay agetty-delay ;integer | #f
831 (nice agetty-nice ;integer | #f
833 ;; "Escape hatch" for passing arbitrary command-line arguments.
834 (extra-options agetty-extra-options ;list of strings
836 ;;; XXX Unimplemented for now!
837 ;;; (issue-file agetty-issue-file ;file-like
841 (define (default-serial-port)
842 "Return a gexp that determines a reasonable default serial port
843 to use as the tty. This is primarily useful for headless systems."
844 (with-imported-modules (source-module-closure
845 '((gnu build linux-boot))) ;for 'find-long-options'
847 ;; console=device,options
848 ;; device: can be tty0, ttyS0, lp0, ttyUSB0 (serial).
849 ;; options: BBBBPNF. P n|o|e, N number of bits,
850 ;; F flow control (r RTS)
851 (let* ((not-comma (char-set-complement (char-set #\,)))
852 (command (linux-command-line))
853 (agetty-specs (find-long-options "agetty.tty" command))
854 (console-specs (filter (lambda (spec)
855 (and (string-prefix? "tty" spec)
857 (string-prefix? "tty0" spec)
858 (string-prefix? "tty1" spec)
859 (string-prefix? "tty2" spec)
860 (string-prefix? "tty3" spec)
861 (string-prefix? "tty4" spec)
862 (string-prefix? "tty5" spec)
863 (string-prefix? "tty6" spec)
864 (string-prefix? "tty7" spec)
865 (string-prefix? "tty8" spec)
866 (string-prefix? "tty9" spec)))))
867 (find-long-options "console" command)))
868 (specs (append agetty-specs console-specs)))
872 ;; Extract device name from first spec.
873 (match (string-tokenize spec not-comma)
877 (define agetty-shepherd-service
879 (($ <agetty-configuration> agetty tty term baud-rate auto-login
880 login-program login-pause? eight-bits? no-reset? remote? flow-control?
881 host no-issue? init-string no-clear? local-line extract-baud?
882 skip-login? no-newline? login-options chroot hangup? keep-baud? timeout
883 detect-case? wait-cr? no-hints? no-hostname? long-hostname?
884 erase-characters kill-characters chdir delay nice extra-options)
887 (documentation "Run agetty on a tty.")
888 (provision (list (symbol-append 'term- (string->symbol (or tty "auto")))))
890 ;; Since the login prompt shows the host name, wait for the 'host-name'
891 ;; service to be done. Also wait for udev essentially so that the tty
892 ;; text is not lost in the middle of kernel messages (see also
893 ;; mingetty-shepherd-service).
894 (requirement '(user-processes host-name udev))
896 (modules '((ice-9 match) (gnu build linux-boot)))
898 (with-imported-modules (source-module-closure
899 '((gnu build linux-boot)))
901 (let ((defaulted-tty #$(or tty (default-serial-port))))
904 (make-forkexec-constructor
905 (list #$(file-append util-linux "/sbin/agetty")
926 #~("--init-string" #$init-string)
931 ;;; FIXME This doesn't work as expected. According to agetty(8), if this option
932 ;;; is not passed, then the default is 'auto'. However, in my tests, when that
933 ;;; option is selected, agetty never presents the login prompt, and the
934 ;;; term-ttyS0 service respawns every few seconds.
936 #~(#$(match local-line
937 ('auto "--local-line=auto")
938 ('always "--local-line=always")
939 ('never "-local-line=never")))
954 #~("--login-options" #$login-options)
957 #~("--chroot" #$chroot)
966 #~("--timeout" #$(number->string timeout))
980 #$@(if long-hostname?
981 #~("--long-hostname")
983 #$@(if erase-characters
984 #~("--erase-chars" #$erase-characters)
986 #$@(if kill-characters
987 #~("--kill-chars" #$kill-characters)
990 #~("--chdir" #$chdir)
993 #~("--delay" #$(number->string delay))
996 #~("--nice" #$(number->string nice))
999 (list "--autologin" auto-login)
1001 #$@(if login-program
1002 #~("--login-program" #$login-program)
1014 (const #f)) ; never start.
1016 (stop #~(make-kill-destructor)))))))
1018 (define agetty-service-type
1019 (service-type (name 'agetty)
1020 (extensions (list (service-extension shepherd-root-service-type
1021 agetty-shepherd-service)))
1023 "Provide console login using the @command{agetty}
1026 (define* (agetty-service config)
1027 "Return a service to run agetty according to @var{config}, which specifies
1028 the tty to run, among other things."
1029 (service agetty-service-type config))
1031 (define-record-type* <mingetty-configuration>
1032 mingetty-configuration make-mingetty-configuration
1033 mingetty-configuration?
1034 (mingetty mingetty-configuration-mingetty ;<package>
1036 (tty mingetty-configuration-tty) ;string
1037 (auto-login mingetty-auto-login ;string | #f
1039 (login-program mingetty-login-program ;gexp
1041 (login-pause? mingetty-login-pause? ;Boolean
1043 (clear-on-logout? mingetty-clear-on-logout? ;Boolean
1046 (define mingetty-shepherd-service
1048 (($ <mingetty-configuration> mingetty tty auto-login login-program
1049 login-pause? clear-on-logout?)
1052 (documentation "Run mingetty on an tty.")
1053 (provision (list (symbol-append 'term- (string->symbol tty))))
1055 ;; Since the login prompt shows the host name, wait for the 'host-name'
1056 ;; service to be done. Also wait for udev essentially so that the tty
1057 ;; text is not lost in the middle of kernel messages (XXX).
1058 (requirement '(user-processes host-name udev virtual-terminal))
1060 (start #~(make-forkexec-constructor
1061 (list #$(file-append mingetty "/sbin/mingetty")
1063 ;; Avoiding 'vhangup' allows us to avoid 'setfont'
1064 ;; errors down the path where various ioctls get
1065 ;; EIO--see 'hung_up_tty_ioctl' in driver/tty/tty_io.c
1069 #$@(if clear-on-logout?
1073 #~("--autologin" #$auto-login)
1075 #$@(if login-program
1076 #~("--loginprog" #$login-program)
1081 (stop #~(make-kill-destructor)))))))
1083 (define mingetty-service-type
1084 (service-type (name 'mingetty)
1085 (extensions (list (service-extension shepherd-root-service-type
1086 mingetty-shepherd-service)))
1088 "Provide console login using the @command{mingetty}
1091 (define* (mingetty-service config)
1092 "Return a service to run mingetty according to @var{config}, which specifies
1093 the tty to run, among other things."
1094 (service mingetty-service-type config))
1096 (define-record-type* <nscd-configuration> nscd-configuration
1097 make-nscd-configuration
1099 (log-file nscd-configuration-log-file ;string
1100 (default "/var/log/nscd.log"))
1101 (debug-level nscd-debug-level ;integer
1103 ;; TODO: See nscd.conf in glibc for other options to add.
1104 (caches nscd-configuration-caches ;list of <nscd-cache>
1105 (default %nscd-default-caches))
1106 (name-services nscd-configuration-name-services ;list of <packages>
1108 (glibc nscd-configuration-glibc ;<package>
1111 (define-record-type* <nscd-cache> nscd-cache make-nscd-cache
1113 (database nscd-cache-database) ;symbol
1114 (positive-time-to-live nscd-cache-positive-time-to-live) ;integer
1115 (negative-time-to-live nscd-cache-negative-time-to-live
1116 (default 20)) ;integer
1117 (suggested-size nscd-cache-suggested-size ;integer ("default module
1120 (check-files? nscd-cache-check-files? ;Boolean
1122 (persistent? nscd-cache-persistent? ;Boolean
1124 (shared? nscd-cache-shared? ;Boolean
1126 (max-database-size nscd-cache-max-database-size ;integer
1127 (default (* 32 (expt 2 20))))
1128 (auto-propagate? nscd-cache-auto-propagate? ;Boolean
1131 (define %nscd-default-caches
1132 ;; Caches that we want to enable by default. Note that when providing an
1133 ;; empty nscd.conf, all caches are disabled.
1134 (list (nscd-cache (database 'hosts)
1136 ;; Aggressively cache the host name cache to improve
1137 ;; privacy and resilience.
1138 (positive-time-to-live (* 3600 12))
1139 (negative-time-to-live 20)
1142 (nscd-cache (database 'services)
1144 ;; Services are unlikely to change, so we can be even more
1146 (positive-time-to-live (* 3600 24))
1147 (negative-time-to-live 3600)
1148 (check-files? #t) ;check /etc/services changes
1151 (define %nscd-default-configuration
1152 ;; Default nscd configuration.
1153 (nscd-configuration))
1155 (define (nscd.conf-file config)
1156 "Return the @file{nscd.conf} configuration file for @var{config}, an
1157 @code{<nscd-configuration>} object."
1158 (define cache->config
1160 (($ <nscd-cache> (= symbol->string database)
1161 positive-ttl negative-ttl size check-files?
1162 persistent? shared? max-size propagate?)
1163 (string-append "\nenable-cache\t" database "\tyes\n"
1165 "positive-time-to-live\t" database "\t"
1166 (number->string positive-ttl) "\n"
1167 "negative-time-to-live\t" database "\t"
1168 (number->string negative-ttl) "\n"
1169 "suggested-size\t" database "\t"
1170 (number->string size) "\n"
1171 "check-files\t" database "\t"
1172 (if check-files? "yes\n" "no\n")
1173 "persistent\t" database "\t"
1174 (if persistent? "yes\n" "no\n")
1175 "shared\t" database "\t"
1176 (if shared? "yes\n" "no\n")
1177 "max-db-size\t" database "\t"
1178 (number->string max-size) "\n"
1179 "auto-propagate\t" database "\t"
1180 (if propagate? "yes\n" "no\n")))))
1183 (($ <nscd-configuration> log-file debug-level caches)
1184 (plain-file "nscd.conf"
1186 # Configuration of libc's name service cache daemon (nscd).\n\n"
1188 (string-append "logfile\t" log-file)
1192 (string-append "debug-level\t"
1193 (number->string debug-level))
1197 (map cache->config caches)))))))
1199 (define (nscd-action-procedure nscd config option)
1200 ;; XXX: This is duplicated from mcron; factorize.
1201 #~(lambda (_ . args)
1202 ;; Run 'nscd' in a pipe so we can explicitly redirect its output to
1203 ;; 'current-output-port', which at this stage is bound to the client
1205 (let ((pipe (apply open-pipe* OPEN_READ #$nscd
1206 "-f" #$config #$option args)))
1208 (match (read-line pipe 'concat)
1210 (catch 'system-error
1212 (zero? (close-pipe pipe)))
1214 ;; There's a race with the SIGCHLD handler, which could
1215 ;; call 'waitpid' before 'close-pipe' above does. If we
1216 ;; get ECHILD, that means we lost the race; in that case, we
1217 ;; cannot tell what the exit code was (FIXME).
1218 (or (= ECHILD (system-error-errno args))
1219 (apply throw args)))))
1224 (define (nscd-actions nscd config)
1225 "Return Shepherd actions for NSCD."
1226 ;; Make this functionality available as actions because that's a simple way
1227 ;; to run the right 'nscd' binary with the right config file.
1228 (list (shepherd-action
1230 (documentation "Display statistics about nscd usage.")
1231 (procedure (nscd-action-procedure nscd config "--statistics")))
1235 "Invalidate the given cache--e.g., 'hosts' for host name lookups.")
1236 (procedure (nscd-action-procedure nscd config "--invalidate")))))
1238 (define (nscd-shepherd-service config)
1239 "Return a shepherd service for CONFIG, an <nscd-configuration> object."
1240 (let ((nscd (file-append (nscd-configuration-glibc config)
1242 (nscd.conf (nscd.conf-file config))
1243 (name-services (nscd-configuration-name-services config)))
1244 (list (shepherd-service
1245 (documentation "Run libc's name service cache daemon (nscd).")
1247 (requirement '(user-processes))
1248 (start #~(make-forkexec-constructor
1249 (list #$nscd "-f" #$nscd.conf "--foreground")
1251 ;; Wait for the PID file. However, the PID file is
1252 ;; written before nscd is actually listening on its
1254 #:pid-file "/var/run/nscd/nscd.pid"
1256 #:environment-variables
1257 (list (string-append "LD_LIBRARY_PATH="
1260 (string-append dir "/lib"))
1261 (list #$@name-services))
1263 (stop #~(make-kill-destructor))
1264 (modules `((ice-9 popen) ;for the actions
1267 ,@%default-modules))
1268 (actions (nscd-actions nscd nscd.conf))))))
1270 (define nscd-activation
1271 ;; Actions to take before starting nscd.
1273 (use-modules (guix build utils))
1274 (mkdir-p "/var/run/nscd")
1275 (mkdir-p "/var/db/nscd") ;for the persistent cache
1277 ;; In libc 2.25 nscd uses inotify to watch /etc/resolv.conf, but only if
1278 ;; that file exists when it is started. Thus create it here. Note: on
1279 ;; some systems, such as when NetworkManager is used, /etc/resolv.conf
1280 ;; is a symlink, hence 'lstat'.
1281 (unless (false-if-exception (lstat "/etc/resolv.conf"))
1282 (call-with-output-file "/etc/resolv.conf"
1284 (display "# This is a placeholder.\n" port))))))
1286 (define nscd-service-type
1287 (service-type (name 'nscd)
1289 (list (service-extension activation-service-type
1290 (const nscd-activation))
1291 (service-extension shepherd-root-service-type
1292 nscd-shepherd-service)))
1294 ;; This can be extended by providing additional name services
1295 ;; such as nss-mdns.
1296 (compose concatenate)
1297 (extend (lambda (config name-services)
1300 (name-services (append
1301 (nscd-configuration-name-services config)
1303 (default-value %nscd-default-configuration)
1305 "Runs libc's @dfn{name service cache daemon} (nscd) with the
1306 given configuration---an @code{<nscd-configuration>} object. @xref{Name
1307 Service Switch}, for an example.")))
1309 (define* (nscd-service #:optional (config %nscd-default-configuration))
1310 "Return a service that runs libc's name service cache daemon (nscd) with the
1311 given @var{config}---an @code{<nscd-configuration>} object. @xref{Name
1312 Service Switch}, for an example."
1313 (service nscd-service-type config))
1316 (define-record-type* <syslog-configuration>
1317 syslog-configuration make-syslog-configuration
1318 syslog-configuration?
1319 (syslogd syslog-configuration-syslogd
1320 (default (file-append inetutils "/libexec/syslogd")))
1321 (config-file syslog-configuration-config-file
1322 (default %default-syslog.conf)))
1324 (define syslog-service-type
1325 (shepherd-service-type
1329 (documentation "Run the syslog daemon (syslogd).")
1330 (provision '(syslogd))
1331 (requirement '(user-processes))
1332 (start #~(let ((spawn (make-forkexec-constructor
1333 (list #$(syslog-configuration-syslogd config)
1335 #$(syslog-configuration-config-file config))
1336 #:pid-file "/var/run/syslog.pid")))
1338 ;; Set the umask such that file permissions are #o640.
1339 (let ((mask (umask #o137))
1343 (stop #~(make-kill-destructor))))
1344 (description "Run the syslog daemon, @command{syslogd}, which is
1345 responsible for logging system messages.")))
1347 ;; Snippet adapted from the GNU inetutils manual.
1348 (define %default-syslog.conf
1349 (plain-file "syslog.conf" "
1350 # Log all error messages, authentication messages of
1351 # level notice or higher and anything of level err or
1352 # higher to the console.
1353 # Don't log private authentication messages!
1354 *.alert;auth.notice;authpriv.none /dev/console
1356 # Log anything (except mail) of level info or higher.
1357 # Don't log private authentication messages!
1358 *.info;mail.none;authpriv.none /var/log/messages
1360 # Like /var/log/messages, but also including \"debug\"-level logs.
1361 *.debug;mail.none;authpriv.none /var/log/debug
1363 # Same, in a different place.
1364 *.info;mail.none;authpriv.none /dev/tty12
1366 # The authpriv file has restricted access.
1367 authpriv.* /var/log/secure
1369 # Log all the mail messages in one place.
1370 mail.* /var/log/maillog
1373 (define* (syslog-service #:optional (config (syslog-configuration)))
1374 "Return a service that runs @command{syslogd} and takes
1375 @var{<syslog-configuration>} as a parameter.
1377 @xref{syslogd invocation,,, inetutils, GNU Inetutils}, for more
1378 information on the configuration file syntax."
1379 (service syslog-service-type config))
1382 (define pam-limits-service-type
1383 (let ((security-limits
1384 ;; Create /etc/security containing the provided "limits.conf" file.
1385 (lambda (limits-file)
1391 (stat #$limits-file)
1392 (symlink #$limits-file
1393 (string-append #$output "/limits.conf"))))))))
1396 (let ((pam-limits (pam-entry
1397 (control "required")
1398 (module "pam_limits.so")
1399 (arguments '("conf=/etc/security/limits.conf")))))
1400 (if (member (pam-service-name pam)
1401 '("login" "su" "slim" "gdm-password" "sddm"))
1404 (session (cons pam-limits
1405 (pam-service-session pam))))
1410 (list (service-extension etc-service-type security-limits)
1411 (service-extension pam-root-service-type
1412 (lambda _ (list pam-extension)))))
1414 "Install the specified resource usage limits by populating
1415 @file{/etc/security/limits.conf} and using the @code{pam_limits}
1416 authentication module."))))
1418 (define* (pam-limits-service #:optional (limits '()))
1419 "Return a service that makes selected programs respect the list of
1420 pam-limits-entry specified in LIMITS via pam_limits.so."
1421 (service pam-limits-service-type
1422 (plain-file "limits.conf"
1423 (string-join (map pam-limits-entry->string limits)
1431 (define* (guix-build-accounts count #:key
1434 "Return a list of COUNT user accounts for Guix build users with the given
1436 (unfold (cut > <> count)
1439 (name (format #f "guixbuilder~2,'0d" n))
1443 ;; guix-daemon expects GROUP to be listed as a
1444 ;; supplementary group too:
1445 ;; <http://lists.gnu.org/archive/html/bug-guix/2013-01/msg00239.html>.
1446 (supplementary-groups (list group "kvm"))
1448 (comment (format #f "Guix Build User ~2d" n))
1449 (home-directory "/var/empty")
1450 (shell (file-append shadow "/sbin/nologin"))))
1455 ;; Select (guix …) and (gnu …) modules, except (guix config).
1457 (('guix 'config) #f)
1458 (('guix rest ...) #t)
1459 (('gnu rest ...) #t)
1462 (define (substitute-key-authorization keys guix)
1463 "Return a gexp with code to register KEYS, a list of files containing 'guix
1464 archive' public keys, with GUIX."
1466 (with-extensions (list guile-gcrypt)
1467 (with-imported-modules `(((guix config) => ,(make-config.scm))
1468 ,@(source-module-closure '((guix pki))
1469 #:select? not-config?))
1470 (computed-file "acl"
1472 (use-modules (guix pki)
1478 (call-with-input-file file
1479 (compose string->canonical-sexp
1483 (call-with-output-file #$output
1485 (write-acl (public-keys->acl keys)
1488 (with-imported-modules '((guix build utils))
1490 (use-modules (guix build utils))
1492 ;; If the ACL already exists, move it out of the way. Create a backup
1493 ;; if it's a regular file: it's likely that the user manually updated
1494 ;; it with 'guix archive --authorize'.
1495 (if (file-exists? "/etc/guix/acl")
1496 (if (and (symbolic-link? "/etc/guix/acl")
1497 (store-file-name? (readlink "/etc/guix/acl")))
1498 (delete-file "/etc/guix/acl")
1499 (rename-file "/etc/guix/acl" "/etc/guix/acl.bak"))
1500 (mkdir-p "/etc/guix"))
1502 ;; Installed the declared ACL.
1503 (symlink #+default-acl "/etc/guix/acl"))))
1505 (define %default-authorized-guix-keys
1506 ;; List of authorized substitute keys.
1507 (list (file-append guix "/share/guix/berlin.guix.gnu.org.pub")
1508 (file-append guix "/share/guix/bordeaux.guix.gnu.org.pub")))
1510 (define-record-type* <guix-configuration>
1511 guix-configuration make-guix-configuration
1513 (guix guix-configuration-guix ;<package>
1515 (build-group guix-configuration-build-group ;string
1516 (default "guixbuild"))
1517 (build-accounts guix-configuration-build-accounts ;integer
1519 (authorize-key? guix-configuration-authorize-key? ;Boolean
1521 (authorized-keys guix-configuration-authorized-keys ;list of gexps
1522 (default %default-authorized-guix-keys))
1523 (use-substitutes? guix-configuration-use-substitutes? ;Boolean
1525 (substitute-urls guix-configuration-substitute-urls ;list of strings
1526 (default %default-substitute-urls))
1527 (chroot-directories guix-configuration-chroot-directories ;list of file-like/strings
1529 (max-silent-time guix-configuration-max-silent-time ;integer
1531 (timeout guix-configuration-timeout ;integer
1533 (log-compression guix-configuration-log-compression
1535 (discover? guix-configuration-discover?
1537 (extra-options guix-configuration-extra-options ;list of strings
1539 (log-file guix-configuration-log-file ;string
1540 (default "/var/log/guix-daemon.log"))
1541 (http-proxy guix-http-proxy ;string | #f
1543 (tmpdir guix-tmpdir ;string | #f
1546 (define %default-guix-configuration
1547 (guix-configuration))
1549 (define shepherd-set-http-proxy-action
1550 ;; Shepherd action to change the HTTP(S) proxy.
1552 (name 'set-http-proxy)
1554 "Change the HTTP(S) proxy used by 'guix-daemon' and restart it.")
1555 (procedure #~(lambda* (_ #:optional proxy)
1556 (let ((environment (environ)))
1557 ;; A bit of a hack: communicate PROXY to the 'start'
1558 ;; method via environment variables.
1561 (format #t "changing HTTP/HTTPS \
1562 proxy of 'guix-daemon' to ~s...~%"
1564 (setenv "http_proxy" proxy))
1566 (format #t "clearing HTTP/HTTPS \
1567 proxy of 'guix-daemon'...~%")
1568 (unsetenv "http_proxy")))
1569 (action 'guix-daemon 'restart)
1570 (environ environment)
1573 (define shepherd-discover-action
1574 ;; Shepherd action to enable or disable substitute servers discovery.
1578 "Enable or disable substitute servers discovery and restart the
1580 (procedure #~(lambda* (_ status)
1581 (let ((environment (environ)))
1583 (string=? status "on"))
1585 (format #t "enable substitute servers discovery~%")
1586 (setenv "discover" "on"))
1588 (format #t "disable substitute servers discovery~%")
1589 (unsetenv "discover")))
1590 (action 'guix-daemon 'restart)
1591 (environ environment)
1594 (define (guix-shepherd-service config)
1595 "Return a <shepherd-service> for the Guix daemon service with CONFIG."
1596 (match-record config <guix-configuration>
1597 (guix build-group build-accounts authorize-key? authorized-keys
1598 use-substitutes? substitute-urls max-silent-time timeout
1599 log-compression discover? extra-options log-file
1600 http-proxy tmpdir chroot-directories)
1601 (list (shepherd-service
1602 (documentation "Run the Guix daemon.")
1603 (provision '(guix-daemon))
1604 (requirement '(user-processes))
1605 (actions (list shepherd-set-http-proxy-action
1606 shepherd-discover-action))
1607 (modules '((srfi srfi-1)
1609 (gnu build shepherd)))
1611 (with-imported-modules `(((guix config) => ,(make-config.scm))
1612 ,@(source-module-closure
1613 '((gnu build shepherd))
1614 #:select? not-config?))
1617 ;; HTTP/HTTPS proxy. The 'http_proxy' variable is set by
1618 ;; the 'set-http-proxy' action.
1619 (or (getenv "http_proxy") #$http-proxy))
1622 (or (getenv "discover") #$discover?))
1624 ;; Start the guix-daemon from a container, when supported,
1625 ;; to solve an installation issue. See the comment below for
1627 (fork+exec-command/container
1628 (cons* #$(file-append guix "/bin/guix-daemon")
1629 "--build-users-group" #$build-group
1631 #$(number->string max-silent-time)
1632 "--timeout" #$(number->string timeout)
1634 #$(symbol->string log-compression)
1635 #$@(if use-substitutes?
1637 '("--no-substitutes"))
1638 (string-append "--discover="
1639 (if discover? "yes" "no"))
1640 "--substitute-urls" #$(string-join substitute-urls)
1643 ;; Add CHROOT-DIRECTORIES and all their dependencies
1644 ;; (if these are store items) to the chroot.
1647 (append-map (lambda (directory)
1648 (list "--chroot-directory"
1650 (call-with-input-file file
1652 '#$(map references-file
1653 chroot-directories)))
1655 ;; When running the installer, we need guix-daemon to
1656 ;; operate from within the same MNT namespace as the
1657 ;; installation container. In that case only, enter the
1658 ;; namespace of the process PID passed as start argument.
1659 ;; Otherwise, for symmetry purposes enter the caller
1660 ;; namespaces which is a no-op.
1662 ((pid) (string->number pid))
1665 #:environment-variables
1666 (append (list #$@(if tmpdir
1667 (list (string-append "TMPDIR=" tmpdir))
1670 ;; Make sure we run in a UTF-8 locale so that
1671 ;; 'guix offload' correctly restores nars
1672 ;; that contain UTF-8 file names such as
1674 ;; <https://bugs.gnu.org/32942>.
1675 (string-append "GUIX_LOCPATH="
1676 #$glibc-utf8-locales
1678 "LC_ALL=en_US.utf8")
1680 (list (string-append "http_proxy=" proxy)
1681 (string-append "https_proxy=" proxy))
1684 #:log-file #$log-file))))
1685 (stop #~(make-kill-destructor))))))
1687 (define (guix-accounts config)
1688 "Return the user accounts and user groups for CONFIG."
1690 (($ <guix-configuration> _ build-group build-accounts)
1695 ;; Use a fixed GID so that we can create the store with the right
1698 (guix-build-accounts build-accounts
1699 #:group build-group)))))
1701 (define (guix-activation config)
1702 "Return the activation gexp for CONFIG."
1703 (match-record config <guix-configuration>
1704 (guix authorize-key? authorized-keys)
1706 ;; Assume that the store has BUILD-GROUP as its group. We could
1707 ;; otherwise call 'chown' here, but the problem is that on a COW overlayfs,
1708 ;; chown leads to an entire copy of the tree, which is a bad idea.
1710 ;; Generate a key pair and optionally authorize substitute server keys.
1711 (unless (file-exists? "/etc/guix/signing-key.pub")
1712 (system* #$(file-append guix "/bin/guix") "archive"
1715 #$(if authorize-key?
1716 (substitute-key-authorization authorized-keys guix)
1719 (define* (references-file item #:optional (name "references"))
1720 "Return a file that contains the list of references of ITEM."
1721 (if (struct? item) ;lowerable object
1723 (with-extensions (list guile-gcrypt) ;for store-copy
1724 (with-imported-modules (source-module-closure
1725 '((guix build store-copy)))
1727 (use-modules (guix build store-copy))
1729 (call-with-output-file #$output
1731 (write (map store-info-item
1732 (call-with-input-file "graph"
1733 read-reference-graph))
1735 #:options `(#:local-build? #f
1736 #:references-graphs (("graph" ,item))))
1737 (plain-file name "()")))
1739 (define guix-service-type
1743 (list (service-extension shepherd-root-service-type guix-shepherd-service)
1744 (service-extension account-service-type guix-accounts)
1745 (service-extension activation-service-type guix-activation)
1746 (service-extension profile-service-type
1747 (compose list guix-configuration-guix))))
1749 ;; Extensions can specify extra directories to add to the build chroot.
1750 (compose concatenate)
1751 (extend (lambda (config directories)
1755 (append (guix-configuration-chroot-directories config)
1758 (default-value (guix-configuration))
1760 "Run the build daemon of GNU@tie{}Guix, aka. @command{guix-daemon}.")))
1763 (define-record-type* <guix-publish-configuration>
1764 guix-publish-configuration make-guix-publish-configuration
1765 guix-publish-configuration?
1766 (guix guix-publish-configuration-guix ;package
1768 (port guix-publish-configuration-port ;number
1770 (host guix-publish-configuration-host ;string
1771 (default "localhost"))
1772 (advertise? guix-publish-advertise? ;boolean
1774 (compression guix-publish-configuration-compression
1776 (default (default-compression this-record
1777 (current-source-location))))
1778 (compression-level %guix-publish-configuration-compression-level ;deprecated
1780 (nar-path guix-publish-configuration-nar-path ;string
1782 (cache guix-publish-configuration-cache ;#f | string
1784 (cache-bypass-threshold guix-publish-configuration-cache-bypass-threshold
1785 (default (* 10 (expt 2 20)))) ;integer
1786 (workers guix-publish-configuration-workers ;#f | integer
1788 (ttl guix-publish-configuration-ttl ;#f | integer
1791 (define-deprecated (guix-publish-configuration-compression-level config)
1792 "Return a compression level, the old way."
1793 (match (guix-publish-configuration-compression config)
1794 (((_ level) _ ...) level)))
1796 (define (default-compression config properties)
1797 "Return the default 'guix publish' compression according to CONFIG, and
1798 raise a deprecation warning if the 'compression-level' field was used."
1799 (match (%guix-publish-configuration-compression-level config)
1801 ;; Default to low compression levels when there's no cache so that users
1802 ;; get good bandwidth by default.
1803 (if (guix-publish-configuration-cache config)
1804 '(("gzip" 5) ("zstd" 19))
1805 '(("gzip" 3) ("zstd" 3)))) ;zstd compresses faster
1807 (warn-about-deprecation 'compression-level properties
1808 #:replacement 'compression)
1809 `(("gzip" ,level)))))
1811 (define (guix-publish-shepherd-service config)
1812 (define (config->compression-options config)
1813 (match (guix-publish-configuration-compression config)
1814 (() ;empty list means "no compression"
1817 (append-map (match-lambda
1819 `("-C" ,(string-append type ":"
1820 (number->string level)))))
1823 (match-record config <guix-publish-configuration>
1824 (guix port host nar-path cache workers ttl cache-bypass-threshold
1826 (list (shepherd-service
1827 (provision '(guix-publish))
1828 (requirement `(user-processes
1830 ,@(if advertise? '(avahi-daemon) '())))
1831 (start #~(make-forkexec-constructor
1832 (list #$(file-append guix "/bin/guix")
1833 "publish" "-u" "guix-publish"
1834 "-p" #$(number->string port)
1835 #$@(config->compression-options config)
1836 (string-append "--nar-path=" #$nar-path)
1837 (string-append "--listen=" #$host)
1842 #~((string-append "--workers="
1847 #~((string-append "--ttl="
1848 #$(number->string ttl)
1852 #~((string-append "--cache=" #$cache)
1854 "--cache-bypass-threshold="
1856 cache-bypass-threshold)))
1859 ;; Make sure we run in a UTF-8 locale so we can produce
1860 ;; nars for packages that contain UTF-8 file names such
1861 ;; as 'nss-certs'. See <https://bugs.gnu.org/26948>.
1862 #:environment-variables
1863 (list (string-append "GUIX_LOCPATH="
1864 #$glibc-utf8-locales "/lib/locale")
1865 "LC_ALL=en_US.utf8")
1866 #:log-file "/var/log/guix-publish.log"))
1867 (stop #~(make-kill-destructor))))))
1869 (define %guix-publish-accounts
1870 (list (user-group (name "guix-publish") (system? #t))
1872 (name "guix-publish")
1873 (group "guix-publish")
1875 (comment "guix publish user")
1876 (home-directory "/var/empty")
1877 (shell (file-append shadow "/sbin/nologin")))))
1879 (define %guix-publish-log-rotations
1881 (files (list "/var/log/guix-publish.log")))))
1883 (define (guix-publish-activation config)
1884 (let ((cache (guix-publish-configuration-cache config)))
1886 (with-imported-modules '((guix build utils))
1888 (use-modules (guix build utils))
1891 (let* ((pw (getpw "guix-publish"))
1892 (uid (passwd:uid pw))
1893 (gid (passwd:gid pw)))
1894 (chown #$cache uid gid))))
1897 (define guix-publish-service-type
1898 (service-type (name 'guix-publish)
1900 (list (service-extension shepherd-root-service-type
1901 guix-publish-shepherd-service)
1902 (service-extension account-service-type
1903 (const %guix-publish-accounts))
1904 (service-extension rottlog-service-type
1905 (const %guix-publish-log-rotations))
1906 (service-extension activation-service-type
1907 guix-publish-activation)))
1908 (default-value (guix-publish-configuration))
1910 "Add a Shepherd service running @command{guix publish}, a
1911 command that allows you to share pre-built binaries with others over HTTP.")))
1918 (define-record-type* <udev-configuration>
1919 udev-configuration make-udev-configuration
1921 (udev udev-configuration-udev ;<package>
1923 (rules udev-configuration-rules ;list of <package>
1926 (define (udev-rules-union packages)
1927 "Return the union of the @code{lib/udev/rules.d} directories found in each
1928 item of @var{packages}."
1930 (with-imported-modules '((guix build union)
1933 (use-modules (guix build union)
1938 (define %standard-locations
1939 '("/lib/udev/rules.d" "/libexec/udev/rules.d"))
1941 (define (rules-sub-directory directory)
1942 ;; Return the sub-directory of DIRECTORY containing udev rules, or
1943 ;; #f if none was found.
1944 (find directory-exists?
1945 (map (cut string-append directory <>) %standard-locations)))
1947 (mkdir-p (string-append #$output "/lib/udev"))
1948 (union-build (string-append #$output "/lib/udev/rules.d")
1949 (filter-map rules-sub-directory '#$packages)))))
1951 (computed-file "udev-rules" build))
1953 (define (udev-rule file-name contents)
1954 "Return a directory with a udev rule file FILE-NAME containing CONTENTS."
1955 (computed-file file-name
1956 (with-imported-modules '((guix build utils))
1958 (use-modules (guix build utils))
1961 (string-append #$output "/lib/udev/rules.d"))
1964 (call-with-output-file
1965 (string-append rules.d "/" #$file-name)
1967 (display #$contents port)))))))
1969 (define (file->udev-rule file-name file)
1970 "Return a directory with a udev rule file FILE-NAME which is a copy of FILE."
1971 (computed-file file-name
1972 (with-imported-modules '((guix build utils))
1974 (use-modules (guix build utils))
1977 (string-append #$output "/lib/udev/rules.d"))
1979 (define file-copy-dest
1980 (string-append rules.d "/" #$file-name))
1983 (copy-file #$file file-copy-dest)))))
1985 (define kvm-udev-rule
1986 ;; Return a directory with a udev rule that changes the group of /dev/kvm to
1987 ;; "kvm" and makes it #o660. Apparently QEMU-KVM used to ship this rule,
1988 ;; but now we have to add it by ourselves.
1990 ;; Build users are part of the "kvm" group, so we can fearlessly make
1991 ;; /dev/kvm 660 (see <http://bugs.gnu.org/18994>, for background.)
1992 (udev-rule "90-kvm.rules"
1993 "KERNEL==\"kvm\", GROUP=\"kvm\", MODE=\"0660\"\n"))
1995 (define udev-shepherd-service
1996 ;; Return a <shepherd-service> for UDEV with RULES.
1998 (($ <udev-configuration> udev rules)
1999 (let* ((rules (udev-rules-union (cons* udev kvm-udev-rule rules)))
2000 (udev.conf (computed-file "udev.conf"
2001 #~(call-with-output-file #$output
2004 "udev_rules=\"~a/lib/udev/rules.d\"\n"
2010 ;; Udev needs /dev to be a 'devtmpfs' mount so that new device nodes can
2012 ;; <http://www.linuxfromscratch.org/lfs/view/development/chapter07/udev.html>.
2013 (requirement '(root-file-system))
2015 (documentation "Populate the /dev directory, dynamically.")
2017 (with-imported-modules (source-module-closure
2018 '((gnu build linux-boot)))
2021 ;; 'udevd' from eudev.
2022 #$(file-append udev "/sbin/udevd"))
2024 (define (wait-for-udevd)
2025 ;; Wait until someone's listening on udevd's control
2027 (let ((sock (socket AF_UNIX SOCK_SEQPACKET 0)))
2029 (catch 'system-error
2031 (connect sock PF_UNIX "/run/udev/control")
2034 (format #t "waiting for udevd...~%")
2038 ;; Allow udev to find the modules.
2039 (setenv "LINUX_MODULE_DIRECTORY"
2040 "/run/booted-system/kernel/lib/modules")
2042 (let* ((kernel-release
2043 (utsname:release (uname)))
2044 (linux-module-directory
2045 (getenv "LINUX_MODULE_DIRECTORY"))
2047 (string-append linux-module-directory "/"
2049 (old-umask (umask #o022)))
2050 ;; If we're in a container, DIRECTORY might not exist,
2051 ;; for instance because the host runs a different
2052 ;; kernel. In that case, skip it; we'll just miss a few
2053 ;; nodes like /dev/fuse.
2054 (when (file-exists? directory)
2055 (make-static-device-nodes directory))
2058 (let ((pid (fork+exec-command (list udevd)
2059 #:environment-variables
2061 ;; The first one is for udev, the second one for
2063 (string-append "UDEV_CONFIG_FILE=" #$udev.conf)
2064 (string-append "EUDEV_RULES_DIRECTORY="
2066 rules "/lib/udev/rules.d"))
2067 (string-append "LINUX_MODULE_DIRECTORY="
2068 (getenv "LINUX_MODULE_DIRECTORY"))
2069 (default-environment-variables)))))
2070 ;; Wait until udevd is up and running. This appears to
2071 ;; be needed so that the events triggered below are
2072 ;; actually handled.
2075 ;; Trigger device node creation.
2076 (system* #$(file-append udev "/bin/udevadm")
2077 "trigger" "--action=add")
2079 ;; Wait for things to settle down.
2080 (system* #$(file-append udev "/bin/udevadm")
2083 (stop #~(make-kill-destructor))
2085 ;; When halting the system, 'udev' is actually killed by
2086 ;; 'user-processes', i.e., before its own 'stop' method was called.
2087 ;; Thus, make sure it is not respawned.
2089 ;; We need additional modules.
2090 (modules `((gnu build linux-boot) ;'make-static-device-nodes'
2091 ,@%default-modules))
2093 (actions (list (shepherd-action
2095 (documentation "Display the directory containing
2096 the udev rules in use.")
2097 (procedure #~(lambda (_)
2099 (newline))))))))))))
2101 (define udev-service-type
2102 (service-type (name 'udev)
2104 (list (service-extension shepherd-root-service-type
2105 udev-shepherd-service)))
2107 (compose concatenate) ;concatenate the list of rules
2108 (extend (lambda (config rules)
2110 (($ <udev-configuration> udev initial-rules)
2113 (rules (append initial-rules rules)))))))
2114 (default-value (udev-configuration))
2116 "Run @command{udev}, which populates the @file{/dev}
2117 directory dynamically. Get extra rules from the packages listed in the
2118 @code{rules} field of its value, @code{udev-configuration} object.")))
2120 (define* (udev-service #:key (udev eudev) (rules '()))
2121 "Run @var{udev}, which populates the @file{/dev} directory dynamically. Get
2122 extra rules from the packages listed in @var{rules}."
2123 (service udev-service-type
2124 (udev-configuration (udev udev) (rules rules))))
2126 (define* (udev-rules-service name rules #:key (groups '()))
2127 "Return a service that extends udev-service-type with RULES and
2128 account-service-type with GROUPS as system groups. This works by creating a
2129 singleton service type NAME-udev-rules, of which the returned service is an
2131 (let* ((name (symbol-append name '-udev-rules))
2133 (const (map (lambda (group)
2134 (user-group (name group) (system? #t)))
2136 (udev-extension (const (list rules)))
2141 account-service-type account-extension)
2143 udev-service-type udev-extension))))))
2146 (define swap-service-type
2147 (shepherd-service-type
2151 (if (and (string? device)
2152 (string-prefix? "/dev/mapper/" device))
2153 (list (symbol-append 'device-mapping-
2154 (string->symbol (basename device))))
2157 (define (device-lookup device)
2158 ;; The generic 'find-partition' procedures could return a partition
2159 ;; that's not swap space, but that's unlikely.
2160 (cond ((uuid? device)
2161 #~(find-partition-by-uuid #$(uuid-bytevector device)))
2162 ((file-system-label? device)
2163 #~(find-partition-by-label
2164 #$(file-system-label->string device)))
2168 (define service-name
2169 (symbol-append 'swap-
2171 (cond ((uuid? device)
2172 (string-take (uuid->string device) 6))
2173 ((file-system-label? device)
2174 (file-system-label->string device))
2178 (with-imported-modules (source-module-closure '((gnu build file-systems)))
2180 (provision (list service-name))
2181 (requirement `(udev ,@requirement))
2182 (documentation "Enable the given swap device.")
2183 (modules `((gnu build file-systems)
2184 ,@%default-modules))
2186 (let ((device #$(device-lookup device)))
2189 (restart-on-EINTR (swapon device))
2192 (let ((device #$(device-lookup device)))
2194 (restart-on-EINTR (swapoff device)))
2197 (description "Turn on the virtual memory swap area.")))
2199 (define (swap-service device)
2200 "Return a service that uses @var{device} as a swap device."
2201 (service swap-service-type device))
2203 (define %default-gpm-options
2204 ;; Default options for GPM.
2205 '("-m" "/dev/input/mice" "-t" "ps2"))
2207 (define-record-type* <gpm-configuration>
2208 gpm-configuration make-gpm-configuration gpm-configuration?
2209 (gpm gpm-configuration-gpm ;package
2211 (options gpm-configuration-options ;list of strings
2212 (default %default-gpm-options)))
2214 (define gpm-shepherd-service
2216 (($ <gpm-configuration> gpm options)
2217 (list (shepherd-service
2218 (requirement '(udev))
2220 ;; 'gpm' runs in the background and sets a PID file.
2221 ;; Note that it requires running as "root".
2222 (start #~(make-forkexec-constructor
2223 (list #$(file-append gpm "/sbin/gpm")
2225 #:pid-file "/var/run/gpm.pid"
2226 #:pid-file-timeout 3))
2228 ;; Return #f if successfully stopped.
2229 (not (zero? (system* #$(file-append gpm "/sbin/gpm")
2232 (define gpm-service-type
2233 (service-type (name 'gpm)
2235 (list (service-extension shepherd-root-service-type
2236 gpm-shepherd-service)))
2237 (default-value (gpm-configuration))
2239 "Run GPM, the general-purpose mouse daemon, with the given
2240 command-line options. GPM allows users to use the mouse in the console,
2241 notably to select, copy, and paste text. The default options use the
2242 @code{ps2} protocol, which works for both USB and PS/2 mice.")))
2245 (define-record-type* <kmscon-configuration>
2246 kmscon-configuration make-kmscon-configuration
2247 kmscon-configuration?
2248 (kmscon kmscon-configuration-kmscon
2250 (virtual-terminal kmscon-configuration-virtual-terminal)
2251 (login-program kmscon-configuration-login-program
2252 (default (file-append shadow "/bin/login")))
2253 (login-arguments kmscon-configuration-login-arguments
2255 (auto-login kmscon-configuration-auto-login
2257 (hardware-acceleration? kmscon-configuration-hardware-acceleration?
2258 (default #f)) ; #t causes failure
2259 (font-engine kmscon-configuration-font-engine
2261 (font-size kmscon-configuration-font-size
2263 (keyboard-layout kmscon-configuration-keyboard-layout
2264 (default #f))) ; #f | <keyboard-layout>
2266 (define kmscon-service-type
2267 (shepherd-service-type
2270 (let ((kmscon (kmscon-configuration-kmscon config))
2271 (virtual-terminal (kmscon-configuration-virtual-terminal config))
2272 (login-program (kmscon-configuration-login-program config))
2273 (login-arguments (kmscon-configuration-login-arguments config))
2274 (auto-login (kmscon-configuration-auto-login config))
2275 (hardware-acceleration? (kmscon-configuration-hardware-acceleration? config))
2276 (font-engine (kmscon-configuration-font-engine config))
2277 (font-size (kmscon-configuration-font-size config))
2278 (keyboard-layout (kmscon-configuration-keyboard-layout config)))
2280 (define kmscon-command
2282 #$(file-append kmscon "/bin/kmscon") "--login"
2283 "--vt" #$virtual-terminal
2284 "--no-switchvt" ;Prevent a switch to the virtual terminal.
2285 "--font-engine" #$font-engine
2286 "--font-size" #$(number->string font-size)
2287 #$@(if keyboard-layout
2288 (let* ((layout (keyboard-layout-name keyboard-layout))
2289 (variant (keyboard-layout-variant keyboard-layout))
2290 (model (keyboard-layout-model keyboard-layout))
2291 (options (keyboard-layout-options keyboard-layout)))
2292 `("--xkb-layout" ,layout
2293 ,@(if variant `("--xkb-variant" ,variant) '())
2294 ,@(if model `("--xkb-model" ,model) '())
2295 ,@(if (null? options)
2297 `("--xkb-options" ,(string-join options ",")))))
2299 #$@(if hardware-acceleration? '("--hwaccel") '())
2301 #$login-program #$@login-arguments
2307 (documentation "kmscon virtual terminal")
2308 (requirement '(user-processes udev dbus-system))
2309 (provision (list (symbol-append 'term- (string->symbol virtual-terminal))))
2310 (start #~(make-forkexec-constructor #$kmscon-command))
2311 (stop #~(make-kill-destructor)))))
2312 (description "Start the @command{kmscon} virtual terminal emulator for the
2313 Linux @dfn{kernel mode setting} (KMS).")))
2315 (define-record-type* <static-networking>
2316 static-networking make-static-networking
2318 (interface static-networking-interface)
2319 (ip static-networking-ip)
2320 (netmask static-networking-netmask
2322 (gateway static-networking-gateway ;FIXME: doesn't belong here
2324 (provision static-networking-provision
2326 (requirement static-networking-requirement
2328 (name-servers static-networking-name-servers ;FIXME: doesn't belong here
2331 (define static-networking-shepherd-service
2333 (($ <static-networking> interface ip netmask gateway provision
2334 requirement name-servers)
2335 (let ((loopback? (and provision (memq 'loopback provision))))
2339 "Bring up the networking interface using a static IP address.")
2340 (requirement requirement)
2341 (provision (or provision
2342 (list (symbol-append 'networking-
2343 (string->symbol interface)))))
2346 ;; Return #t if successfully started.
2347 (let* ((addr (inet-pton AF_INET #$ip))
2348 (sockaddr (make-socket-address AF_INET addr 0))
2349 (mask (and #$netmask
2350 (inet-pton AF_INET #$netmask)))
2352 (make-socket-address AF_INET
2354 (gateway (and #$gateway
2355 (inet-pton AF_INET #$gateway)))
2356 (gatewayaddr (and gateway
2357 (make-socket-address AF_INET
2359 (configure-network-interface #$interface sockaddr
2366 (let ((sock (socket AF_INET SOCK_DGRAM 0)))
2367 (add-network-route/gateway sock gatewayaddr)
2368 (close-port sock))))))
2370 ;; Return #f is successfully stopped.
2371 (let ((sock (socket AF_INET SOCK_STREAM 0)))
2373 (delete-network-route sock
2374 (make-socket-address
2375 AF_INET INADDR_ANY 0)))
2376 (set-network-interface-flags sock #$interface 0)
2381 (define (static-networking-etc-files interfaces)
2382 "Return a /etc/resolv.conf entry for INTERFACES or the empty list."
2383 (match (delete-duplicates
2384 (append-map static-networking-name-servers
2389 (let ((content (string-join
2390 (map (cut string-append "nameserver " <>)
2394 ,(plain-file "resolv.conf"
2396 # Generated by 'static-networking-service'.\n"
2399 (define (static-networking-shepherd-services interfaces)
2400 "Return the list of Shepherd services to bring up INTERFACES, a list of
2401 <static-networking> objects."
2402 (define (loopback? service)
2403 (memq 'loopback (shepherd-service-provision service)))
2405 (let ((services (map static-networking-shepherd-service interfaces)))
2406 (match (remove loopback? services)
2408 ;; There's no interface other than 'loopback', so we assume that the
2409 ;; 'networking' service will be provided by dhclient or similar.
2412 ;; Assume we're providing all the interfaces, and thus, provide a
2413 ;; 'networking' service.
2414 (cons (shepherd-service
2415 (provision '(networking))
2416 (requirement (append-map shepherd-service-provision
2418 (start #~(const #t))
2420 (documentation "Bring up all the networking interfaces."))
2423 (define static-networking-service-type
2424 ;; The service type for statically-defined network interfaces.
2425 (service-type (name 'static-networking)
2428 (service-extension shepherd-root-service-type
2429 static-networking-shepherd-services)
2430 (service-extension etc-service-type
2431 static-networking-etc-files)))
2432 (compose concatenate)
2435 "Turn up the specified network interfaces upon startup,
2436 with the given IP address, gateway, netmask, and so on. The value for
2437 services of this type is a list of @code{static-networking} objects, one per
2438 network interface.")))
2440 (define* (static-networking-service interface ip
2442 netmask gateway provision
2443 ;; Most interfaces require udev to be usable.
2444 (requirement '(udev))
2446 "Return a service that starts @var{interface} with address @var{ip}. If
2447 @var{netmask} is true, use it as the network mask. If @var{gateway} is true,
2448 it must be a string specifying the default network gateway.
2450 This procedure can be called several times, one for each network
2451 interface of interest. Behind the scenes what it does is extend
2452 @code{static-networking-service-type} with additional network interfaces
2454 (simple-service 'static-network-interface
2455 static-networking-service-type
2456 (list (static-networking (interface interface) (ip ip)
2457 (netmask netmask) (gateway gateway)
2458 (provision provision)
2459 (requirement requirement)
2460 (name-servers name-servers)))))
2463 (define %base-services
2464 ;; Convenience variable holding the basic services.
2465 (list (service login-service-type)
2467 (service virtual-terminal-service-type)
2468 (service console-font-service-type
2470 (cons tty %default-console-font))
2471 '("tty1" "tty2" "tty3" "tty4" "tty5" "tty6")))
2473 (service agetty-service-type (agetty-configuration
2474 (extra-options '("-L")) ; no carrier detect
2476 (tty #f))) ; automatic
2478 (service mingetty-service-type (mingetty-configuration
2480 (service mingetty-service-type (mingetty-configuration
2482 (service mingetty-service-type (mingetty-configuration
2484 (service mingetty-service-type (mingetty-configuration
2486 (service mingetty-service-type (mingetty-configuration
2488 (service mingetty-service-type (mingetty-configuration
2491 (service static-networking-service-type
2492 (list (static-networking (interface "lo")
2495 (provision '(loopback)))))
2497 (service urandom-seed-service-type)
2498 (service guix-service-type)
2499 (service nscd-service-type)
2501 (service rottlog-service-type)
2503 ;; The LVM2 rules are needed as soon as LVM2 or the device-mapper is
2504 ;; used, so enable them by default. The FUSE and ALSA rules are
2505 ;; less critical, but handy.
2506 (service udev-service-type
2508 (rules (list lvm2 fuse alsa-utils crda))))
2510 (service sysctl-service-type)
2512 (service special-files-service-type
2513 `(("/bin/sh" ,(file-append bash "/bin/sh"))
2514 ("/usr/bin/env" ,(file-append coreutils "/bin/env"))))))
2516 ;;; base.scm ends here