unofficial mirror of help-guix@gnu.org 
 help / color / mirror / Atom feed
* Seeking help with g-expressions maze
@ 2024-06-10  4:35 Abbé
  2024-06-10  7:50 ` Christopher Baines
  0 siblings, 1 reply; 3+ messages in thread
From: Abbé @ 2024-06-10  4:35 UTC (permalink / raw)
  To: help-guix


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

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

end of thread, other threads:[~2024-06-10 23:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-10  4:35 Seeking help with g-expressions maze Abbé
2024-06-10  7:50 ` Christopher Baines
2024-06-10 23:23   ` Abbé

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