home: services: Add Syncthing.
* gnu/home/services/syncthing.scm: New file. * gnu/local.mk (GNU_SYSTEM_MODULES): Add it. * gnu/services/syncthing.scm (<syncthing-configuration>)[home-service?]: New field. Adjust 'provision' and 'requirement' depending on 'home-service?', and likewise for #:user and #:group. Use 'filter' + 'negate' instead of 'remove'. * doc/guix.texi (Networking Services): Add note and cross-reference to "Networking Home Services". (Networking Home Services): New node.
parent
1ce3424e22
commit
7605c01fcc
|
@ -450,6 +450,7 @@ Home Services
|
||||||
* Mail: Mail Home Services. Services for managing mail.
|
* Mail: Mail Home Services. Services for managing mail.
|
||||||
* Messaging: Messaging Home Services. Services for managing messaging.
|
* Messaging: Messaging Home Services. Services for managing messaging.
|
||||||
* Media: Media Home Services. Services for managing media.
|
* Media: Media Home Services. Services for managing media.
|
||||||
|
* Networking: Networking Home Services. Networking services.
|
||||||
* Miscellaneous: Miscellaneous Home Services. More services.
|
* Miscellaneous: Miscellaneous Home Services. More services.
|
||||||
|
|
||||||
Platforms
|
Platforms
|
||||||
|
@ -21304,6 +21305,8 @@ client.
|
||||||
@end table
|
@end table
|
||||||
@end deftp
|
@end deftp
|
||||||
|
|
||||||
|
@cindex Syncthing, file synchronization service
|
||||||
|
@cindex backup service, Syncthing
|
||||||
The @code{(gnu services syncthing)} module provides the following services:
|
The @code{(gnu services syncthing)} module provides the following services:
|
||||||
@cindex syncthing
|
@cindex syncthing
|
||||||
|
|
||||||
|
@ -21321,7 +21324,14 @@ syncthing} daemon, The value for this service type is a
|
||||||
(syncthing-configuration (user "alice")))
|
(syncthing-configuration (user "alice")))
|
||||||
@end lisp
|
@end lisp
|
||||||
|
|
||||||
|
@quotation Note
|
||||||
|
This service is also available for Guix Home, where it runs directly
|
||||||
|
with your user privileges (@pxref{Networking Home Services,
|
||||||
|
@code{home-syncthing-service-type}}).
|
||||||
|
@end quotation
|
||||||
|
|
||||||
See below for details about @code{syncthing-configuration}.
|
See below for details about @code{syncthing-configuration}.
|
||||||
|
@end defvar
|
||||||
|
|
||||||
@deftp {Data Type} syncthing-configuration
|
@deftp {Data Type} syncthing-configuration
|
||||||
Data type representing the configuration for @code{syncthing-service-type}.
|
Data type representing the configuration for @code{syncthing-service-type}.
|
||||||
|
@ -21351,7 +21361,6 @@ directory is @file{$HOME} of the specified Syncthing @code{user}.
|
||||||
|
|
||||||
@end table
|
@end table
|
||||||
@end deftp
|
@end deftp
|
||||||
@end defvar
|
|
||||||
|
|
||||||
Furthermore, @code{(gnu services ssh)} provides the following services.
|
Furthermore, @code{(gnu services ssh)} provides the following services.
|
||||||
@cindex SSH
|
@cindex SSH
|
||||||
|
@ -42979,6 +42988,7 @@ services)}.
|
||||||
* Mail: Mail Home Services. Services for managing mail.
|
* Mail: Mail Home Services. Services for managing mail.
|
||||||
* Messaging: Messaging Home Services. Services for managing messaging.
|
* Messaging: Messaging Home Services. Services for managing messaging.
|
||||||
* Media: Media Home Services. Services for managing media.
|
* Media: Media Home Services. Services for managing media.
|
||||||
|
* Networking: Networking Home Services. Networking services.
|
||||||
* Miscellaneous: Miscellaneous Home Services. More services.
|
* Miscellaneous: Miscellaneous Home Services. More services.
|
||||||
@end menu
|
@end menu
|
||||||
@c In addition to that Home Services can provide
|
@c In addition to that Home Services can provide
|
||||||
|
@ -44569,6 +44579,45 @@ kodi} for more information.
|
||||||
@end table
|
@end table
|
||||||
@end deftp
|
@end deftp
|
||||||
|
|
||||||
|
@node Networking Home Services
|
||||||
|
@subsection Networking Home Services
|
||||||
|
|
||||||
|
This section lists services somewhat networking-related that you may use
|
||||||
|
with Guix Home.
|
||||||
|
|
||||||
|
@cindex Syncthing, file synchronization service
|
||||||
|
@cindex backup service, Syncthing
|
||||||
|
The @code{(gnu home services syncthing)} module provides a service to
|
||||||
|
set up the @uref{Syncthing, https://syncthing.net} continuous file
|
||||||
|
backup service.
|
||||||
|
|
||||||
|
@defvar home-syncthing-service-type
|
||||||
|
This is the service type for the @command{syncthing} daemon; it is the
|
||||||
|
Home counterpart of the @code{syncthing-service-type} system service
|
||||||
|
(@pxref{Networking Services, @code{syncthing-service-type}}). The value
|
||||||
|
for this service type is a @command{syncthing-configuration}.
|
||||||
|
|
||||||
|
Here is how you would set it up with the default configuration:
|
||||||
|
|
||||||
|
@lisp
|
||||||
|
(service home-syncthing-service-type)
|
||||||
|
@end lisp
|
||||||
|
|
||||||
|
For a custom configuration, wrap you @code{syncthing-configuration} in
|
||||||
|
@code{for-home}, as in this example:
|
||||||
|
|
||||||
|
@lisp
|
||||||
|
(service home-syncthing-service-type
|
||||||
|
(for-home
|
||||||
|
(syncthing-configuration (logflags 5))))
|
||||||
|
@end lisp
|
||||||
|
|
||||||
|
For details about @code{syncthing-configuration}, check out the
|
||||||
|
documentation of the system service (@pxref{Networking Services,
|
||||||
|
@code{syncthing-service-type}}).
|
||||||
|
@end defvar
|
||||||
|
|
||||||
|
|
||||||
@node Miscellaneous Home Services
|
@node Miscellaneous Home Services
|
||||||
@subsection Miscellaneous Home Services
|
@subsection Miscellaneous Home Services
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
;;; GNU Guix --- Functional package management for GNU
|
||||||
|
;;; Copyright © 2023 Ludovic Courtès <ludo@gnu.org>
|
||||||
|
;;;
|
||||||
|
;;; This file is part of GNU Guix.
|
||||||
|
;;;
|
||||||
|
;;; GNU Guix is free software; you can redistribute it and/or modify it
|
||||||
|
;;; under the terms of the GNU General Public License as published by
|
||||||
|
;;; the Free Software Foundation; either version 3 of the License, or (at
|
||||||
|
;;; your option) any later version.
|
||||||
|
;;;
|
||||||
|
;;; GNU Guix is distributed in the hope that it will be useful, but
|
||||||
|
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
;;; GNU General Public License for more details.
|
||||||
|
;;;
|
||||||
|
;;; You should have received a copy of the GNU General Public License
|
||||||
|
;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
(define-module (gnu home services syncthing)
|
||||||
|
#:use-module (gnu services)
|
||||||
|
#:use-module (gnu home services)
|
||||||
|
#:use-module (gnu services syncthing)
|
||||||
|
#:export (home-syncthing-service-type)
|
||||||
|
#:re-export (syncthing-configuration
|
||||||
|
syncthing-configuration?))
|
||||||
|
|
||||||
|
(define home-syncthing-service-type
|
||||||
|
(service-type
|
||||||
|
(inherit (system->home-service-type syncthing-service-type))
|
||||||
|
(default-value (for-home (syncthing-configuration)))))
|
|
@ -104,6 +104,7 @@ GNU_SYSTEM_MODULES = \
|
||||||
%D%/home/services/shepherd.scm \
|
%D%/home/services/shepherd.scm \
|
||||||
%D%/home/services/sound.scm \
|
%D%/home/services/sound.scm \
|
||||||
%D%/home/services/ssh.scm \
|
%D%/home/services/ssh.scm \
|
||||||
|
%D%/home/services/syncthing.scm \
|
||||||
%D%/home/services/mcron.scm \
|
%D%/home/services/mcron.scm \
|
||||||
%D%/home/services/utils.scm \
|
%D%/home/services/utils.scm \
|
||||||
%D%/home/services/xdg.scm \
|
%D%/home/services/xdg.scm \
|
||||||
|
|
|
@ -49,32 +49,38 @@
|
||||||
(group syncthing-configuration-group ;string
|
(group syncthing-configuration-group ;string
|
||||||
(default "users"))
|
(default "users"))
|
||||||
(home syncthing-configuration-home ;string
|
(home syncthing-configuration-home ;string
|
||||||
(default #f)))
|
(default #f))
|
||||||
|
(home-service? syncthing-configuration-home-service?
|
||||||
|
(default for-home?) (innate)))
|
||||||
|
|
||||||
(define syncthing-shepherd-service
|
(define syncthing-shepherd-service
|
||||||
(match-record-lambda <syncthing-configuration>
|
(match-record-lambda <syncthing-configuration>
|
||||||
(syncthing arguments logflags user group home)
|
(syncthing arguments logflags user group home home-service?)
|
||||||
(list
|
(list
|
||||||
(shepherd-service
|
(shepherd-service
|
||||||
(provision (list (string->symbol (string-append "syncthing-" user))))
|
(provision (if home-service?
|
||||||
|
'(syncthing)
|
||||||
|
(list (string->symbol
|
||||||
|
(string-append "syncthing-" user)))))
|
||||||
(documentation "Run syncthing.")
|
(documentation "Run syncthing.")
|
||||||
(requirement '(loopback))
|
(requirement (if home-service? '() '(loopback)))
|
||||||
(start #~(make-forkexec-constructor
|
(start #~(make-forkexec-constructor
|
||||||
(append (list (string-append #$syncthing "/bin/syncthing")
|
(append (list (string-append #$syncthing "/bin/syncthing")
|
||||||
"--no-browser"
|
"--no-browser"
|
||||||
"--no-restart"
|
"--no-restart"
|
||||||
(string-append "--logflags=" (number->string #$logflags)))
|
(string-append "--logflags=" (number->string #$logflags)))
|
||||||
'#$arguments)
|
'#$arguments)
|
||||||
#:user #$user
|
#:user #$(and (not home-service?) user)
|
||||||
#:group #$group
|
#:group #$(and (not home-service?) group)
|
||||||
#:environment-variables
|
#:environment-variables
|
||||||
(append (list (string-append "HOME=" (or #$home (passwd:dir (getpw #$user))))
|
(append (list (string-append "HOME=" (or #$home (passwd:dir (getpw #$user))))
|
||||||
"SSL_CERT_DIR=/etc/ssl/certs"
|
"SSL_CERT_DIR=/etc/ssl/certs"
|
||||||
"SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt")
|
"SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt")
|
||||||
(remove (lambda (str)
|
(filter (negate ;XXX: 'remove' is not in (guile)
|
||||||
(or (string-prefix? "HOME=" str)
|
(lambda (str)
|
||||||
(string-prefix? "SSL_CERT_DIR=" str)
|
(or (string-prefix? "HOME=" str)
|
||||||
(string-prefix? "SSL_CERT_FILE=" str)))
|
(string-prefix? "SSL_CERT_DIR=" str)
|
||||||
|
(string-prefix? "SSL_CERT_FILE=" str))))
|
||||||
(environ)))))
|
(environ)))))
|
||||||
(respawn? #f)
|
(respawn? #f)
|
||||||
(stop #~(make-kill-destructor))))))
|
(stop #~(make-kill-destructor))))))
|
||||||
|
|
Reference in New Issue