[PATCH] Add guix-home-service-type

  • Done
  • quality assurance status badge
Details
3 participants
  • Ludovic Courtès
  • Richard Sent
  • Lars Rustand
Owner
unassigned
Submitted by
Lars Rustand
Severity
normal
L
L
Lars Rustand wrote on 19 Jan 15:12 +0100
(address . guix-patches@gnu.org)
87wms5e6ym.fsf@yoga.mail-host-address-is-not-set
Hoping to upstream this nice service from RDE. This service allows to
embed a home environment in a operating-system declaration.


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

Toggle diff (55 lines)
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
L
L
Ludovic Courtès wrote on 10 Feb 22:30 +0100
(name . Lars Rustand)(address . rustand.lars@gmail.com)(address . 68589@debbugs.gnu.org)
877cjchuro.fsf@gnu.org
Hi Lars,

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

Toggle quote (7 lines)
> 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!

Toggle quote (4 lines)
> +++ 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.

Toggle quote (6 lines)
> +(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’:


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

Toggle quote (3 lines)
> +(define (guix-home-gc-roots config)
> + (map cdr config))

Unused.

Toggle quote (5 lines)
> +(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.”

Toggle quote (6 lines)
> + (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’.
R
R
Richard Sent wrote on 26 Mar 00:12 +0100
(address . 68589@debbugs.gnu.org)
87wmpp52jg.fsf@freakingpenguin.com
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.
L
L
Ludovic Courtès wrote on 29 Apr 12:16 +0200
(name . Richard Sent)(address . richard@freakingpenguin.com)
87frv4fp93.fsf@gnu.org
Hi,

Richard Sent <richard@freakingpenguin.com> skribis:

Toggle quote (8 lines)
> 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’.
Closed
?