help-guix
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Running guix home + shepherd in non-Guix OS


From: Abbé
Subject: Running guix home + shepherd in non-Guix OS
Date: Mon, 05 Feb 2024 15:00:48 +0000

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é




reply via email to

[Prev in Thread] Current Thread [Next in Thread]