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

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).