guix-devel
[Top][All Lists]
Advanced

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

Re: Shepherd config file and GEXP semantics


From: Ludovic Courtès
Subject: Re: Shepherd config file and GEXP semantics
Date: Sat, 05 Feb 2022 14:59:36 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)

Hi,

Attila Lendvai <attila@lendvai.name> skribis:

> (define (make-user-module)
>   (let ((m (make-fresh-user-module)))
>     ;; The typical configuration file wants to do '(make <service> ...)', and
>     ;; '(register-services ...)', so provide the relevant bindings by default.
>     (module-use! m (resolve-interface '(oop goops)))
>     (module-use! m (resolve-interface '(shepherd service)))
>     m))
>
> (define (load-in-user-module)
>   (let ((user-module (make-user-module)))
>     (save-module-excursion
>      (lambda ()
>        (set-current-module user-module)
>        (use-modules (nongnu services swarm-utils))
>
>        ;; this works, i.e. *log-directory* is not unbound upon execution:
>        ;; (eval '(lambda ()
>        ;;          *log-directory*)
>        ;;       user-module)
>
>        (lambda () *log-directory*)
>        ))))

‘use-modules’ is a macro that should only be used at the top level, even
if it sometimes works in different contexts, for now.

Instead, you should use Guile’s first-class module API (info "(guile)
Module System Reflection").  As you noticed in the code you copied from,
you would call ‘module-use!’ and similar procedures.

I don’t see which module ‘*log-directory*’ is in, though.

HTH,
Ludo’.



reply via email to

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