mirror of
https://codeberg.org/hako/Rosenthal.git
synced 2026-11-29 22:58:06 +00:00
services: sing-box: Support setting config directory.
* modules/rosenthal/services/networking.scm (<sing-box-configuration>) [config-directory]: New field. (sing-box-shepherd-service): Use it. Signed-off-by: Hilton Chain <hako@ultrarare.space> Modified-by: Hilton Chain <hako@ultrarare.space> Merges: #56
This commit is contained in:
1 parent
91f2eac90a
commit
ab3698c4ad
1 file changed
+24
-4
@@ -7,7 +7,9 @@
|
|||||||
#:use-module (srfi srfi-1)
|
#:use-module (srfi srfi-1)
|
||||||
#:use-module (srfi srfi-26)
|
#:use-module (srfi srfi-26)
|
||||||
;; Utilities
|
;; Utilities
|
||||||
|
#:use-module (guix diagnostics)
|
||||||
#:use-module (guix gexp)
|
#:use-module (guix gexp)
|
||||||
|
#:use-module (guix i18n)
|
||||||
#:use-module (guix records)
|
#:use-module (guix records)
|
||||||
#:use-module (rosenthal utils predicates)
|
#:use-module (rosenthal utils predicates)
|
||||||
;; Guix System
|
;; Guix System
|
||||||
@@ -91,12 +93,18 @@
|
|||||||
;;; sing-box
|
;;; sing-box
|
||||||
;;;
|
;;;
|
||||||
|
|
||||||
|
(define-maybe file-object)
|
||||||
|
(define-maybe string)
|
||||||
|
|
||||||
(define-configuration/no-serialization sing-box-configuration
|
(define-configuration/no-serialization sing-box-configuration
|
||||||
(sing-box
|
(sing-box
|
||||||
(file-like sing-box)
|
(file-like sing-box)
|
||||||
"")
|
"")
|
||||||
(config-file
|
(config-file
|
||||||
file-object
|
maybe-file-object
|
||||||
|
"")
|
||||||
|
(config-directory
|
||||||
|
maybe-string
|
||||||
"")
|
"")
|
||||||
(data-directory
|
(data-directory
|
||||||
(string "/var/lib/sing-box")
|
(string "/var/lib/sing-box")
|
||||||
@@ -136,21 +144,33 @@
|
|||||||
|
|
||||||
(define sing-box-shepherd-service
|
(define sing-box-shepherd-service
|
||||||
(match-record-lambda <sing-box-configuration>
|
(match-record-lambda <sing-box-configuration>
|
||||||
(sing-box data-directory config-file
|
(sing-box data-directory config-file config-directory
|
||||||
shepherd-provision shepherd-requirement log-file auto-start?)
|
shepherd-provision shepherd-requirement log-file auto-start?)
|
||||||
|
(let ((config-file-set? (maybe-value-set? config-file))
|
||||||
|
(config-dir-set? (maybe-value-set? config-directory)))
|
||||||
|
(when (eqv? config-file-set? config-dir-set?)
|
||||||
|
(leave (G_ "'~a': exactly one of '~a' or '~a' must be set~%")
|
||||||
|
"sing-box-configuration"
|
||||||
|
"config-file"
|
||||||
|
"config-directory"))
|
||||||
(list (shepherd-service
|
(list (shepherd-service
|
||||||
(provision shepherd-provision)
|
(provision shepherd-provision)
|
||||||
(requirement `(user-processes ,@shepherd-requirement))
|
(requirement `(user-processes ,@shepherd-requirement))
|
||||||
(start
|
(start
|
||||||
#~(make-forkexec-constructor
|
#~(make-forkexec-constructor
|
||||||
(list #$(file-append sing-box "/bin/sing-box")
|
(list #$(file-append sing-box "/bin/sing-box")
|
||||||
"--config" #$config-file
|
#$@(if config-file-set?
|
||||||
|
(list "--config" config-file)
|
||||||
|
'())
|
||||||
|
#$@(if config-dir-set?
|
||||||
|
(list "--config-directory" config-directory)
|
||||||
|
'())
|
||||||
"--directory" #$data-directory
|
"--directory" #$data-directory
|
||||||
"--disable-color"
|
"--disable-color"
|
||||||
"run")
|
"run")
|
||||||
#:log-file #$log-file))
|
#:log-file #$log-file))
|
||||||
(stop #~(make-kill-destructor))
|
(stop #~(make-kill-destructor))
|
||||||
(auto-start? auto-start?)))))
|
(auto-start? auto-start?))))))
|
||||||
|
|
||||||
(define sing-box-service-type
|
(define sing-box-service-type
|
||||||
(service-type
|
(service-type
|
||||||
|
|||||||
Reference in new issue
Block a user