mirror of
https://codeberg.org/hako/Rosenthal.git
synced 2026-03-04 08:54:20 +00:00
utils: Add toml-file.
* modules/rosenthal/utils/file.scm (toml-file): New procedure. * modules/rosenthal/services/web.scm (conduit-shepherd, iocaine-etc) (navidrome-shepherd-service): Use it.
This commit is contained in:
parent
19a9eaa029
commit
f58f1b0583
@ -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-configuration>
|
||||
(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 <iocaine-configuration>
|
||||
(config)
|
||||
`(("iocaine/iocaine.toml" ,config))))
|
||||
`(("iocaine/iocaine.toml" ,(toml-file "iocaine.toml" config)))))
|
||||
|
||||
(define iocaine-shepherd-service
|
||||
(match-record-lambda <iocaine-configuration>
|
||||
@ -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-configuration>
|
||||
(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))
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user