all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Lars Rustand <rustand.lars@gmail.com>
To: 68589@debbugs.gnu.org
Subject: [bug#68589] [PATCH] Add guix-home-service-type
Date: Fri, 19 Jan 2024 15:12:13 +0100	[thread overview]
Message-ID: <87wms5e6ym.fsf@yoga.mail-host-address-is-not-set> (raw)


Hoping to upstream this nice service from RDE. This service allows to
embed a home environment in a operating-system declaration.

Original source: https://git.sr.ht/~abcdw/rde/tree/master/item/src/gnu/services/home.scm

Change-Id: I42976cae9dd1580dc07dc866cd851294c7921725
---
 gnu/services/home.scm | 47 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)
 create mode 100644 gnu/services/home.scm

diff --git a/gnu/services/home.scm b/gnu/services/home.scm
new file mode 100644
index 0000000000..868eafbec8
--- /dev/null
+++ b/gnu/services/home.scm
@@ -0,0 +1,47 @@
+(define-module (gnu services home)
+  #:use-module (gnu services)
+  #:use-module (gnu services shepherd)
+
+  #:use-module (guix gexp)
+  #:use-module (guix packages)
+  #:use-module (guix records)
+
+  #:export (guix-home-service-type))
+
+
+(define (guix-home-shepherd-service config)
+  (map
+   (lambda (x)
+     (let ((user (car x))
+           (he (cdr x)))
+       (shepherd-service
+        (documentation "Activate Guix Home.")
+        ;; Originally requirement was user-homes, but for recently it stopped
+        ;; working, seems like it was executed too early and didn't work, so
+        ;; we switched to term-tty1.
+        (requirement '(term-tty1))
+        (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))))
+                  #:group (group:name (getgrgid (passwd:gid (getpw #$user))))))
+        (stop #~(make-kill-destructor)))))
+     config))
+
+(define (guix-home-gc-roots config)
+  (map cdr 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 append)
+   ;; (extend append)
+   (default-value '())))

base-commit: 162d6a2fdd6af13272967c77347a54934ecb45e6
--
2.41.0




             reply	other threads:[~2024-01-19 14:26 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-19 14:12 Lars Rustand [this message]
2024-02-10 21:30 ` [bug#68589] [PATCH] Add guix-home-service-type Ludovic Courtès
2024-03-25 23:12 ` Richard Sent
2024-04-29 10:16   ` bug#68589: " Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87wms5e6ym.fsf@yoga.mail-host-address-is-not-set \
    --to=rustand.lars@gmail.com \
    --cc=68589@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.