services: Add user-id and group-id configuration options.

This commit is contained in:
Hilton Chain committed 2025-11-04 16:54:55 +08:00
1 parent 0d15cfdb28
commit ee65ec0e89
7 files changed
+346 -132

No files matched your search

+12 -6
View File
@@ -16,6 +16,7 @@
#:use-module (gnu services dbus)
#:use-module (gnu services shepherd)
#:use-module (gnu system shadow)
#:use-module (rosenthal utils predicates)
#:export (sing-box-service-type
sing-box-configuration
@@ -26,10 +27,6 @@
;;; 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)
@@ -40,6 +37,10 @@
(data-directory
(string "/var/lib/sing-box")
"")
;; Account
(group-id
(user-and-group-id #f)
"")
;; Shepherd
(shepherd-provision
(list-of-symbols '(sing-box))
@@ -55,7 +56,12 @@
""))
(define sing-box-account
(list (user-group (name "sing-box") (system? #t))))
(match-record-lambda <sing-box-configuration>
(group-id)
(list (user-group
(name "sing-box")
(id group-id)
(system? #t)))))
(define sing-box-activation
(match-record-lambda <sing-box-configuration>
@@ -87,7 +93,7 @@
(name 'sing-box)
(extensions
(list (service-extension account-service-type
(const sing-box-account))
sing-box-account)
(service-extension activation-service-type
sing-box-activation)
(service-extension shepherd-root-service-type