mirror of
https://codeberg.org/hako/Rosenthal.git
synced 2025-08-22 06:09:11 +00:00
services: Add sing-box-service-type.
* modules/rosenthal/services/networking.scm (<sing-box-configuration>): New data type. (file-object?, sing-box-activation, sing-box-shepherd-service): New procedures. (sing-box-account, sing-box-service-type): New variables.
This commit is contained in:
parent
55fbf529c7
commit
92c6a14084
@ -15,9 +15,13 @@
|
|||||||
#:use-module (gnu services configuration)
|
#:use-module (gnu services configuration)
|
||||||
#:use-module (gnu services dbus)
|
#:use-module (gnu services dbus)
|
||||||
#:use-module (gnu services shepherd)
|
#:use-module (gnu services shepherd)
|
||||||
|
#:use-module (gnu system shadow)
|
||||||
#:export (iwd-configuration
|
#:export (iwd-configuration
|
||||||
iwd-service-type
|
iwd-service-type
|
||||||
|
|
||||||
|
sing-box-service-type
|
||||||
|
sing-box-configuration
|
||||||
|
|
||||||
tailscale-configuration
|
tailscale-configuration
|
||||||
tailscale-service-type))
|
tailscale-service-type))
|
||||||
|
|
||||||
@ -377,6 +381,81 @@ list, power save will be disabled."))
|
|||||||
(default-value (iwd-configuration))
|
(default-value (iwd-configuration))
|
||||||
(description "Run iwd, the iNet wireless daemon.")))
|
(description "Run iwd, the iNet wireless daemon.")))
|
||||||
|
|
||||||
|
|
||||||
|
;;;
|
||||||
|
;;; sing-box
|
||||||
|
;;;
|
||||||
|
|
||||||
|
(define (file-object? val)
|
||||||
|
(or (string? val)
|
||||||
|
(file-like? val)))
|
||||||
|
|
||||||
|
(define-configuration/no-serialization sing-box-configuration
|
||||||
|
(sing-box
|
||||||
|
(file-like sing-box)
|
||||||
|
"")
|
||||||
|
(config-file
|
||||||
|
file-object
|
||||||
|
"")
|
||||||
|
(data-directory
|
||||||
|
(string "/var/lib/sing-box")
|
||||||
|
"")
|
||||||
|
;; Shepherd
|
||||||
|
(shepherd-provision
|
||||||
|
(list-of-symbols '(sing-box))
|
||||||
|
"")
|
||||||
|
(shepherd-requirement
|
||||||
|
(list-of-symbols '(networking))
|
||||||
|
"")
|
||||||
|
(log-file
|
||||||
|
(string "/var/log/sing-box.log")
|
||||||
|
"")
|
||||||
|
(auto-start?
|
||||||
|
(boolean #t)
|
||||||
|
""))
|
||||||
|
|
||||||
|
(define sing-box-account
|
||||||
|
(list (user-group (name "sing-box") (system? #t))))
|
||||||
|
|
||||||
|
(define sing-box-activation
|
||||||
|
(match-record-lambda <sing-box-configuration>
|
||||||
|
(data-directory)
|
||||||
|
#~(begin
|
||||||
|
(use-modules (guix build utils))
|
||||||
|
(mkdir-p #$data-directory))))
|
||||||
|
|
||||||
|
(define sing-box-shepherd-service
|
||||||
|
(match-record-lambda <sing-box-configuration>
|
||||||
|
(sing-box data-directory config-file
|
||||||
|
shepherd-provision shepherd-requirement log-file auto-start?)
|
||||||
|
(list (shepherd-service
|
||||||
|
(provision shepherd-provision)
|
||||||
|
(requirement `(user-processes ,@shepherd-requirement))
|
||||||
|
(start
|
||||||
|
#~(make-forkexec-constructor
|
||||||
|
(list #$(file-append sing-box "/bin/sing-box")
|
||||||
|
"--config" #$config-file
|
||||||
|
"--directory" #$data-directory
|
||||||
|
"--disable-color"
|
||||||
|
"run")
|
||||||
|
#:log-file #$log-file))
|
||||||
|
(stop #~(make-kill-destructor))
|
||||||
|
(auto-start? auto-start?)))))
|
||||||
|
|
||||||
|
(define sing-box-service-type
|
||||||
|
(service-type
|
||||||
|
(name 'sing-box)
|
||||||
|
(extensions
|
||||||
|
(list (service-extension account-service-type
|
||||||
|
(const sing-box-account))
|
||||||
|
(service-extension activation-service-type
|
||||||
|
sing-box-activation)
|
||||||
|
(service-extension shepherd-root-service-type
|
||||||
|
sing-box-shepherd-service)
|
||||||
|
(service-extension log-rotation-service-type
|
||||||
|
(compose list sing-box-configuration-log-file))))
|
||||||
|
(description "")))
|
||||||
|
|
||||||
|
|
||||||
;;;
|
;;;
|
||||||
;;; Tailscale
|
;;; Tailscale
|
||||||
|
Loading…
Reference in New Issue
Block a user