@@ -125,6 +125,7 @@
Copyright @copyright{} 2023 Graham James Addis@*
Copyright @copyright{} 2023 Tomas Volf@*
Copyright @copyright{} 2024 Herman Rimm@*
+Copyright @copyright{} 2024 Richard Sent@*
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
@@ -39567,6 +39568,37 @@ Guix Services
@end table
@end deftp
+@subsubheading Guix Home Service
+The Guix Home Service allows for associating Guix @ref{Declaring the
+Home Environment, home-environment} declarations with a Guix
+@ref{operating-system Reference, operating-system}.
+
+@defvar guix-home-service-type
+Service type for the Guix Home Service. Its value must be an
+association list. The key of each pair is a string representing the user
+to deploy the configuration under and the value is a home-environment
+configuration.
+
+@lisp
+(define my-home
+ (home-environment
+ ...))
+
+(operating-system
+ (services (list
+ (service guix-home-service-type
+ `(("alice" ,my-home))))))
+@end lisp
+
+This service can be extended by other services to add additional home
+environments, as in this example:
+
+@lisp
+(simple-service 'my-extra-home home-service-type
+ `(("bob" ,my-extra-home))))
+@end lisp
+@end defvar
+
@subsubheading Nar Herder
The @uref{https://git.cbaines.net/guix/nar-herder/about/,Nar Herder} is
a utility for managing a collection of nars.
@@ -132,7 +132,12 @@ (define (ensure-shepherd-gexp config)
(format #f "/run/user/~a" (getuid)))
"/shepherd/socket"))
#$(reload-configuration-gexp config)
- #$(launch-shepherd-gexp config)))
+ ;; Don't attempt to start user shepherd if the system is running the
+ ;; activation script. /run/user/<uid> may not have been created
+ ;; yet. But do otherwise so if the runtime dir does not exist an error
+ ;; is logged.
+ (unless (getenv "GUIX_SYSTEM_IS_RUNNING_HOME_ACTIVATE")
+ #$(launch-shepherd-gexp config))))
(define (shepherd-xdg-configuration-files config)
`(("shepherd/init.scm" ,(home-shepherd-configuration-file config))))
@@ -1,5 +1,6 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2019, 2020, 2021, 2022 Christopher Baines <mail@cbaines.net>
+;;; Copyright © 2024 Andrew Tropin <andrew@trop.in>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -101,6 +102,8 @@ (define-module (gnu services guix)
guix-data-service-type
+ guix-home-service-type
+
nar-herder-service-type
nar-herder-configuration
nar-herder-configuration?
@@ -686,6 +689,42 @@ (define guix-data-service-type
(description
"Run an instance of the Guix Data Service.")))
+
+;;;
+;;; Guix Home Service
+;;;
+
+(define (guix-home-shepherd-service config)
+ (map (lambda (x)
+ (let ((user (car x))
+ (he (cdr x)))
+ (shepherd-service
+ (documentation "Activate Guix Home.")
+ (requirement '(user-processes))
+ (provision (list (symbol-append 'guix-home- (string->symbol user))))
+ (one-shot? #t)
+ (auto-start? #t)
+ (start #~(make-forkexec-constructor
+ '(#$(file-append he "/activate"))
+ #:user #$user
+ #:environment-variables
+ (list (string-append "HOME=" (passwd:dir (getpw #$user)))
+ "GUIX_SYSTEM_IS_RUNNING_HOME_ACTIVATE=t")
+ #:group (group:name (getgrgid (passwd:gid (getpw #$user))))))
+ (stop #~(make-kill-destructor)))))
+ config))
+
+(define guix-home-service-type
+ (service-type
+ (name 'guix-home)
+ (description "Setups home-environments specified in the value.")
+ (extensions (list (service-extension
+ shepherd-root-service-type
+ guix-home-shepherd-service)))
+ (compose concatenate)
+ (extend append)
+ (default-value '())))
+
;;;
;;; Nar Herder