From 459dd9eaf2ded3bd5676af7e62892db2c7880758 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Fri, 27 Jun 2014 18:57:33 +0200 Subject: system: Add a 'system?' field to user accounts. * gnu/system/shadow.scm ()[system?]: New field. * gnu/system.scm (user-account->gexp): Add it. * guix/build/activation.scm (add-user): Add #:system? parameter and honor it. (activate-users+groups): Handle the 'system?' part of user tuples. Pass it to 'add-user'. Don't create PROFILE-DIR when SYSTEM? is true. * gnu/services/dbus.scm (dbus-service): Add 'system?' field for "messagebus" account. * gnu/services/base.scm (guix-build-accounts): Likewise. * gnu/services/avahi.scm (avahi-service): Likewise. --- guix/build/activation.scm | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'guix/build') diff --git a/guix/build/activation.scm b/guix/build/activation.scm index 12c1ca142d..9464d2157d 100644 --- a/guix/build/activation.scm +++ b/guix/build/activation.scm @@ -47,7 +47,7 @@ (define* (add-group name #:key gid password (zero? (apply system* "groupadd" args)))) (define* (add-user name group - #:key uid comment home shell password + #:key uid comment home shell password system? (supplementary-groups '()) (log-port (current-error-port))) "Create an account for user NAME part of GROUP, with the specified @@ -82,6 +82,7 @@ (define* (add-user name group '()) ,@(if shell `("-s" ,shell) '()) ,@(if password `("-p" ,password) '()) + ,@(if system? '("--system") '()) ,name))) (zero? (apply system* "useradd" args))))) @@ -97,22 +98,24 @@ (define (touch file) (define activate-user (match-lambda - ((name uid group supplementary-groups comment home shell password) + ((name uid group supplementary-groups comment home shell password system?) (unless (false-if-exception (getpwnam name)) (let ((profile-dir (string-append "/var/guix/profiles/per-user/" name))) (add-user name group #:uid uid + #:system? system? #:supplementary-groups supplementary-groups #:comment comment #:home home #:shell shell #:password password) - ;; Create the profile directory for the new account. - (let ((pw (getpwnam name))) - (mkdir-p profile-dir) - (chown profile-dir (passwd:uid pw) (passwd:gid pw)))))))) + (unless system? + ;; Create the profile directory for the new account. + (let ((pw (getpwnam name))) + (mkdir-p profile-dir) + (chown profile-dir (passwd:uid pw) (passwd:gid pw))))))))) ;; 'groupadd' aborts if the file doesn't already exist. (touch "/etc/group") -- cgit v1.2.3