GNU bug report logs - #68589
[PATCH] Add guix-home-service-type

Previous Next

Package: guix-patches;

Reported by: Lars Rustand <rustand.lars <at> gmail.com>

Date: Fri, 19 Jan 2024 14:26:01 UTC

Severity: normal

Tags: patch

Done: Ludovic Courtès <ludo <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 68589 in the body.
You can then email your comments to 68589 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#68589; Package guix-patches. (Fri, 19 Jan 2024 14:26:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Lars Rustand <rustand.lars <at> gmail.com>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Fri, 19 Jan 2024 14:26:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Lars Rustand <rustand.lars <at> gmail.com>
To: guix-patches <at> gnu.org
Subject: [PATCH] Add guix-home-service-type
Date: Fri, 19 Jan 2024 15:12:13 +0100
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




Information forwarded to guix-patches <at> gnu.org:
bug#68589; Package guix-patches. (Sat, 10 Feb 2024 21:32:02 GMT) Full text and rfc822 format available.

Message #8 received at 68589 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Lars Rustand <rustand.lars <at> gmail.com>
Cc: 68589 <at> debbugs.gnu.org
Subject: Re: [bug#68589] [PATCH] Add guix-home-service-type
Date: Sat, 10 Feb 2024 22:30:35 +0100
Hi Lars,

Lars Rustand <rustand.lars <at> gmail.com> skribis:

> 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

This would be much welcome!

> +++ b/gnu/services/home.scm
> @@ -0,0 +1,47 @@
> +(define-module (gnu services home)

Could you add a header similar to that found in other files?

Since this is copied from rde, make sure to preserve their copyright
notices.

> +(define (guix-home-shepherd-service config)
> +  (map
> +   (lambda (x)
> +     (let ((user (car x))
> +           (he (cdr x)))

In Guix we’d use ‘match’ instead of ‘car’ + ‘cdr’:

  https://guix.gnu.org/manual/devel/en/html_node/Data-Types-and-Pattern-Matching.html

But perhaps we could just as well define a <guix-home-configuration>
record or similar?

> +(define (guix-home-gc-roots config)
> +  (map cdr config))

Unused.

> +(define guix-home-service-type
> +  (service-type
> +   (name 'guix-home)
> +   (description "Setups home-environments specified in the value.")

“Sets up Guix Home for the specified user accounts.”

> +   (extensions (list (service-extension
> +                      shepherd-root-service-type
> +                      guix-home-shepherd-service)))
> +   ;; (compose append)
> +   ;; (extend append)

Why comment it out?

Also make sure to register the file in ‘gnu/local.mk’.

Last, we usually require a test for system services; you can find them
in gnu/tests/*.scm.  Could you try and write one?  It would check for
instance that the user’s shepherd is indeed started.

Could you send an updated patch?

Thanks,
Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#68589; Package guix-patches. (Mon, 25 Mar 2024 23:13:01 GMT) Full text and rfc822 format available.

Message #11 received at 68589 <at> debbugs.gnu.org (full text, mbox):

From: Richard Sent <richard <at> freakingpenguin.com>
To: 68589 <at> debbugs.gnu.org
Subject: Re: [bug#68589] [PATCH] Add guix-home-service-type
Date: Mon, 25 Mar 2024 19:12:35 -0400
Hi all,

I accidentally submitted a patch very similar to this one at
https://issues.guix.gnu.org/69781. FYI in case anyone winds up iterating
on this version of the patch.

Not sure how to merge debbugs issues. I did implement most of the
feedback mentioned in this issue and resolved a couple of other
problems.

-- 
Take it easy,
Richard Sent
Making my computer weirder one commit at a time.




Reply sent to Ludovic Courtès <ludo <at> gnu.org>:
You have taken responsibility. (Mon, 29 Apr 2024 10:17:01 GMT) Full text and rfc822 format available.

Notification sent to Lars Rustand <rustand.lars <at> gmail.com>:
bug acknowledged by developer. (Mon, 29 Apr 2024 10:17:02 GMT) Full text and rfc822 format available.

Message #16 received at 68589-done <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Richard Sent <richard <at> freakingpenguin.com>
Cc: rustand.lars <at> gmail.com, 68589-done <at> debbugs.gnu.org
Subject: Re: [bug#68589] [PATCH] Add guix-home-service-type
Date: Mon, 29 Apr 2024 12:16:08 +0200
Hi,

Richard Sent <richard <at> freakingpenguin.com> skribis:

> I accidentally submitted a patch very similar to this one at
> https://issues.guix.gnu.org/69781. FYI in case anyone winds up iterating
> on this version of the patch.
>
> Not sure how to merge debbugs issues. I did implement most of the
> feedback mentioned in this issue and resolved a couple of other
> problems.

Oops indeed.  Lars, I’m closing this issue, but please let us know if
you have suggestions!

Ludo’.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 27 May 2024 11:24:13 GMT) Full text and rfc822 format available.

This bug report was last modified 60 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.