From f1d89d66f0c07765d559a3fab79cc3c870660b92 Mon Sep 17 00:00:00 2001 From: Hilton Chain Date: Sat, 3 Dec 2022 15:25:52 +0800 Subject: [PATCH] services: Add home-wakapi-service-type. * rosenthal/services/child-error.scm (home-wakapi-configuration) (home-wakapi-shepherd-service,home-wakapi-service-type): New variables. --- rosenthal/services/child-error.scm | 40 +++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/rosenthal/services/child-error.scm b/rosenthal/services/child-error.scm index 13a5531..5fcf1a6 100644 --- a/rosenthal/services/child-error.scm +++ b/rosenthal/services/child-error.scm @@ -18,7 +18,10 @@ clash-service-type cloudflare-tunnel-configuration - cloudflare-tunnel-service-type)) + cloudflare-tunnel-service-type + + home-wakapi-configuration + home-wakapi-service-type)) ;; Child-error: services for packages not available in Guix, currently this ;; means some Go and Rust apps I build locally but don't want to package. @@ -188,3 +191,38 @@ headers. This can expose sensitive information in your logs.") (const %cloudflare-tunnel-accounts)))) (default-value (cloudflare-tunnel-configuration)) (description "Run cloudflared, the Cloudflare Tunnel daemon."))) + + +;; +;; Wakapi +;; + + +(define-configuration/no-serialization home-wakapi-configuration + (wakapi + (string "/bin/wakapi") + "The wakapi executable.") + (config + (yaml-config '()) + "Association list of Wakapi configurations.")) + +(define home-wakapi-shepherd-service + (match-lambda + (($ wakapi config) + (let ((config-file (mixed-text-file + "wakapi.yaml" + #~(string-append #$@(serialize-yaml-config config) "\n")))) + (list (shepherd-service + (documentation "Run wakapi.") + (provision '(wakapi)) + (start #~(make-forkexec-constructor + (list #$wakapi "-config" #$config-file))))))))) + +(define home-wakapi-service-type + (service-type + (name 'home-wakapi) + (extensions + (list (service-extension home-shepherd-service-type + home-wakapi-shepherd-service))) + (default-value (home-wakapi-configuration)) + (description "Run Wakapi, a self-hosted WakaTime-compatible backend.")))