summaryrefslogtreecommitdiff
path: root/gnu/system.scm
diff options
context:
space:
mode:
authorMark H Weaver <mhw@netris.org>2015-06-10 17:50:27 -0400
committerMark H Weaver <mhw@netris.org>2015-06-10 17:50:27 -0400
commit14928016556300a6763334d4279c3d117902caaf (patch)
treed0dc262b14164b82f97dd6e896ca9e93a1fabeea /gnu/system.scm
parent1511e0235525358abb52cf62abeb9457605b5093 (diff)
parent57cd353d87d6e9e6e882327be70b4d7b5ce863ba (diff)
Merge branch 'master' into core-updates
Diffstat (limited to 'gnu/system.scm')
-rw-r--r--gnu/system.scm101
1 files changed, 80 insertions, 21 deletions
diff --git a/gnu/system.scm b/gnu/system.scm
index 609604a9b52..92ed454b2c0 100644
--- a/gnu/system.scm
+++ b/gnu/system.scm
@@ -25,6 +25,7 @@
25 #:use-module (guix packages) 25 #:use-module (guix packages)
26 #:use-module (guix derivations) 26 #:use-module (guix derivations)
27 #:use-module (guix profiles) 27 #:use-module (guix profiles)
28 #:use-module (guix ui)
28 #:use-module (gnu packages base) 29 #:use-module (gnu packages base)
29 #:use-module (gnu packages bash) 30 #:use-module (gnu packages bash)
30 #:use-module (gnu packages guile) 31 #:use-module (gnu packages guile)
@@ -109,7 +110,7 @@
109 (default %base-firmware)) 110 (default %base-firmware))
110 111
111 (host-name operating-system-host-name) ; string 112 (host-name operating-system-host-name) ; string
112 (hosts-file operating-system-hosts-file ; M item | #f 113 (hosts-file operating-system-hosts-file ; file-like | #f
113 (default #f)) 114 (default #f))
114 115
115 (mapped-devices operating-system-mapped-devices ; list of <mapped-device> 116 (mapped-devices operating-system-mapped-devices ; list of <mapped-device>
@@ -119,7 +120,7 @@
119 (default '())) 120 (default '()))
120 121
121 (users operating-system-users ; list of user accounts 122 (users operating-system-users ; list of user accounts
122 (default '())) 123 (default %base-user-accounts))
123 (groups operating-system-groups ; list of user groups 124 (groups operating-system-groups ; list of user groups
124 (default %base-groups)) 125 (default %base-groups))
125 126
@@ -147,7 +148,7 @@
147 (setuid-programs operating-system-setuid-programs 148 (setuid-programs operating-system-setuid-programs
148 (default %setuid-programs)) ; list of string-valued gexps 149 (default %setuid-programs)) ; list of string-valued gexps
149 150
150 (sudoers operating-system-sudoers ; /etc/sudoers contents 151 (sudoers operating-system-sudoers ; file-like
151 (default %sudoers-specification))) 152 (default %sudoers-specification)))
152 153
153 154
@@ -373,7 +374,7 @@ This is the GNU system. Welcome.\n")
373 374
374(define (default-/etc/hosts host-name) 375(define (default-/etc/hosts host-name)
375 "Return the default /etc/hosts file." 376 "Return the default /etc/hosts file."
376 (text-file "hosts" (local-host-aliases host-name))) 377 (plain-file "hosts" (local-host-aliases host-name)))
377 378
378(define (emacs-site-file) 379(define (emacs-site-file)
379 "Return the Emacs 'site-start.el' file. That file contains the necessary 380 "Return the Emacs 'site-start.el' file. That file contains the necessary
@@ -439,11 +440,10 @@ on SHELLS. /etc/shells is used by xterm, polkit, and other programs."
439 (pam-services '()) 440 (pam-services '())
440 (profile "/run/current-system/profile") 441 (profile "/run/current-system/profile")
441 hosts-file nss (shells '()) 442 hosts-file nss (shells '())
442 (sudoers "")) 443 (sudoers (plain-file "sudoers" "")))
443 "Return a derivation that builds the static part of the /etc directory." 444 "Return a derivation that builds the static part of the /etc directory."
444 (mlet* %store-monad 445 (mlet* %store-monad
445 ((pam.d (pam-services->directory pam-services)) 446 ((pam.d (pam-services->directory pam-services))
446 (sudoers (text-file "sudoers" sudoers))
447 (login.defs (text-file "login.defs" "# Empty for now.\n")) 447 (login.defs (text-file "login.defs" "# Empty for now.\n"))
448 (shells (shells-file shells)) 448 (shells (shells-file shells))
449 (emacs (emacs-site-directory)) 449 (emacs (emacs-site-directory))
@@ -461,14 +461,40 @@ export TZDIR=\"" tzdata "/share/zoneinfo\"
461# Tell 'modprobe' & co. where to look for modules. 461# Tell 'modprobe' & co. where to look for modules.
462export LINUX_MODULE_DIRECTORY=/run/booted-system/kernel/lib/modules 462export LINUX_MODULE_DIRECTORY=/run/booted-system/kernel/lib/modules
463 463
464export PATH=$HOME/.guix-profile/bin:/run/current-system/profile/bin 464# These variables are honored by OpenSSL (libssl) and Git.
465export PATH=/run/setuid-programs:/run/current-system/profile/sbin:$PATH 465export SSL_CERT_DIR=/etc/ssl/certs
466export SSL_CERT_FILE=\"$SSL_CERT_DIR/ca-certificates.crt\"
467export GIT_SSL_CAINFO=\"$SSL_CERT_FILE\"
468
469# Crucial variables that could be missing the the profiles' 'etc/profile'
470# because they would require combining both profiles.
471# FIXME: See <http://bugs.gnu.org/20255>.
466export MANPATH=$HOME/.guix-profile/share/man:/run/current-system/profile/share/man 472export MANPATH=$HOME/.guix-profile/share/man:/run/current-system/profile/share/man
467export INFOPATH=$HOME/.guix-profile/share/info:/run/current-system/profile/share/info 473export INFOPATH=$HOME/.guix-profile/share/info:/run/current-system/profile/share/info
468
469export XDG_DATA_DIRS=$HOME/.guix-profile/share:/run/current-system/profile/share 474export XDG_DATA_DIRS=$HOME/.guix-profile/share:/run/current-system/profile/share
470export XDG_CONFIG_DIRS=$HOME/.guix-profile/etc/xdg:/run/current-system/profile/etc/xdg 475export XDG_CONFIG_DIRS=$HOME/.guix-profile/etc/xdg:/run/current-system/profile/etc/xdg
471 476
477# Ignore the default value of 'PATH'.
478unset PATH
479
480# Load the system profile's settings.
481GUIX_PROFILE=/run/current-system/profile \\
482. /run/current-system/profile/etc/profile
483
484# Prepend setuid programs.
485export PATH=/run/setuid-programs:$PATH
486
487if [ -f \"$HOME/.guix-profile/etc/profile\" ]
488then
489 # Load the user profile's settings.
490 GUIX_PROFILE=\"$HOME/.guix-profile\" \\
491 . \"$HOME/.guix-profile/etc/profile\"
492else
493 # At least define this one so that basic things just work
494 # when the user installs their first package.
495 export PATH=\"$HOME/.guix-profile/bin:$PATH\"
496fi
497
472# Append the directory of 'site-start.el' to the search path. 498# Append the directory of 'site-start.el' to the search path.
473export EMACSLOADPATH=:/etc/emacs 499export EMACSLOADPATH=:/etc/emacs
474 500
@@ -476,18 +502,13 @@ export EMACSLOADPATH=:/etc/emacs
476# when /etc/machine-id is missing. Make sure these warnings are non-fatal. 502# when /etc/machine-id is missing. Make sure these warnings are non-fatal.
477export DBUS_FATAL_WARNINGS=0 503export DBUS_FATAL_WARNINGS=0
478 504
479# These variables are honored by OpenSSL (libssl) and Git.
480export SSL_CERT_DIR=/etc/ssl/certs
481export SSL_CERT_FILE=\"$SSL_CERT_DIR/ca-certificates.crt\"
482export GIT_SSL_CAINFO=\"$SSL_CERT_FILE\"
483
484# Allow Aspell to find dictionaries installed in the user profile. 505# Allow Aspell to find dictionaries installed in the user profile.
485export ASPELL_CONF=\"dict-dir $HOME/.guix-profile/lib/aspell\" 506export ASPELL_CONF=\"dict-dir $HOME/.guix-profile/lib/aspell\"
486 507
487if [ -n \"$BASH_VERSION\" -a -f /etc/bashrc ] 508if [ -n \"$BASH_VERSION\" -a -f /etc/bashrc ]
488then 509then
489 # Load Bash-specific initialization code. 510 # Load Bash-specific initialization code.
490 source /etc/bashrc 511 . /etc/bashrc
491fi 512fi
492")) 513"))
493 514
@@ -519,7 +540,7 @@ fi\n"))
519 ("hosts" ,#~#$hosts-file) 540 ("hosts" ,#~#$hosts-file)
520 ("localtime" ,#~(string-append #$tzdata "/share/zoneinfo/" 541 ("localtime" ,#~(string-append #$tzdata "/share/zoneinfo/"
521 #$timezone)) 542 #$timezone))
522 ("sudoers" ,#~#$sudoers))))) 543 ("sudoers" ,sudoers)))))
523 544
524(define (operating-system-profile os) 545(define (operating-system-profile os)
525 "Return a derivation that builds the system profile of OS." 546 "Return a derivation that builds the system profile of OS."
@@ -549,6 +570,37 @@ fi\n"))
549 (return (append users 570 (return (append users
550 (append-map service-user-accounts services))))) 571 (append-map service-user-accounts services)))))
551 572
573(define (maybe-string->file file-name thing)
574 "If THING is a string, return a <plain-file> with THING as its content.
575Otherwise just return THING.
576
577This is for backward-compatibility of fields that used to be strings and are
578now file-like objects.."
579 (match thing
580 ((? string?)
581 (warning (_ "using a string for file '~a' is deprecated; \
582use 'plain-file' instead~%")
583 file-name)
584 (plain-file file-name thing))
585 (x
586 x)))
587
588(define (maybe-file->monadic file-name thing)
589 "If THING is a value in %STORE-MONAD, return it as is; otherwise return
590THING in the %STORE-MONAD.
591
592This is for backward-compatibility of fields that used to be monadic values
593and are now file-like objects."
594 (with-monad %store-monad
595 (match thing
596 ((? procedure?)
597 (warning (_ "using a monadic value for '~a' is deprecated; \
598use 'plain-file' instead~%")
599 file-name)
600 thing)
601 (x
602 (return x)))))
603
552(define (operating-system-etc-directory os) 604(define (operating-system-etc-directory os)
553 "Return that static part of the /etc directory of OS." 605 "Return that static part of the /etc directory of OS."
554 (mlet* %store-monad 606 (mlet* %store-monad
@@ -559,8 +611,10 @@ fi\n"))
559 (append-map service-pam-services services))) 611 (append-map service-pam-services services)))
560 (profile-drv (operating-system-profile os)) 612 (profile-drv (operating-system-profile os))
561 (skeletons (operating-system-skeletons os)) 613 (skeletons (operating-system-skeletons os))
562 (/etc/hosts (or (operating-system-hosts-file os) 614 (/etc/hosts (maybe-file->monadic
563 (default-/etc/hosts (operating-system-host-name os)))) 615 "hosts"
616 (or (operating-system-hosts-file os)
617 (default-/etc/hosts (operating-system-host-name os)))))
564 (shells (user-shells os))) 618 (shells (user-shells os)))
565 (etc-directory #:pam-services pam-services 619 (etc-directory #:pam-services pam-services
566 #:skeletons skeletons 620 #:skeletons skeletons
@@ -570,7 +624,9 @@ fi\n"))
570 #:timezone (operating-system-timezone os) 624 #:timezone (operating-system-timezone os)
571 #:hosts-file /etc/hosts 625 #:hosts-file /etc/hosts
572 #:shells shells 626 #:shells shells
573 #:sudoers (operating-system-sudoers os) 627 #:sudoers (maybe-string->file
628 "sudoers"
629 (operating-system-sudoers os))
574 #:profile profile-drv))) 630 #:profile profile-drv)))
575 631
576(define %setuid-programs 632(define %setuid-programs
@@ -587,8 +643,9 @@ fi\n"))
587 ;; group can do anything. See 643 ;; group can do anything. See
588 ;; <http://www.sudo.ws/sudo/man/1.8.10/sudoers.man.html>. 644 ;; <http://www.sudo.ws/sudo/man/1.8.10/sudoers.man.html>.
589 ;; TODO: Add a declarative API. 645 ;; TODO: Add a declarative API.
590 "root ALL=(ALL) ALL 646 (plain-file "sudoers" "\
591%wheel ALL=(ALL) ALL\n") 647root ALL=(ALL) ALL
648%wheel ALL=(ALL) ALL\n"))
592 649
593(define (user-group->gexp group) 650(define (user-group->gexp group)
594 "Turn GROUP, a <user-group> object, into a list-valued gexp suitable for 651 "Turn GROUP, a <user-group> object, into a list-valued gexp suitable for
@@ -665,6 +722,8 @@ etc."
665 (define group-specs 722 (define group-specs
666 (map user-group->gexp groups)) 723 (map user-group->gexp groups))
667 724
725 (assert-valid-users/groups accounts groups)
726
668 (gexp->file "activate" 727 (gexp->file "activate"
669 #~(begin 728 #~(begin
670 (eval-when (expand load eval) 729 (eval-when (expand load eval)