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