diff --git a/modules/rosenthal/services/web.scm b/modules/rosenthal/services/web.scm index e239a15..bb865f1 100644 --- a/modules/rosenthal/services/web.scm +++ b/modules/rosenthal/services/web.scm @@ -185,7 +185,7 @@ reload its configuration file.")) (string "/var/lib/conduit") "") (config - file-like + gexp "") ;; Account (group-id @@ -235,20 +235,21 @@ reload its configuration file.")) (define conduit-shepherd (match-record-lambda (conduit config auto-start? shepherd-provision shepherd-requirement) - (list (shepherd-service - (provision shepherd-provision) - (requirement `(networking user-processes ,@shepherd-requirement)) - (start - #~(make-forkexec-constructor - (list #$conduit) - #:user "conduit" - #:group "conduit" - #:log-file "/var/log/conduit.log" - #:environment-variables - (list (string-append "CONDUIT_CONFIG=" #$config)))) - (stop #~(make-kill-destructor)) - (actions - (list (shepherd-configuration-action config))))))) + (let ((config-file (toml-file "conduit.toml" config))) + (list (shepherd-service + (provision shepherd-provision) + (requirement `(networking user-processes ,@shepherd-requirement)) + (start + #~(make-forkexec-constructor + (list #$conduit) + #:user "conduit" + #:group "conduit" + #:log-file "/var/log/conduit.log" + #:environment-variables + (list (string-append "CONDUIT_CONFIG=" #$config-file)))) + (stop #~(make-kill-destructor)) + (actions + (list (shepherd-configuration-action config-file)))))))) (define conduit-service-type (service-type @@ -384,7 +385,7 @@ reload its configuration file.")) (file-like iocaine) "") (config - file-object + gexp "") (log-file (string "/var/log/iocaine.log") @@ -425,7 +426,7 @@ reload its configuration file.")) (define iocaine-etc (match-record-lambda (config) - `(("iocaine/iocaine.toml" ,config)))) + `(("iocaine/iocaine.toml" ,(toml-file "iocaine.toml" config))))) (define iocaine-shepherd-service (match-record-lambda @@ -743,8 +744,8 @@ test its configuration file.")) (auto-start? (boolean #t) "") - (extra-config - (string "") + (config + (gexp #~'()) "") (no-serialization)) @@ -765,14 +766,13 @@ test its configuration file.")) (define navidrome-shepherd-service (match-record-lambda - (navidrome ffmpeg auto-start? extra-config) + (navidrome ffmpeg auto-start? config) (let ((config-file - (mixed-text-file - "navidrome.toml" - "DataFolder = '/var/lib/navidrome'\n" - "CacheFolder = '/var/lib/navidrome/cache'\n" - "EnableInsightsCollector = false\n" - extra-config))) + (toml-file "navidrome.toml" + #~`(("DataFolder" . "/var/lib/navidrome") + ("CacheFolder" . "/var/lib/navidrome/cache") + ("EnableInsightsCollector" . #f) + ,@#$config)))) (list (shepherd-service (documentation "Run Navidrome.") (provision '(navidrome)) diff --git a/modules/rosenthal/utils/file.scm b/modules/rosenthal/utils/file.scm index 56c293a..53cd238 100644 --- a/modules/rosenthal/utils/file.scm +++ b/modules/rosenthal/utils/file.scm @@ -9,12 +9,14 @@ ;; Guix packages #:use-module (gnu packages guile) #:use-module (gnu packages guile-xyz) + #:use-module (rosenthal packages guile-xyz) #:export (computed-substitution-with-inputs file-content hidden-desktop-entry ini-file json-file + toml-file yaml-file)) ;; XXX: ‘substitute*’ doesn't fully support Unicode: @@ -80,6 +82,19 @@ format." (call-with-output-file #$output (cut scm->json #$exp <> #:pretty #t)))))) +;; https://github.com/hylophile/guile-toml +;; TODO: TOML writing support is incomplete. +;; See https://github.com/hylophile/guile-toml/blob/main/toml/builder.scm. +(define (toml-file name exp) + "Return file-like object NAME, serialized from G-expression EXP in TOML +format." + (computed-file name + (with-extensions (list guile-json-4 guile-toml) + #~(begin + (use-modules (srfi srfi-26) (toml)) + (call-with-output-file #$output + (cut scm->toml #$exp <>)))))) + ;; https://gitlab.com/yorgath/guile-yamlpp (define (yaml-file name exp) "Return file-like object NAME, serialized from G-expression EXP in YAML