unofficial mirror of help-guix@gnu.org 
 help / color / mirror / Atom feed
* Running guix home + shepherd in non-Guix OS
@ 2024-02-05 15:00 Abbé
  2024-02-06 12:35 ` Carlo Zancanaro
  0 siblings, 1 reply; 3+ messages in thread
From: Abbé @ 2024-02-05 15:00 UTC (permalink / raw)
  To: help-guix@gnu.org

Hi!

I'm testing Guix on my NixOS through guix home environment. Recently, I replaced my systemd user manager with GNU Shepherd, and it seems to work fine (e.g. I could launch emacs as shepherd service).

I'm wondering how would one go about integrating shepherd with 'guix home' configuration (i.e. home environment services), akin to what Guix does (I believe, without needing to do 'guix home ...').

Following is my init.scm to play nice with systemd:

==========================================================================================
;; init.scm -- default shepherd configuration file.
(use-modules
 (shepherd service)
 (scheme base); #:select (open-output-bytevector get-output-bytevector)
 (rnrs io ports)
 ((ice-9 ftw) #:select (scandir)))

(define (string->bytevector sz)
  (let ((out (open-output-bytevector)))
    (display sz out)
    (get-output-bytevector out)))

(define (sd-notify status)
  (let ((sd-notify-socket-path (getenv "NOTIFY_SOCKET")))
                (when (string? sd-notify-socket-path)
                        (let ((sock (socket AF_UNIX SOCK_DGRAM PF_UNIX))
                                                (buf (string->bytevector status)))
                                (connect sock AF_UNIX sd-notify-socket-path)
                                (send sock buf 0)
                                (close sock)))))

(sd-notify "READY=1\nSTATUS=Shepherd is ready for its herd.\n")

;; Services known to shepherd:
;; Add new services (defined using 'service') to shepherd here by
;; providing them as arguments to 'register-services'.
(register-services)

;; Send shepherd into the background
;(perform-service-action root-service 'daemonize)

;; Services to start when shepherd starts:
;; Add the name of each service that should be started to the list
;; below passed to 'for-each'.
;(for-each start '())
(for-each
  (lambda (file) (load (string-append "init.d/" file)))
  (scandir (string-append (dirname (current-filename)) "/init.d")
           (lambda (file)
             (string-suffix? ".scm" file))))

;; Local Variables:
;; mode: scheme
;; tab-width: 2
;; End:
==========================================================================================

Essentially, what should I put in $XDG_CONFIG_HOME/shepherd/init.d/ for it to execute my "guix home" configuration.

Thanks in advance for any hints

--
Abbé



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Running guix home + shepherd in non-Guix OS
  2024-02-05 15:00 Running guix home + shepherd in non-Guix OS Abbé
@ 2024-02-06 12:35 ` Carlo Zancanaro
  2024-02-12 20:43   ` Abbé
  0 siblings, 1 reply; 3+ messages in thread
From: Carlo Zancanaro @ 2024-02-06 12:35 UTC (permalink / raw)
  To: Abbé; +Cc: help-guix@gnu.org

Hi Abbé,

On Mon, Feb 05 2024, Abbé wrote:
> I'm wondering how would one go about integrating shepherd with 'guix
> home' configuration (i.e. home environment services), akin to what
> Guix does (I believe, without needing to do 'guix home ...').

How are you defining your Guix Home configuration? Have you run "guix
home reconfigure" with your Home config?

If you have done that, you should see ~/.profile contain the lines

  HOME_ENVIRONMENT=$HOME/.guix-home
  . $HOME_ENVIRONMENT/setup-environment
  $HOME_ENVIRONMENT/on-first-login

The on-first-login script is responsible for starting a Shepherd process
which will manage the shepherd services that are defined by your Home
config (if any). These services can then be managed with the "herd"
command, as usual.

When you run "guix home reconfigure" the reconfigure process will also
register/update shepherd services to match your new configuration. Any
running services will need to be restarted with "herd restart" to finish
their upgrade.

This is the same as how Guix Home works on a Guix system.

> Essentially, what should I put in $XDG_CONFIG_HOME/shepherd/init.d/
> for it to execute my "guix home" configuration.

Guix Home does more than just start shepherd services. It is a system
for managing packages, configuration files, etc. If you haven't already,
I would suggest reading "(guix) Home Configuration" in the manual.

There isn't really anything that you can put into your Shepherd config
to execute your Home configuration. It goes the other way: instantiating
your Home config will start a Shepherd process.

I hope that helps,

Carlo


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Running guix home + shepherd in non-Guix OS
  2024-02-06 12:35 ` Carlo Zancanaro
@ 2024-02-12 20:43   ` Abbé
  0 siblings, 0 replies; 3+ messages in thread
From: Abbé @ 2024-02-12 20:43 UTC (permalink / raw)
  To: Carlo Zancanaro; +Cc: help-guix


[-- Attachment #1.1: Type: text/plain, Size: 1049 bytes --]

Hi Carlo,

Apologies for missing your reply, and thank you for time to reply to me.

On Tuesday, February 6th, 2024 at 1:35 PM, Carlo Zancanaro <carlo@zancanaro.id.au> wrote:

> Hi Abbé,
> 

> On Mon, Feb 05 2024, Abbé wrote:
> 

> > I'm wondering how would one go about integrating shepherd with 'guix
> > home' configuration (i.e. home environment services), akin to what
> > Guix does (I believe, without needing to do 'guix home ...').

[...]
 

> Guix Home does more than just start shepherd services. It is a system
> for managing packages, configuration files, etc. If you haven't already,
> I would suggest reading "(guix) Home Configuration" in the manual.

Thanks, on careful reading, I spotted what I was missing. It works as expected now.

> 

> There isn't really anything that you can put into your Shepherd config
> to execute your Home configuration. It goes the other way: instantiating
> your Home config will start a Shepherd process.
> 

> I hope that helps,
> 

> Carlo

Thanks!
--
Abbé

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 509 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-02-12 20:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-05 15:00 Running guix home + shepherd in non-Guix OS Abbé
2024-02-06 12:35 ` Carlo Zancanaro
2024-02-12 20:43   ` Abbé

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).