123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- (define-module (gnu services syncthing)
- #:use-module (gnu packages syncthing)
- #:use-module (gnu services)
- #:use-module (gnu services shepherd)
- #:use-module (guix gexp)
- #:use-module (guix records)
- #:use-module (ice-9 match)
- #:use-module (srfi srfi-1)
- #:export (syncthing-configuration
- syncthing-configuration?
- syncthing-service-type))
- (define-record-type* <syncthing-configuration>
- syncthing-configuration make-syncthing-configuration
- syncthing-configuration?
- (syncthing syncthing-configuration-syncthing
- (default syncthing))
- (arguments syncthing-configuration-arguments
- (default '()))
- (logflags syncthing-configuration-logflags
- (default 0))
- (user syncthing-configuration-user
- (default #f))
- (group syncthing-configuration-group
- (default "users"))
- (home syncthing-configuration-home
- (default #f)))
- (define syncthing-shepherd-service
- (match-lambda
- (($ <syncthing-configuration> syncthing arguments logflags user group home)
- (list
- (shepherd-service
- (provision (list (string->symbol (string-append "syncthing-" user))))
- (documentation "Run syncthing.")
- (requirement '(loopback))
- (start #~(make-forkexec-constructor
- (append (list (string-append #$syncthing "/bin/syncthing")
- "-no-browser"
- "-no-restart"
- (string-append "-logflags=" (number->string #$logflags)))
- '#$arguments)
- #:user #$user
- #:group #$group
- #:environment-variables
- (append (list (string-append "HOME=" (or #$home (passwd:dir (getpw #$user))))
- "SSL_CERT_DIR=/etc/ssl/certs"
- "SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt")
- (remove (lambda (str)
- (or (string-prefix? "HOME=" str)
- (string-prefix? "SSL_CERT_DIR=" str)
- (string-prefix? "SSL_CERT_FILE=" str)))
- (environ)))))
- (respawn? #f)
- (stop #~(make-kill-destructor)))))))
- (define syncthing-service-type
- (service-type (name 'syncthing)
- (extensions (list (service-extension shepherd-root-service-type
- syncthing-shepherd-service)))
- (description
- "Run @uref{https://github.com/syncthing/syncthing, Syncthing}
- decentralized continuous file system synchronization.")))
|