unofficial mirror of help-guix@gnu.org 
 help / color / mirror / Atom feed
* Modification of Services with External Definitions of Clause Bodies
@ 2024-05-23 12:58 Marek Paśnikowski
  2024-05-26 12:24 ` Marek Paśnikowski
  0 siblings, 1 reply; 2+ messages in thread
From: Marek Paśnikowski @ 2024-05-23 12:58 UTC (permalink / raw)
  To: help-guix

[-- Attachment #1: Type: text/plain, Size: 1245 bytes --]

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?

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Modification of Services with External Definitions of Clause Bodies
  2024-05-23 12:58 Modification of Services with External Definitions of Clause Bodies Marek Paśnikowski
@ 2024-05-26 12:24 ` Marek Paśnikowski
  0 siblings, 0 replies; 2+ messages in thread
From: Marek Paśnikowski @ 2024-05-26 12:24 UTC (permalink / raw)
  To: help-guix

[-- Attachment #1: Type: text/plain, Size: 1993 bytes --]

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)
                           ...
                           (n-field)))

(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 #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-05-26 12:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-23 12:58 Modification of Services with External Definitions of Clause Bodies Marek Paśnikowski
2024-05-26 12:24 ` Marek Paśnikowski

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