mirror of
https://codeberg.org/hako/Rosenthal.git
synced 2026-08-12 15:50:15 +00:00
utils: Add file-object-or-file-config?.
This commit is contained in:
parent
c660951855
commit
05f69100c3
@ -274,14 +274,17 @@ headers. This can expose sensitive information in your logs.")
|
|||||||
(file-like wakapi-bin)
|
(file-like wakapi-bin)
|
||||||
"The wakapi package.")
|
"The wakapi package.")
|
||||||
(config
|
(config
|
||||||
gexp
|
file-object-or-file-config
|
||||||
"Association list of Wakapi configurations.")
|
"Association list of Wakapi configurations.")
|
||||||
(no-serialization))
|
(no-serialization))
|
||||||
|
|
||||||
(define home-wakapi-shepherd-service
|
(define home-wakapi-shepherd-service
|
||||||
(match-record-lambda <home-wakapi-configuration>
|
(match-record-lambda <home-wakapi-configuration>
|
||||||
(wakapi config)
|
(wakapi config)
|
||||||
(let ((config-file (yaml-file "wakapi.yaml" config)))
|
(let ((config-file
|
||||||
|
(if (file-config? config)
|
||||||
|
(yaml-file "wakapi.yaml" config)
|
||||||
|
config)))
|
||||||
(list (shepherd-service
|
(list (shepherd-service
|
||||||
(documentation "Run wakapi.")
|
(documentation "Run wakapi.")
|
||||||
(provision '(wakapi))
|
(provision '(wakapi))
|
||||||
|
|||||||
@ -7,6 +7,7 @@
|
|||||||
#:use-module (guix packages)
|
#:use-module (guix packages)
|
||||||
#:use-module (guix records)
|
#:use-module (guix records)
|
||||||
#:use-module (rosenthal utils file)
|
#:use-module (rosenthal utils file)
|
||||||
|
#:use-module (rosenthal utils predicates)
|
||||||
;; Guix System
|
;; Guix System
|
||||||
#:use-module (gnu system accounts)
|
#:use-module (gnu system accounts)
|
||||||
#:use-module (gnu system shadow)
|
#:use-module (gnu system shadow)
|
||||||
@ -19,14 +20,14 @@
|
|||||||
#:export (gamemode-service-type
|
#:export (gamemode-service-type
|
||||||
gamemode-configuration))
|
gamemode-configuration))
|
||||||
|
|
||||||
(define-maybe gexp)
|
(define-maybe file-object-or-file-config)
|
||||||
|
|
||||||
(define-configuration/no-serialization gamemode-configuration
|
(define-configuration/no-serialization gamemode-configuration
|
||||||
(gamemode
|
(gamemode
|
||||||
(file-like gamemode)
|
(file-like gamemode)
|
||||||
"@code{gamemode} package to use.")
|
"@code{gamemode} package to use.")
|
||||||
(config
|
(config
|
||||||
maybe-gexp
|
maybe-file-object-or-file-config
|
||||||
""))
|
""))
|
||||||
|
|
||||||
(define (gamemode-account-service config)
|
(define (gamemode-account-service config)
|
||||||
@ -39,7 +40,9 @@
|
|||||||
(gamemode config)
|
(gamemode config)
|
||||||
`(("gamemode.ini"
|
`(("gamemode.ini"
|
||||||
,(if (maybe-value-set? config)
|
,(if (maybe-value-set? config)
|
||||||
|
(if (file-config? config)
|
||||||
(ini-file "gamemode.ini" config)
|
(ini-file "gamemode.ini" config)
|
||||||
|
config)
|
||||||
(file-append (package-source gamemode) "/example/gamemode.ini")))
|
(file-append (package-source gamemode) "/example/gamemode.ini")))
|
||||||
("security/limits.d/10-gamemode.conf"
|
("security/limits.d/10-gamemode.conf"
|
||||||
,(file-append gamemode "/etc/security/limits.d/10-gamemode.conf")))))
|
,(file-append gamemode "/etc/security/limits.d/10-gamemode.conf")))))
|
||||||
|
|||||||
@ -8,6 +8,7 @@
|
|||||||
#:use-module (guix gexp)
|
#:use-module (guix gexp)
|
||||||
#:use-module (guix records)
|
#:use-module (guix records)
|
||||||
#:use-module (rosenthal utils file)
|
#:use-module (rosenthal utils file)
|
||||||
|
#:use-module (rosenthal utils predicates)
|
||||||
;; Guix System - services
|
;; Guix System - services
|
||||||
#:use-module (gnu services)
|
#:use-module (gnu services)
|
||||||
#:use-module (gnu services admin)
|
#:use-module (gnu services admin)
|
||||||
@ -91,7 +92,7 @@
|
|||||||
(file-like goimapnotify)
|
(file-like goimapnotify)
|
||||||
"")
|
"")
|
||||||
(config
|
(config
|
||||||
gexp
|
file-object-or-file-config
|
||||||
"")
|
"")
|
||||||
(wait
|
(wait
|
||||||
(integer 1)
|
(integer 1)
|
||||||
@ -109,7 +110,10 @@
|
|||||||
(define home-goimapnotify-shepherd
|
(define home-goimapnotify-shepherd
|
||||||
(match-record-lambda <home-goimapnotify-configuration>
|
(match-record-lambda <home-goimapnotify-configuration>
|
||||||
(goimapnotify config wait shepherd-provision shepherd-requirement auto-start?)
|
(goimapnotify config wait shepherd-provision shepherd-requirement auto-start?)
|
||||||
(let ((config-file (yaml-file "goimapnotify.yaml" config)))
|
(let ((config-file
|
||||||
|
(if (file-config? config)
|
||||||
|
(yaml-file "goimapnotify.yaml" config)
|
||||||
|
config)))
|
||||||
(list (shepherd-service
|
(list (shepherd-service
|
||||||
(provision shepherd-provision)
|
(provision shepherd-provision)
|
||||||
(requirement shepherd-requirement)
|
(requirement shepherd-requirement)
|
||||||
|
|||||||
@ -34,7 +34,7 @@
|
|||||||
(string "http://localhost:8008")
|
(string "http://localhost:8008")
|
||||||
"")
|
"")
|
||||||
(config
|
(config
|
||||||
file-like
|
file-object-or-file-config
|
||||||
"")
|
"")
|
||||||
(group-id
|
(group-id
|
||||||
(user-and-group-id #f)
|
(user-and-group-id #f)
|
||||||
@ -69,13 +69,17 @@
|
|||||||
(define heisenbridge-shepherd
|
(define heisenbridge-shepherd
|
||||||
(match-record-lambda <heisenbridge-configuration>
|
(match-record-lambda <heisenbridge-configuration>
|
||||||
(heisenbridge config homeserver shepherd-provision shepherd-requirement auto-start?)
|
(heisenbridge config homeserver shepherd-provision shepherd-requirement auto-start?)
|
||||||
|
(let ((config-file
|
||||||
|
(if (file-config? config)
|
||||||
|
(yaml-file "heisenbridge.yaml" config)
|
||||||
|
config)))
|
||||||
(list (shepherd-service
|
(list (shepherd-service
|
||||||
(provision shepherd-provision)
|
(provision shepherd-provision)
|
||||||
(requirement `(user-processes networking ,@shepherd-requirement))
|
(requirement `(user-processes networking ,@shepherd-requirement))
|
||||||
(start
|
(start
|
||||||
#~(make-forkexec-constructor
|
#~(make-forkexec-constructor
|
||||||
(list #$(file-append heisenbridge "/bin/heisenbridge")
|
(list #$(file-append heisenbridge "/bin/heisenbridge")
|
||||||
"--config" #$config #$homeserver)
|
"--config" #$config-file #$homeserver)
|
||||||
#:user "heisenbridge"
|
#:user "heisenbridge"
|
||||||
#:group "heisenbridge"
|
#:group "heisenbridge"
|
||||||
#:environment-variables
|
#:environment-variables
|
||||||
@ -84,7 +88,7 @@
|
|||||||
"SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt")))
|
"SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt")))
|
||||||
(stop #~(make-kill-destructor))
|
(stop #~(make-kill-destructor))
|
||||||
(auto-start? auto-start?)
|
(auto-start? auto-start?)
|
||||||
(actions (list (shepherd-configuration-action config)))))))
|
(actions (list (shepherd-configuration-action config-file))))))))
|
||||||
|
|
||||||
(define heisenbridge-service-type
|
(define heisenbridge-service-type
|
||||||
(service-type
|
(service-type
|
||||||
@ -106,7 +110,7 @@
|
|||||||
(file-like mautrix-telegram)
|
(file-like mautrix-telegram)
|
||||||
"")
|
"")
|
||||||
(config
|
(config
|
||||||
file-like
|
file-object-or-file-config
|
||||||
"")
|
"")
|
||||||
(group-id
|
(group-id
|
||||||
(user-and-group-id #f)
|
(user-and-group-id #f)
|
||||||
@ -153,6 +157,10 @@
|
|||||||
(define mautrix-telegram-shepherd
|
(define mautrix-telegram-shepherd
|
||||||
(match-record-lambda <mautrix-telegram-configuration>
|
(match-record-lambda <mautrix-telegram-configuration>
|
||||||
(mautrix-telegram config shepherd-provision shepherd-requirement auto-start?)
|
(mautrix-telegram config shepherd-provision shepherd-requirement auto-start?)
|
||||||
|
(let ((config-file
|
||||||
|
(if (file-config? config)
|
||||||
|
(yaml-file "mautrix-telegram.yaml" config)
|
||||||
|
config)))
|
||||||
(list (shepherd-service
|
(list (shepherd-service
|
||||||
(provision shepherd-provision)
|
(provision shepherd-provision)
|
||||||
(requirement
|
(requirement
|
||||||
@ -160,13 +168,13 @@
|
|||||||
(start
|
(start
|
||||||
#~(make-forkexec-constructor
|
#~(make-forkexec-constructor
|
||||||
(list #$(file-append mautrix-telegram "/bin/mautrix-telegram")
|
(list #$(file-append mautrix-telegram "/bin/mautrix-telegram")
|
||||||
"--no-update" "--config" #$config)
|
"--no-update" "--config" #$config-file)
|
||||||
#:user "mautrix-telegram"
|
#:user "mautrix-telegram"
|
||||||
#:group "mautrix-telegram"
|
#:group "mautrix-telegram"
|
||||||
#:directory "/var/lib/mautrix-telegram"))
|
#:directory "/var/lib/mautrix-telegram"))
|
||||||
(stop #~(make-kill-destructor))
|
(stop #~(make-kill-destructor))
|
||||||
(auto-start? auto-start?)
|
(auto-start? auto-start?)
|
||||||
(actions (list (shepherd-configuration-action config)))))))
|
(actions (list (shepherd-configuration-action config-file))))))))
|
||||||
|
|
||||||
(define mautrix-telegram-service-type
|
(define mautrix-telegram-service-type
|
||||||
(service-type
|
(service-type
|
||||||
|
|||||||
@ -98,7 +98,7 @@
|
|||||||
(file-like grafana-bin)
|
(file-like grafana-bin)
|
||||||
"")
|
"")
|
||||||
(config
|
(config
|
||||||
gexp
|
file-object-or-file-config
|
||||||
"")
|
"")
|
||||||
(postgresql-password-file
|
(postgresql-password-file
|
||||||
string
|
string
|
||||||
@ -157,7 +157,10 @@
|
|||||||
(define grafana-shepherd
|
(define grafana-shepherd
|
||||||
(match-record-lambda <grafana-configuration>
|
(match-record-lambda <grafana-configuration>
|
||||||
(grafana config shepherd-provision shepherd-requirement auto-start?)
|
(grafana config shepherd-provision shepherd-requirement auto-start?)
|
||||||
(let ((config-file (ini-file "grafana.ini" config)))
|
(let ((config-file
|
||||||
|
(if (file-config? config)
|
||||||
|
(ini-file "grafana.ini" config)
|
||||||
|
config)))
|
||||||
(list (shepherd-service
|
(list (shepherd-service
|
||||||
(provision shepherd-provision)
|
(provision shepherd-provision)
|
||||||
(requirement `(loopback postgresql user-processes
|
(requirement `(loopback postgresql user-processes
|
||||||
@ -197,7 +200,7 @@
|
|||||||
(file-like loki-bin)
|
(file-like loki-bin)
|
||||||
"")
|
"")
|
||||||
(config
|
(config
|
||||||
gexp
|
file-object-or-file-config
|
||||||
"")
|
"")
|
||||||
(group-id
|
(group-id
|
||||||
(user-and-group-id #f)
|
(user-and-group-id #f)
|
||||||
@ -244,7 +247,10 @@
|
|||||||
(define loki-shepherd
|
(define loki-shepherd
|
||||||
(match-record-lambda <loki-configuration>
|
(match-record-lambda <loki-configuration>
|
||||||
(loki config shepherd-provision shepherd-requirement auto-start?)
|
(loki config shepherd-provision shepherd-requirement auto-start?)
|
||||||
(let ((config-file (yaml-file "loki.yaml" config)))
|
(let ((config-file
|
||||||
|
(if (file-config? config)
|
||||||
|
(yaml-file "loki.yaml" config)
|
||||||
|
config)))
|
||||||
(list (shepherd-service
|
(list (shepherd-service
|
||||||
(provision shepherd-provision)
|
(provision shepherd-provision)
|
||||||
(requirement `(loopback user-processes ,@shepherd-requirement))
|
(requirement `(loopback user-processes ,@shepherd-requirement))
|
||||||
@ -281,7 +287,7 @@
|
|||||||
(file-like mimir-bin)
|
(file-like mimir-bin)
|
||||||
"")
|
"")
|
||||||
(config
|
(config
|
||||||
gexp
|
file-object-or-file-config
|
||||||
"")
|
"")
|
||||||
(group-id
|
(group-id
|
||||||
(user-and-group-id #f)
|
(user-and-group-id #f)
|
||||||
@ -328,7 +334,10 @@
|
|||||||
(define mimir-shepherd
|
(define mimir-shepherd
|
||||||
(match-record-lambda <mimir-configuration>
|
(match-record-lambda <mimir-configuration>
|
||||||
(mimir config shepherd-provision shepherd-requirement auto-start?)
|
(mimir config shepherd-provision shepherd-requirement auto-start?)
|
||||||
(let ((config-file (yaml-file "mimir.yaml" config)))
|
(let ((config-file
|
||||||
|
(if (file-config? config)
|
||||||
|
(yaml-file "mimir.yaml" config)
|
||||||
|
config)))
|
||||||
(list (shepherd-service
|
(list (shepherd-service
|
||||||
(provision shepherd-provision)
|
(provision shepherd-provision)
|
||||||
(requirement `(loopback user-processes ,@shepherd-requirement))
|
(requirement `(loopback user-processes ,@shepherd-requirement))
|
||||||
@ -368,7 +377,7 @@
|
|||||||
(string "0.0.0.0:9090")
|
(string "0.0.0.0:9090")
|
||||||
"")
|
"")
|
||||||
(config
|
(config
|
||||||
gexp
|
file-object-or-file-config
|
||||||
"")
|
"")
|
||||||
(group-id
|
(group-id
|
||||||
(user-and-group-id #f)
|
(user-and-group-id #f)
|
||||||
@ -415,7 +424,10 @@
|
|||||||
(define prometheus-shepherd
|
(define prometheus-shepherd
|
||||||
(match-record-lambda <prometheus-configuration>
|
(match-record-lambda <prometheus-configuration>
|
||||||
(prometheus listen-address config shepherd-provision shepherd-requirement auto-start?)
|
(prometheus listen-address config shepherd-provision shepherd-requirement auto-start?)
|
||||||
(let ((config-file (yaml-file "prometheus.yml" config)))
|
(let ((config-file
|
||||||
|
(if (file-config? config)
|
||||||
|
(yaml-file "prometheus.yml" config)
|
||||||
|
config)))
|
||||||
(list (shepherd-service
|
(list (shepherd-service
|
||||||
(provision shepherd-provision)
|
(provision shepherd-provision)
|
||||||
(requirement `(loopback user-processes ,@shepherd-requirement))
|
(requirement `(loopback user-processes ,@shepherd-requirement))
|
||||||
|
|||||||
@ -178,7 +178,7 @@
|
|||||||
(list-of-file-likes (list git git-lfs))
|
(list-of-file-likes (list git git-lfs))
|
||||||
"@code{git} and extension packages to install.")
|
"@code{git} and extension packages to install.")
|
||||||
(config
|
(config
|
||||||
gexp
|
file-object-or-file-config
|
||||||
"")
|
"")
|
||||||
(postgresql-password-file
|
(postgresql-password-file
|
||||||
string
|
string
|
||||||
@ -228,7 +228,10 @@
|
|||||||
(define forgejo-shepherd-service
|
(define forgejo-shepherd-service
|
||||||
(match-record-lambda <forgejo-configuration>
|
(match-record-lambda <forgejo-configuration>
|
||||||
(forgejo config)
|
(forgejo config)
|
||||||
(let ((config-file (ini-file "forgejo.ini" config)))
|
(let ((config-file
|
||||||
|
(if (file-config? config)
|
||||||
|
(ini-file "forgejo.ini" config)
|
||||||
|
config)))
|
||||||
(list (shepherd-service
|
(list (shepherd-service
|
||||||
(documentation "Run Forgejo.")
|
(documentation "Run Forgejo.")
|
||||||
(provision '(forgejo))
|
(provision '(forgejo))
|
||||||
@ -282,7 +285,7 @@
|
|||||||
(file-like iocaine)
|
(file-like iocaine)
|
||||||
"")
|
"")
|
||||||
(config
|
(config
|
||||||
gexp
|
file-object-or-file-config
|
||||||
"")
|
"")
|
||||||
(log-file
|
(log-file
|
||||||
(string "/var/log/iocaine.log")
|
(string "/var/log/iocaine.log")
|
||||||
@ -323,7 +326,10 @@
|
|||||||
(define iocaine-etc
|
(define iocaine-etc
|
||||||
(match-record-lambda <iocaine-configuration>
|
(match-record-lambda <iocaine-configuration>
|
||||||
(config)
|
(config)
|
||||||
`(("iocaine/iocaine.toml" ,(toml-file "iocaine.toml" config)))))
|
`(("iocaine/iocaine.toml"
|
||||||
|
,(if (file-config? config)
|
||||||
|
(toml-file "iocaine.toml" config)
|
||||||
|
config)))))
|
||||||
|
|
||||||
(define iocaine-shepherd-service
|
(define iocaine-shepherd-service
|
||||||
(match-record-lambda <iocaine-configuration>
|
(match-record-lambda <iocaine-configuration>
|
||||||
@ -541,7 +547,7 @@ test its configuration file."))
|
|||||||
(string "misskey/misskey:latest")
|
(string "misskey/misskey:latest")
|
||||||
"Misskey docker image to use.")
|
"Misskey docker image to use.")
|
||||||
(config
|
(config
|
||||||
gexp
|
file-object-or-file-config
|
||||||
"Alist of Misskey configuration, to be serialized to YAML format.")
|
"Alist of Misskey configuration, to be serialized to YAML format.")
|
||||||
(data-directory
|
(data-directory
|
||||||
(string "/var/lib/misskey")
|
(string "/var/lib/misskey")
|
||||||
@ -589,7 +595,10 @@ test its configuration file."))
|
|||||||
(define misskey-oci
|
(define misskey-oci
|
||||||
(match-record-lambda <misskey-configuration>
|
(match-record-lambda <misskey-configuration>
|
||||||
(image config data-directory log-file )
|
(image config data-directory log-file )
|
||||||
(let ((config-file (yaml-file "misskey.yaml" config)))
|
(let ((config-file
|
||||||
|
(if (file-config? config)
|
||||||
|
(yaml-file "misskey.yaml" config)
|
||||||
|
config)))
|
||||||
(oci-extension
|
(oci-extension
|
||||||
(containers
|
(containers
|
||||||
(list (oci-container-configuration
|
(list (oci-container-configuration
|
||||||
@ -642,7 +651,7 @@ test its configuration file."))
|
|||||||
(boolean #t)
|
(boolean #t)
|
||||||
"")
|
"")
|
||||||
(config
|
(config
|
||||||
(gexp #~'())
|
(file-object-or-file-config #~'())
|
||||||
"")
|
"")
|
||||||
(no-serialization))
|
(no-serialization))
|
||||||
|
|
||||||
@ -665,11 +674,16 @@ test its configuration file."))
|
|||||||
(match-record-lambda <navidrome-configuration>
|
(match-record-lambda <navidrome-configuration>
|
||||||
(navidrome ffmpeg auto-start? config)
|
(navidrome ffmpeg auto-start? config)
|
||||||
(let ((config-file
|
(let ((config-file
|
||||||
|
(if (file-config? config)
|
||||||
(toml-file "navidrome.toml"
|
(toml-file "navidrome.toml"
|
||||||
#~`(("DataFolder" . "/var/lib/navidrome")
|
(let ((default-settings
|
||||||
|
'(("DataFolder" . "/var/lib/navidrome")
|
||||||
("CacheFolder" . "/var/lib/navidrome/cache")
|
("CacheFolder" . "/var/lib/navidrome/cache")
|
||||||
("EnableInsightsCollector" . #f)
|
("EnableInsightsCollector" . #f))))
|
||||||
,@#$config))))
|
(if (gexp? config)
|
||||||
|
#~(append #$default-settings #$config)
|
||||||
|
(append default-settings config))))
|
||||||
|
config)))
|
||||||
(list (shepherd-service
|
(list (shepherd-service
|
||||||
(documentation "Run Navidrome.")
|
(documentation "Run Navidrome.")
|
||||||
(provision '(navidrome))
|
(provision '(navidrome))
|
||||||
@ -714,7 +728,7 @@ test its configuration file."))
|
|||||||
(string "/var/lib/tuwunel")
|
(string "/var/lib/tuwunel")
|
||||||
"Directory to create for @code{tuwunel} user.")
|
"Directory to create for @code{tuwunel} user.")
|
||||||
(config
|
(config
|
||||||
gexp
|
file-object-or-file-config
|
||||||
"Configuration file in @code{toml-file} format.")
|
"Configuration file in @code{toml-file} format.")
|
||||||
;; Account
|
;; Account
|
||||||
(group-id
|
(group-id
|
||||||
@ -758,7 +772,10 @@ test its configuration file."))
|
|||||||
(define tuwunel-shepherd
|
(define tuwunel-shepherd
|
||||||
(match-record-lambda <tuwunel-configuration>
|
(match-record-lambda <tuwunel-configuration>
|
||||||
(tuwunel config auto-start? shepherd-requirement)
|
(tuwunel config auto-start? shepherd-requirement)
|
||||||
(let ((config-file (toml-file "tuwunel.toml" config)))
|
(let ((config-file
|
||||||
|
(if (file-config? config)
|
||||||
|
(toml-file "tuwunel.toml" config)
|
||||||
|
config)))
|
||||||
(list (shepherd-service
|
(list (shepherd-service
|
||||||
(provision '(tuwunel))
|
(provision '(tuwunel))
|
||||||
(requirement `(networking user-processes ,@shepherd-requirement))
|
(requirement `(networking user-processes ,@shepherd-requirement))
|
||||||
|
|||||||
@ -5,12 +5,23 @@
|
|||||||
;; Utilities
|
;; Utilities
|
||||||
#:use-module (guix gexp)
|
#:use-module (guix gexp)
|
||||||
#:export (file-object?
|
#:export (file-object?
|
||||||
|
file-config?
|
||||||
|
file-object-or-file-config?
|
||||||
user-and-group-id?))
|
user-and-group-id?))
|
||||||
|
|
||||||
(define (file-object? val)
|
(define (file-object? val)
|
||||||
(or (string? val)
|
(or (and (string? val)
|
||||||
|
(string-prefix? "/" val))
|
||||||
(file-like? val)))
|
(file-like? val)))
|
||||||
|
|
||||||
|
(define (file-config? val)
|
||||||
|
(or (gexp? val)
|
||||||
|
(pair? val)))
|
||||||
|
|
||||||
|
(define (file-object-or-file-config? val)
|
||||||
|
(or (file-object? val)
|
||||||
|
(file-config? val)))
|
||||||
|
|
||||||
(define (user-and-group-id? val)
|
(define (user-and-group-id? val)
|
||||||
(or (integer? val)
|
(or (integer? val)
|
||||||
(eqv? val #f)))
|
(eqv? val #f)))
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user