services: clash: Run as root.

Process name related matching is only available to root user.
This commit also changes the default clash implementation to mihomo.

* rosenthal/services/child-error.scm (clash-configuration)
[clash]: Use mihomo-bin.
(%clash-accounts): Remove user account "clash".
(clash-activation): Don't change directory owner.
(clash-shepherd-service)[start]<#:user>: Remove.
trunk
Hilton Chain 4 weeks ago
parent bcf1b0c464
commit fb0a73108e
No known key found for this signature in database
GPG Key ID: ACC66D09CA528292
  1. 19
      rosenthal/services/child-error.scm

@ -49,7 +49,7 @@
(define-configuration clash-configuration (define-configuration clash-configuration
(clash (clash
(file-like clash-bin) (file-like mihomo-bin)
"The clash package.") "The clash package.")
(log-file (log-file
@ -70,23 +70,15 @@
(no-serialization)) (no-serialization))
(define %clash-accounts (define %clash-accounts
(list (user-group (name "clash") (system? #t)) (list (user-group (name "clash") (system? #t))))
(user-account
(name "clash")
(group "clash")
(system? #t)
(home-directory "/var/empty")
(shell (file-append shadow "/sbin/nologin")))))
(define clash-activation (define clash-activation
(match-record-lambda <clash-configuration> (match-record-lambda <clash-configuration>
(clash log-file data-directory config) (data-directory config)
#~(begin #~(begin
(use-modules (guix build utils)) (use-modules (guix build utils))
(let ((config-dest (string-append #$data-directory "/config.yaml")) (let ((config-dest (string-append #$data-directory "/config.yaml")))
(user (getpwnam "clash")))
(mkdir-p #$data-directory) (mkdir-p #$data-directory)
(chown #$data-directory (passwd:uid user) (passwd:gid user))
(if (file-exists? config-dest) (if (file-exists? config-dest)
(delete-file config-dest)) (delete-file config-dest))
(symlink #$config config-dest))))) (symlink #$config config-dest)))))
@ -97,7 +89,7 @@
(define clash-shepherd-service (define clash-shepherd-service
(match-record-lambda <clash-configuration> (match-record-lambda <clash-configuration>
(clash log-file data-directory config shepherd-provision) (clash log-file data-directory shepherd-provision)
(list (shepherd-service (list (shepherd-service
(documentation "Run clash.") (documentation "Run clash.")
(provision shepherd-provision) (provision shepherd-provision)
@ -111,7 +103,6 @@
mihomo-cmd mihomo-cmd
clash-cmd)) clash-cmd))
"-d" #$data-directory) "-d" #$data-directory)
#:user "clash"
#:group "clash" #:group "clash"
#:log-file #$log-file)) #:log-file #$log-file))
(stop #~(make-kill-destructor)) (stop #~(make-kill-destructor))

Loading…
Cancel
Save