summaryrefslogtreecommitdiff
path: root/gnu/system.scm
diff options
context:
space:
mode:
Diffstat (limited to 'gnu/system.scm')
-rw-r--r--gnu/system.scm135
1 files changed, 84 insertions, 51 deletions
diff --git a/gnu/system.scm b/gnu/system.scm
index f3dafd144b..9871a0b5d3 100644
--- a/gnu/system.scm
+++ b/gnu/system.scm
@@ -359,6 +359,9 @@ marked as 'needed-for-boot'."
(remove file-system-needed-for-boot?
(operating-system-file-systems os)))
+ (define mapped-devices-for-boot
+ (operating-system-boot-mapped-devices os))
+
(define (device-mappings fs)
(let ((device (file-system-device fs)))
(if (string? device) ;title is 'device
@@ -374,21 +377,23 @@ marked as 'needed-for-boot'."
(file-system
(inherit fs)
(dependencies
- (delete-duplicates (append (device-mappings fs)
- (file-system-dependencies fs))
- eq?))))
+ (delete-duplicates
+ (remove (cut member <> mapped-devices-for-boot)
+ (append (device-mappings fs)
+ (file-system-dependencies fs)))
+ eq?))))
(service file-system-service-type
(map add-dependencies file-systems)))
-(define (mapped-device-user device file-systems)
- "Return a file system among FILE-SYSTEMS that uses DEVICE, or #f."
+(define (mapped-device-users device file-systems)
+ "Return the subset of FILE-SYSTEMS that use DEVICE."
(let ((target (string-append "/dev/mapper/" (mapped-device-target device))))
- (find (lambda (fs)
- (or (member device (file-system-dependencies fs))
- (and (string? (file-system-device fs))
- (string=? (file-system-device fs) target))))
- file-systems)))
+ (filter (lambda (fs)
+ (or (member device (file-system-dependencies fs))
+ (and (string? (file-system-device fs))
+ (string=? (file-system-device fs) target))))
+ file-systems)))
(define (operating-system-user-mapped-devices os)
"Return the subset of mapped devices that can be installed in
@@ -396,9 +401,8 @@ user-land--i.e., those not needed during boot."
(let ((devices (operating-system-mapped-devices os))
(file-systems (operating-system-file-systems os)))
(filter (lambda (md)
- (let ((user (mapped-device-user md file-systems)))
- (or (not user)
- (not (file-system-needed-for-boot? user)))))
+ (let ((users (mapped-device-users md file-systems)))
+ (not (any file-system-needed-for-boot? users))))
devices)))
(define (operating-system-boot-mapped-devices os)
@@ -407,8 +411,8 @@ from the initrd."
(let ((devices (operating-system-mapped-devices os))
(file-systems (operating-system-file-systems os)))
(filter (lambda (md)
- (let ((user (mapped-device-user md file-systems)))
- (and user (file-system-needed-for-boot? user))))
+ (let ((users (mapped-device-users md file-systems)))
+ (any file-system-needed-for-boot? users)))
devices)))
(define (device-mapping-services os)
@@ -451,7 +455,7 @@ value of the SYSTEM-SERVICE-TYPE service."
("initrd" ,initrd)
("locale" ,locale)))))))) ;used by libc
-(define* (essential-services os #:key container?)
+(define* (essential-services os #:key container? container-shared-network?)
"Return the list of essential services for OS. These are special services
that implement part of what's declared in OS are responsible for low-level
bookkeeping. CONTAINER? determines whether to return the list of services for
@@ -459,6 +463,9 @@ a container or that of a \"bare metal\" system."
(define known-fs
(map file-system-mount-point (operating-system-file-systems os)))
+ (if (and container-shared-network? (not container?))
+ (error "cannot specify container-shared-network? without container? #t"))
+
(let* ((mappings (device-mapping-services os))
(root-fs (root-file-system-service))
(other-fs (non-boot-file-system-service os))
@@ -470,19 +477,20 @@ a container or that of a \"bare metal\" system."
(cons* (service system-service-type entries)
%boot-service
- ;; %SHEPHERD-ROOT-SERVICE must come first so that the gexp that
+ ;; %SHEPHERD-ROOT-SERVICE must come last so that the gexp that
;; execs shepherd comes last in the boot script (XXX). Likewise,
- ;; the cleanup service must come last so that its gexp runs before
+ ;; the cleanup service must come first so that its gexp runs before
;; activation code.
- %shepherd-root-service
- %activation-service
(service cleanup-service-type #f)
+ %activation-service
+ %shepherd-root-service
(pam-root-service (operating-system-pam-services os))
(account-service (append (operating-system-accounts os)
(operating-system-groups os))
(operating-system-skeletons os))
- (operating-system-etc-service os)
+ (operating-system-etc-service
+ os #:container-shared-network? container-shared-network?)
(service fstab-service-type '())
(session-environment-service
(operating-system-environment-variables os))
@@ -502,12 +510,13 @@ a container or that of a \"bare metal\" system."
(service firmware-service-type
(operating-system-firmware os))))))))
-(define* (operating-system-services os #:key container?)
+(define* (operating-system-services os #:key container? container-shared-network?)
"Return all the services of OS, including \"internal\" services that do not
explicitly appear in OS."
(instantiate-missing-services
(append (operating-system-user-services os)
- (essential-services os #:container? container?))))
+ (essential-services os #:container? container?
+ #:container-shared-network? container-shared-network?))))
;;;
@@ -576,7 +585,7 @@ This is the GNU system. Welcome.\n")
"Return the default /etc/hosts file."
(plain-file "hosts" (local-host-aliases host-name)))
-(define* (operating-system-etc-service os)
+(define* (operating-system-etc-service os #:key container-shared-network?)
"Return a <service> that builds containing the static part of the /etc
directory."
(let ((login.defs
@@ -616,9 +625,6 @@ unset PATH
GUIX_PROFILE=/run/current-system/profile ; \\
. /run/current-system/profile/etc/profile
-# Prepend setuid programs.
-export PATH=/run/setuid-programs:$PATH
-
# Since 'lshd' does not use pam_env, /etc/environment must be explicitly
# loaded when someone logs in via SSH. See <http://bugs.gnu.org/22175>.
# We need 'PATH' to be defined here, for 'cat' and 'cut'. Do this before
@@ -630,16 +636,26 @@ then
export `cat /etc/environment | cut -d= -f1`
fi
-if [ -f \"$HOME/.guix-profile/etc/profile\" ]
-then
- # Load the user profile's settings.
- GUIX_PROFILE=\"$HOME/.guix-profile\" ; \\
- . \"$HOME/.guix-profile/etc/profile\"
-else
- # At least define this one so that basic things just work
- # when the user installs their first package.
- export PATH=\"$HOME/.guix-profile/bin:$PATH\"
-fi
+# Arrange so that ~/.config/guix/current comes first.
+for profile in \"$HOME/.guix-profile\" \"$HOME/.config/guix/current\"
+do
+ if [ -f \"$profile/etc/profile\" ]
+ then
+ # Load the user profile's settings.
+ GUIX_PROFILE=\"$profile\" ; \\
+ . \"$profile/etc/profile\"
+ else
+ # At least define this one so that basic things just work
+ # when the user installs their first package.
+ export PATH=\"$profile/bin:$PATH\"
+ fi
+done
+
+# Prepend setuid programs.
+export PATH=/run/setuid-programs:$PATH
+
+# Arrange so that ~/.config/guix/current/share/info comes first.
+export INFOPATH=\"$HOME/.config/guix/current/share/info:$INFOPATH\"
# Set the umask, notably for users logging in via 'lsh'.
# See <http://bugs.gnu.org/22650>.
@@ -671,16 +687,13 @@ then
source /run/current-system/profile/etc/profile.d/bash_completion.sh
fi\n")))
(etc-service
- `(("services" ,(file-append net-base "/etc/services"))
- ("protocols" ,(file-append net-base "/etc/protocols"))
+ `(("protocols" ,(file-append net-base "/etc/protocols"))
("rpc" ,(file-append net-base "/etc/rpc"))
("login.defs" ,#~#$login.defs)
("issue" ,#~#$issue)
("nsswitch.conf" ,#~#$nsswitch)
("profile" ,#~#$profile)
("bashrc" ,#~#$bashrc)
- ("hosts" ,#~#$(or (operating-system-hosts-file os)
- (default-/etc/hosts (operating-system-host-name os))))
;; Write the operating-system-host-name to /etc/hostname to prevent
;; NetworkManager from changing the system's hostname when connecting
;; to certain networks. Some discussion at
@@ -688,7 +701,13 @@ fi\n")))
("hostname" ,(plain-file "hostname" (operating-system-host-name os)))
("localtime" ,(file-append tzdata "/share/zoneinfo/"
(operating-system-timezone os)))
- ("sudoers" ,(operating-system-sudoers-file os))))))
+ ("sudoers" ,(operating-system-sudoers-file os))
+ ,@(if container-shared-network?
+ '()
+ `(("services" ,(file-append net-base "/etc/services"))
+ ("hosts" ,#~#$(or (operating-system-hosts-file os)
+ (default-/etc/hosts
+ (operating-system-host-name os))))))))))
(define %root-account
;; Default root account.
@@ -797,22 +816,29 @@ use 'plain-file' instead~%")
root ALL=(ALL) ALL
%wheel ALL=(ALL) ALL\n"))
-(define* (operating-system-activation-script os #:key container?)
+(define* (operating-system-activation-script os #:key container?
+ container-shared-network?)
"Return the activation script for OS---i.e., the code that \"activates\" the
stateful part of OS, including user accounts and groups, special directories,
etc."
- (let* ((services (operating-system-services os #:container? container?))
+ (let* ((services (operating-system-services
+ os
+ #:container? container?
+ #:container-shared-network? container-shared-network?))
(activation (fold-services services
#:target-type activation-service-type)))
(activation-service->script activation)))
-(define* (operating-system-boot-script os #:key container?)
+(define* (operating-system-boot-script os #:key container?
+ container-shared-network?)
"Return the boot script for OS---i.e., the code started by the initrd once
we're running in the final root. When CONTAINER? is true, skip all
hardware-related operations as necessary when booting a Linux container."
- (let* ((services (operating-system-services os #:container? container?))
+ (let* ((services (operating-system-services
+ os
+ #:container? container?
+ #:container-shared-network? container-shared-network?))
(boot (fold-services services #:target-type boot-service-type)))
- ;; BOOT is the script as a monadic value.
(service-value boot)))
(define (operating-system-user-accounts os)
@@ -831,17 +857,24 @@ hardware-related operations as necessary when booting a Linux container."
#:target-type
shepherd-root-service-type))))
-(define* (operating-system-derivation os #:key container?)
+(define* (operating-system-derivation os #:key container?
+ container-shared-network?)
"Return a derivation that builds OS."
- (let* ((services (operating-system-services os #:container? container?))
+ (let* ((services (operating-system-services
+ os
+ #:container? container?
+ #:container-shared-network? container-shared-network?))
(system (fold-services services)))
;; SYSTEM contains the derivation as a monadic value.
(service-value system)))
-(define* (operating-system-profile os #:key container?)
+(define* (operating-system-profile os #:key container? container-shared-network?)
"Return a derivation that builds the system profile of OS."
(mlet* %store-monad
- ((services -> (operating-system-services os #:container? container?))
+ ((services -> (operating-system-services
+ os
+ #:container? container?
+ #:container-shared-network? container-shared-network?))
(profile (fold-services services
#:target-type profile-service-type)))
(match profile