From ae763b5b0b7d5e7316a3d0efe991fe8ab2261031 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Wed, 1 Feb 2017 12:16:39 +0100 Subject: system: Create home directories once 'file-systems' is up. Fixes . Reported by Andy Patterson and Leo Famulari . * gnu/build/activation.scm (activate-users+groups)[activate-user]: Pass #:create-home? #t iff CREATE-HOME? and SYSTEM?. (activate-user-home): New procedure. * gnu/system/shadow.scm (account-shepherd-service): New procedure. (account-service-type)[extensions]: Add SHEPHERD-ROOT-SERVICE-TYPE extension. * gnu/tests/base.scm (run-basic-test)["home"] ["skeletons in home directories"]: New tests. * gnu/tests/install.scm (%separate-home-os, %separate-home-os-source) (%test-separate-home-os): New variables. --- gnu/system/shadow.scm | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'gnu/system') diff --git a/gnu/system/shadow.scm b/gnu/system/shadow.scm index cfdcf5e136..ee9d55c157 100644 --- a/gnu/system/shadow.scm +++ b/gnu/system/shadow.scm @@ -21,9 +21,11 @@ (define-module (gnu system shadow) #:use-module (guix records) #:use-module (guix gexp) #:use-module (guix store) + #:use-module (guix modules) #:use-module (guix sets) #:use-module (guix ui) #:use-module (gnu services) + #:use-module (gnu services shepherd) #:use-module ((gnu system file-systems) #:select (%tty-gid)) #:use-module ((gnu packages admin) @@ -43,6 +45,7 @@ (define-module (gnu system shadow) user-account-supplementary-groups user-account-comment user-account-home-directory + user-account-create-home-directory? user-account-shell user-account-system? @@ -288,6 +291,35 @@ (define group-specs (activate-users+groups (list #$@user-specs) (list #$@group-specs)))) +(define (account-shepherd-service accounts+groups) + "Return a Shepherd service that creates the home directories for the user +accounts among ACCOUNTS+GROUPS." + (define accounts + (filter user-account? accounts+groups)) + + ;; Create home directories only once 'file-systems' is up. This makes sure + ;; they are created in the right place if /home lives on a separate + ;; partition. + ;; + ;; XXX: We arrange for this service to stop right after it's done its job so + ;; that 'guix system reconfigure' knows that it can reload it fearlessly + ;; (and thus create new home directories). The cost of this hack is that + ;; there's a small window during which first-time logins could happen before + ;; the home directory has been created. + (list (shepherd-service + (requirement '(file-systems)) + (provision '(user-homes)) + (modules '((gnu build activation))) + (start (with-imported-modules (source-module-closure + '((gnu build activation))) + #~(lambda () + (activate-user-home + (list #$@(map user-account->gexp accounts))) + #f))) ;stop + (stop #~(const #f)) + (respawn? #f) + (documentation "Create user home directories.")))) + (define (shells-file shells) "Return a file-like object that builds a shell list for use as /etc/shells based on SHELLS. /etc/shells is used by xterm, polkit, and other programs." @@ -327,6 +359,8 @@ (define account-service-type (extensions (list (service-extension activation-service-type account-activation) + (service-extension shepherd-root-service-type + account-shepherd-service) (service-extension etc-service-type etc-files))))) -- cgit v1.2.3 From 357db1f91de9b3eb14be52a98cc804cdfd284f6d Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Wed, 1 Feb 2017 12:30:56 +0100 Subject: system: More 'file-append' instead of #~(string-append #$thing …). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * gnu/system/shadow.scm ()[shell]: Use 'file-append'. (%base-user-accounts): Likewise. * gnu/system/grub.scm (%background-image): Likewise. --- gnu/system/grub.scm | 4 ++-- gnu/system/shadow.scm | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'gnu/system') diff --git a/gnu/system/grub.scm b/gnu/system/grub.scm index 067b291a5c..7df7d4615a 100644 --- a/gnu/system/grub.scm +++ b/gnu/system/grub.scm @@ -94,8 +94,8 @@ (define-record-type* (define %background-image (grub-image (aspect-ratio 4/3) - (file #~(string-append #$%artwork-repository - "/grub/GuixSD-fully-black-4-3.svg")))) + (file (file-append %artwork-repository + "/grub/GuixSD-fully-black-4-3.svg")))) (define %default-theme ;; Default theme contributed by Felipe López. diff --git a/gnu/system/shadow.scm b/gnu/system/shadow.scm index ee9d55c157..1acfcc4866 100644 --- a/gnu/system/shadow.scm +++ b/gnu/system/shadow.scm @@ -84,7 +84,7 @@ (define-record-type* (create-home-directory? user-account-create-home-directory? ;Boolean (default #t)) (shell user-account-shell ; gexp - (default #~(string-append #$bash "/bin/bash"))) + (default (file-append bash "/bin/bash"))) (system? user-account-system? ; Boolean (default #f))) @@ -131,7 +131,7 @@ (define %base-user-accounts (name "nobody") (uid 65534) (group "nogroup") - (shell #~(string-append #$shadow "/sbin/nologin")) + (shell (file-append shadow "/sbin/nologin")) (home-directory "/nonexistent") (create-home-directory? #f) (system? #t)))) -- cgit v1.2.3