all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Abbé <gnu.bonfire@p.atriar.ch>
To: help-guix@gnu.org
Subject: Seeking help with g-expressions maze
Date: Mon, 10 Jun 2024 04:35:09 +0000	[thread overview]
Message-ID: <171799411588.7.857514431154339738.351278683@p.atriar.ch> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 4162 bytes --]

Hi,

I'm trying to implement a guix home service module for rbw, and ended up with following:

----------------8<----------------------8<-----------------------
(define-module (abbe services rbw)
  #:use-module (guix packages)
  #:use-module (guix download)
  #:use-module (guix gexp)
  #:use-module (guix records)
  #:use-module (gnu home services)
  #:use-module (gnu home services xdg)
  #:use-module (gnu services)
  #:use-module (gnu services configuration)
  #:use-module (gnu packages gnupg)
  #:use-module (json)
  #:use-module (ice-9 match)
  #:export  (home-rbw-configuration
             home-rbw-configuration?
             home-rbw-configuration-pinentry-program
             home-rbw-configuration-email
             home-rbw-configuration-base-url
             home-rbw-configuration-identity-url
             home-rbw-configuration-notifications-url
             home-rbw-configuration-client-cert-path
             home-rbw-configuration-sync-interval
             home-rbw-configuration-lock-timeout

             home-rbw-config-files

             home-rbw-service-type))

(define-maybe string)

(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")
  (base-url
   maybe-string
   "Base URL")
  (identity-url
   maybe-string
   "Identity URL")
  (notifications-url
   maybe-string
   "Notifications URL")
  (client-cert-path
   maybe-string
   "Client certificate path")
  (sync-interval
   (integer 3600)
   "Synchronization interval")
  (lock-timeout
   (integer 3600)
   "Lock timeout"))

(define (home-rbw-config-files config)
  (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))))))
  `(("rbw/config.json" ,(home-rbw-configuration-file config))))

(define home-rbw-service-type
  (service-type
   (name 'home-rbw)
   (extensions
    (list (service-extension home-xdg-configuration-files-service-type
                             home-rbw-config-files)))
   (default-value (home-rbw-configuration))
   (description
    "Configure rbw")))
----------------8<----------------------8<-----------------------

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

Following is the service definition I'm using in my home configuration:

----------------8<----------------------8<-----------------------
     (service home-rbw-service-type
              (home-rbw-configuration))
----------------8<----------------------8<-----------------------

I'm coming from nix background, documentation on G Expressions documentation seem a bit overwhelming, akin to Haskell for a C programmer.

Any help will be appreciated.

Thanks!
--
Abbe

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 249 bytes --]

             reply	other threads:[~2024-06-10  4:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-10  4:35 Abbé [this message]
2024-06-10  7:50 ` Seeking help with g-expressions maze Christopher Baines
2024-06-10 23:23   ` Abbé

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=171799411588.7.857514431154339738.351278683@p.atriar.ch \
    --to=gnu.bonfire@p.atriar.ch \
    --cc=help-guix@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.