help-guix
[Top][All Lists]
Advanced

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

Re: Seeking help with g-expressions maze


From: Abbé
Subject: Re: Seeking help with g-expressions maze
Date: Mon, 10 Jun 2024 23:23:03 +0000

On Monday, June 10th, 2024 at 9:50 AM, Christopher Baines <mail@cbaines.net> 
wrote:

> Abbé gnu.bonfire@p.atriar.ch writes:
> 

> > (define-configuration/no-serialization home-rbw-configuration
> > (pinentry-program
> > (file-like (file-append pinentry "/bin/pinentry-curses"))
> > "Pinentry program to use.")
> > (email
> > (string "")
> > "Email address of the user")
> 

> 

> ...
> 

> > (define (rbw-config config)
> > (match-record config <home-rbw-configuration>
> > (pinentry-program email base-url identity-url notifications-url
> > client-cert-path sync-interval lock-timeout)
> > `((pinentry-program . ,pinentry-program)
> > (email . ,email)
> > (base_url . ,base-url)
> > (identity_url . ,identity-url)
> > (notifications_url . ,notifications-url)
> > (client_cert_path . ,client-cert-path)
> > (sync_interval . ,sync-interval)
> > (lock_timeout . ,lock-timeout))))
> > (define (home-rbw-configuration-file config)
> > (let ((xformed-config (rbw-config config)))
> > (computed-file "rbw-config.json"
> > 

> > #~(call-with-output-file #$output
> > (lambda (port)
> > (display #$(scm->json-string xformed-config) port))))))
> 

> 

> Here you're calling scm->json-string on an alist containing the
> 

> file-append record for pinentry-program. scm->json-string doesn't know
> 

> how to handle that, it's invalid. Hence the exception you're getting.
> 

> > `(("rbw/config.json" ,(home-rbw-configuration-file config))))
> 

> 

> ...
> 

> > While applying this module, I end up with following obvious error, but
> > I'm not quite sure how to go about resolving this:
> > 

> > ----------------8<----------------------8<-----------------------
> > ice-9/boot-9.scm:1685:16: In procedure raise-exception:
> > Throw to key `json-invalid' with args` (#<file-append #<package 
> > pinentry@1.2.1 gnu/packages/gnupg.scm:1016 7df6139219a0> 
> > "/bin/pinentry-curses">)'.
> > ----------------8<----------------------8<-----------------------
> 

> 

> If you want to use scm->json-string, you need to be working with a data
> 

> structure it can understand, and it can't understand gexp's. That
> suggests you should run it on the build side, once the file-append
> record has been transformed in to a string.
> 

> I think this would be similar to how the transmission service in Guix
> builds it's settings.json file.

Thanks for the hint.

Abbe

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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