[Top][All Lists]

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

Re: Modification of Services with External Definitions of Clause Bodies

From: Marek Paśnikowski
Subject: Re: Modification of Services with External Definitions of Clause Bodies
Date: Sun, 26 May 2024 14:24:40 +0200

23.05.2024 14:58:16 CEST Marek Paśnikowski:
> Good day to you all.
> I am trying to achieve the following configuration pattern:
> (define-public %distribution-services
>   (modify-services %desktop-services
>                    (1-service-type config => 1-change)
>                    (2-service-type config => 2-change)
>                    (3-service-type config => 3-change)
>                    ...
>                    (n-service-type config => n-change)))
> Each k-change is to be defined in its own, external module almost like this:
> (define-public k-change
>   (lambda (config)
>     (k-service-configuration (inherit config)
>                              ...
>                              (n-customization)))
> I wrote almost, because the presented pattern still fails to execute.
> Regardless, this is the furthest I was able to go — this approach fails
> during system reconfiguration, as opposed to the other attempts which
> failed during guix pull.
> The error message:
> In procedure struct-vtable:
> Wrong type argument in posistion 1 (expecting struct):
> #<procedure k-change (config)>
> I know WHY it fails - lambdas do return procedures.  My question to you is,
> how can I modify the k-change definition to have it return the appropriate
> service configuration structure?

I missed the simplest possible type of abstraction during the initial testing 
— the humble function.  So here is the solution to my problem:

(define-public (k-change config)
  (k-service-configuration (inherit config)

(define-public %distribution-services
  (modify-services %desktop-services
                   (k-service-type config
                                   (k-change config))))

It is not as beautiful as I had aimed for, but this is compromise I must take.
Literally nothing else works.

Attachment: signature.asc
Description: This is a digitally signed message part.

reply via email to

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