2022-04-21 01:44:52 +02:00
|
|
|
(define-module (oni home services syncthing)
|
|
|
|
#:use-module (gnu services configuration)
|
|
|
|
#:use-module (gnu packages syncthing)
|
|
|
|
#:use-module (gnu home services)
|
|
|
|
#:use-module (gnu home services shepherd)
|
|
|
|
#:use-module (gnu home services utils)
|
|
|
|
#:use-module (guix packages)
|
|
|
|
#:use-module (guix gexp)
|
|
|
|
|
|
|
|
#:export (home-syncthing-service-type
|
|
|
|
home-syncthing-configuration))
|
|
|
|
|
|
|
|
(define-configuration home-syncthing-configuration
|
|
|
|
(package
|
2022-04-21 06:19:40 +02:00
|
|
|
(package syncthing)
|
2022-04-21 01:44:52 +02:00
|
|
|
"Package to use for setting syncthing"))
|
|
|
|
|
|
|
|
(define (add-syncthing-packages config)
|
|
|
|
(list (home-syncthing-configuration-package config)))
|
|
|
|
|
|
|
|
(define (home-syncthing-shepherd-service config)
|
|
|
|
(list
|
|
|
|
(shepherd-service
|
|
|
|
(documentation "Start syncthing")
|
|
|
|
(provision '(syncthing))
|
|
|
|
(auto-start? #t)
|
|
|
|
(start
|
2022-04-21 02:17:57 +02:00
|
|
|
#~(make-forkexec-constructor
|
2022-04-21 06:19:40 +02:00
|
|
|
(list #$(file-append (home-syncthing-configuration-package config) "/bin/syncthing")
|
|
|
|
"serve"
|
|
|
|
"--logfile" (format #f "~a/.local/var/log/syncthing.log" (getenv "HOME"))
|
|
|
|
"--no-browser")))
|
2022-04-21 01:44:52 +02:00
|
|
|
(stop
|
2022-04-21 02:17:57 +02:00
|
|
|
#~(make-kill-destructor)))))
|
2022-04-21 01:44:52 +02:00
|
|
|
|
|
|
|
(define home-syncthing-service-type
|
|
|
|
(service-type
|
|
|
|
(name 'home-syncthing)
|
|
|
|
(extensions
|
|
|
|
(list (service-extension
|
|
|
|
home-profile-service-type
|
|
|
|
add-syncthing-packages)
|
|
|
|
(service-extension
|
|
|
|
home-shepherd-service-type
|
|
|
|
home-syncthing-shepherd-service)))
|
|
|
|
(compose identity)
|
|
|
|
(default-value (home-syncthing-configuration))
|
|
|
|
(description "Install and configure syncthing.")))
|