mirror of
https://codeberg.org/hako/Rosenthal.git
synced 2026-03-04 17:04:21 +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")
|
(string "/var/lib/conduit")
|
||||||
"")
|
"")
|
||||||
(config
|
(config
|
||||||
file-like
|
gexp
|
||||||
"")
|
"")
|
||||||
;; Account
|
;; Account
|
||||||
(group-id
|
(group-id
|
||||||
@ -235,20 +235,21 @@ reload its configuration file."))
|
|||||||
(define conduit-shepherd
|
(define conduit-shepherd
|
||||||
(match-record-lambda <conduit-configuration>
|
(match-record-lambda <conduit-configuration>
|
||||||
(conduit config auto-start? shepherd-provision shepherd-requirement)
|
(conduit config auto-start? shepherd-provision shepherd-requirement)
|
||||||
(list (shepherd-service
|
(let ((config-file (toml-file "conduit.toml" config)))
|
||||||
(provision shepherd-provision)
|
(list (shepherd-service
|
||||||
(requirement `(networking user-processes ,@shepherd-requirement))
|
(provision shepherd-provision)
|
||||||
(start
|
(requirement `(networking user-processes ,@shepherd-requirement))
|
||||||
#~(make-forkexec-constructor
|
(start
|
||||||
(list #$conduit)
|
#~(make-forkexec-constructor
|
||||||
#:user "conduit"
|
(list #$conduit)
|
||||||
#:group "conduit"
|
#:user "conduit"
|
||||||
#:log-file "/var/log/conduit.log"
|
#:group "conduit"
|
||||||
#:environment-variables
|
#:log-file "/var/log/conduit.log"
|
||||||
(list (string-append "CONDUIT_CONFIG=" #$config))))
|
#:environment-variables
|
||||||
(stop #~(make-kill-destructor))
|
(list (string-append "CONDUIT_CONFIG=" #$config-file))))
|
||||||
(actions
|
(stop #~(make-kill-destructor))
|
||||||
(list (shepherd-configuration-action config)))))))
|
(actions
|
||||||
|
(list (shepherd-configuration-action config-file))))))))
|
||||||
|
|
||||||
(define conduit-service-type
|
(define conduit-service-type
|
||||||
(service-type
|
(service-type
|
||||||
@ -384,7 +385,7 @@ reload its configuration file."))
|
|||||||
(file-like iocaine)
|
(file-like iocaine)
|
||||||
"")
|
"")
|
||||||
(config
|
(config
|
||||||
file-object
|
gexp
|
||||||
"")
|
"")
|
||||||
(log-file
|
(log-file
|
||||||
(string "/var/log/iocaine.log")
|
(string "/var/log/iocaine.log")
|
||||||
@ -425,7 +426,7 @@ reload its configuration file."))
|
|||||||
(define iocaine-etc
|
(define iocaine-etc
|
||||||
(match-record-lambda <iocaine-configuration>
|
(match-record-lambda <iocaine-configuration>
|
||||||
(config)
|
(config)
|
||||||
`(("iocaine/iocaine.toml" ,config))))
|
`(("iocaine/iocaine.toml" ,(toml-file "iocaine.toml" config)))))
|
||||||
|
|
||||||
(define iocaine-shepherd-service
|
(define iocaine-shepherd-service
|
||||||
(match-record-lambda <iocaine-configuration>
|
(match-record-lambda <iocaine-configuration>
|
||||||
@ -743,8 +744,8 @@ test its configuration file."))
|
|||||||
(auto-start?
|
(auto-start?
|
||||||
(boolean #t)
|
(boolean #t)
|
||||||
"")
|
"")
|
||||||
(extra-config
|
(config
|
||||||
(string "")
|
(gexp #~'())
|
||||||
"")
|
"")
|
||||||
(no-serialization))
|
(no-serialization))
|
||||||
|
|
||||||
@ -765,14 +766,13 @@ test its configuration file."))
|
|||||||
|
|
||||||
(define navidrome-shepherd-service
|
(define navidrome-shepherd-service
|
||||||
(match-record-lambda <navidrome-configuration>
|
(match-record-lambda <navidrome-configuration>
|
||||||
(navidrome ffmpeg auto-start? extra-config)
|
(navidrome ffmpeg auto-start? config)
|
||||||
(let ((config-file
|
(let ((config-file
|
||||||
(mixed-text-file
|
(toml-file "navidrome.toml"
|
||||||
"navidrome.toml"
|
#~`(("DataFolder" . "/var/lib/navidrome")
|
||||||
"DataFolder = '/var/lib/navidrome'\n"
|
("CacheFolder" . "/var/lib/navidrome/cache")
|
||||||
"CacheFolder = '/var/lib/navidrome/cache'\n"
|
("EnableInsightsCollector" . #f)
|
||||||
"EnableInsightsCollector = false\n"
|
,@#$config))))
|
||||||
extra-config)))
|
|
||||||
(list (shepherd-service
|
(list (shepherd-service
|
||||||
(documentation "Run Navidrome.")
|
(documentation "Run Navidrome.")
|
||||||
(provision '(navidrome))
|
(provision '(navidrome))
|
||||||
|
|||||||
@ -9,12 +9,14 @@
|
|||||||
;; Guix packages
|
;; Guix packages
|
||||||
#:use-module (gnu packages guile)
|
#:use-module (gnu packages guile)
|
||||||
#:use-module (gnu packages guile-xyz)
|
#:use-module (gnu packages guile-xyz)
|
||||||
|
#:use-module (rosenthal packages guile-xyz)
|
||||||
#:export (computed-substitution-with-inputs
|
#:export (computed-substitution-with-inputs
|
||||||
file-content
|
file-content
|
||||||
hidden-desktop-entry
|
hidden-desktop-entry
|
||||||
|
|
||||||
ini-file
|
ini-file
|
||||||
json-file
|
json-file
|
||||||
|
toml-file
|
||||||
yaml-file))
|
yaml-file))
|
||||||
|
|
||||||
;; XXX: ‘substitute*’ doesn't fully support Unicode:
|
;; XXX: ‘substitute*’ doesn't fully support Unicode:
|
||||||
@ -80,6 +82,19 @@ format."
|
|||||||
(call-with-output-file #$output
|
(call-with-output-file #$output
|
||||||
(cut scm->json #$exp <> #:pretty #t))))))
|
(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
|
;; https://gitlab.com/yorgath/guile-yamlpp
|
||||||
(define (yaml-file name exp)
|
(define (yaml-file name exp)
|
||||||
"Return file-like object NAME, serialized from G-expression EXP in YAML
|
"Return file-like object NAME, serialized from G-expression EXP in YAML
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user