Hilton Chain <[email protected]> writes:
> Hilton Chain <[email protected]> writes:
>
>> On Wed, 02 Apr 2025 23:46:51 +0800,
>> Rutherther wrote:
>>>
>>>
>>> Hello Hilton,
>>>
>>> Hilton Chain <[email protected]> writes:
>>>
>>> >
>>> > 2. Need of manually exposing interfaces. e.g. those from
>>> > shepherd-service.
>>> >
>>>
>>> I feel like this has been a topic mentioned multiple times in the last
>>> few weeks on this mailing list. Here I have e-mail from Carlo Zancanaro
>>> in mind, "Configuring shepherd services belonging to system services" (I
>>> don't know how to 'mention' e-mails in a good way, if you have tips,
>>> please do share them),
>>> where also this patch https://issues.guix.gnu.org/27155 has been
>>> mentioned.
>>>
>>> I think it's a pity we don't have a generic solution merged yet,
>>> especially given the patch that is 8 years old and Ludo mentions in it
>>> "It was long overdue.", I agree.
>>> The general finalizer approach would allow for exposing further
>>> procedures that would alter the services after they are made, things
>>> like this would become possible to do easily and we could build on it
>>> further, functions like '(finalize-shepherd-service "service" (lambda
>>> (config) (.. (inherit (config)))))' and more specific ones like
>>> (shepherd-override-auto-start? #f)'.
>>>
>>> Regards,
>>> Rutherther
>>
> Instead of alist, I tried to use the current configuration interface,
> but with service extensions exposed.
Actually it can be turned into a procedure (and maybe a macro like
modify-services) which avoids the repetitive task. This approach has
its own issues, I added them as comments below:
--8<---------------cut here---------------start------------->8---
(define (modify-extension kind target transformer services)
(map (lambda (%service)
(if (eq? kind (service-kind %service))
(service
;; XXX: This creates new service type objects and may break
;; current ‘modify-services’.
(service-type
(inherit kind)
(extensions
(map (lambda (%extension)
(if (eq? target (service-extension-target
%extension))
(service-extension
target
;; XXX: Transformed extensions won't honor
;; modifications to the configuration fields.
(transformer
((service-extension-compute %extension)
(service-value %service))))
%extension))
(service-type-extensions kind))))
(service-value %service))
%service))
services))
--8<---------------cut here---------------end--------------->8---
--8<---------------cut here---------------start------------->8---
(modify-extension guix-service-type
shepherd-root-service-type
(lambda (extension)
(const
(map (lambda (service)
(if (member 'guix-daemon (shepherd-service-provision service))
(shepherd-service
(inherit service)
(provision (cons 'test (shepherd-service-provision service)))
(auto-start? #f))
service))
extension)))
%desktop-services)
--8<---------------cut here---------------end--------------->8---