+ (with-imported-modules (source-module-closure '((gnu system accounts)))
+ #~(begin
+ (use-modules (gnu system accounts))
+
+ (activate-users+groups (map sexp->user-account (list #$@user-specs))
+ (map sexp->user-group (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))
+ (one-shot? #t)
+ (modules '((gnu build activation)
+ (gnu system accounts)))
+ (start (with-imported-modules (source-module-closure
+ '((gnu build activation)
+ (gnu system accounts)))
+ #~(lambda ()
+ (activate-user-home
+ (map sexp->user-account
+ (list #$@(map user-account->gexp accounts))))
+ #t))) ;success
+ (documentation "Create user home directories."))))