summary refs log tree commit diff
path: root/gnu/services
diff options
context:
space:
mode:
authorRichard Sent <richard@freakingpenguin.com>2024-03-21 14:36:43 -0400
committerLudovic Courtès <ludo@gnu.org>2024-04-17 12:13:03 +0200
commit59bb53823e6babb2d50e246d312879980c7988c9 (patch)
treee20d682176458fdc8514185da5cd1dc84b5bfd33 /gnu/services
parent9f8e92cc7d8cbcb2709dda5f3f0287215441d939 (diff)
downloadguix-59bb53823e6babb2d50e246d312879980c7988c9.tar.gz
services: Add the Guix Home service.
This patch adds a Guix Home service, which allows for configuring/deploying an
operating-system declaration with an associated home-environment.

* gnu/services/guix.scm: Add guix-home-service and guix-home-shepherd-service
* gnu/home/services/shepherd.scm: Don't attempt to launch user shepherd when
the system shepherd runs guix-home-<user>
* doc/guix.texi: Add documentation for guix-home-service
* gnu/tests/guix.scm: Add a test to verify guix-home-service-type is able to
activate a home environment

Change-Id: Ifbcc0878d934aa4abe34bb2123b5081fb432aa8e
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Diffstat (limited to 'gnu/services')
-rw-r--r--gnu/services/guix.scm38
1 files changed, 38 insertions, 0 deletions
diff --git a/gnu/services/guix.scm b/gnu/services/guix.scm
index 8b326d9124..96f5ecaac0 100644
--- a/gnu/services/guix.scm
+++ b/gnu/services/guix.scm
@@ -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 @@
 
             guix-data-service-type
 
+            guix-home-service-type
+
             nar-herder-service-type
             nar-herder-configuration
             nar-herder-configuration?
@@ -688,6 +691,41 @@ ca-certificates.crt file in the system profile."
 
 
 ;;;
+;;; Guix Home Service
+;;;
+
+(define (guix-home-shepherd-service config)
+  (map (match-lambda
+         ((user he)
+          (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 "Sets up Guix Home for the specified user accounts.")
+   (extensions (list (service-extension
+                      shepherd-root-service-type
+                      guix-home-shepherd-service)))
+   (compose concatenate)
+   (extend append)
+   (default-value '())))
+
+
+;;;
 ;;; Nar Herder
 ;;;