aboutsummaryrefslogtreecommitdiff
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2021 Oleg Pykhalov <go.wigust@gmail.com>
;;; Copyright © 2023 Justin Veilleux <terramorpha@cock.li>
;;;
;;; 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 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))

;;; Commentary:
;;;
;;; This module provides a service definition for the syncthing service.
;;;
;;; Code:

(define-record-type* <syncthing-configuration>
  syncthing-configuration make-syncthing-configuration
  syncthing-configuration?
  (syncthing syncthing-configuration-syncthing ;file-like
             (default syncthing))
  (arguments syncthing-configuration-arguments ;list of strings
             (default '()))
  (logflags  syncthing-configuration-logflags  ;number
             (default 0))
  (user      syncthing-configuration-user      ;string
             (default #f))
  (group     syncthing-configuration-group     ;string
             (default "users"))
  (home      syncthing-configuration-home      ;string
             (default #f))
  (home-service? syncthing-configuration-home-service?
                 (default for-home?) (innate)))

(define syncthing-shepherd-service
  (match-record-lambda <syncthing-configuration>
      (syncthing arguments logflags user group home home-service?)
    (list
     (shepherd-service
      (provision (if home-service?
                     '(syncthing)
                     (list (string->symbol
                            (string-append "syncthing-" user)))))
      (documentation "Run syncthing.")
      (requirement (if home-service? '() '(loopback user-processes)))
      (start #~(make-forkexec-constructor
                (append (list (string-append #$syncthing "/bin/syncthing")
                              "--no-browser"
                              "--no-restart"
                              (string-append "--logflags=" (number->string #$logflags)))
                        '#$arguments)
                #:user #$(and (not home-service?) user)
                #:group #$(and (not home-service?) group)
                #:environment-variables
                (append
                 (list
                  (string-append "HOME="
                                 (or #$home
                                     (passwd:dir
                                      (getpw (if (and #$home-service?
                                                      (not #$user))
                                                 (getuid)
                                                 #$user)))))
                              "SSL_CERT_DIR=/etc/ssl/certs"
                              "SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt")
                        (filter (negate       ;XXX: 'remove' is not in (guile)
                                 (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.")))

;;; syncthing.scm ends here
='2024-06-17 12:04:20 -0400'>2024-06-17news: Add entry for removing linux-libre 6.8 ("end of life")....* etc/news.scm: Add entry for linux-libre 6.8 removal. Signed-off-by: Leo Famulari <leo@famulari.name> Change-Id: I9f91c810d5be7ab790c82bfa16a43e4893c06920 Wilko Meyer 2024-05-01news: Add entry for ‘guix git authenticate’ changes....* etc/news.scm: Add entry. Change-Id: I661a0c0bfc373b87a70508ad9a735315c96ba4a5 Co-authored-by: Florian Pelz <pelzflorian@pelzflorian.de> Change-Id: Ibafef9d432df163948c4884279d4ce2579ed0312 Ludovic Courtès 2024-04-30news: Add entry for removing linux-libre 6.7 (EoL)....* etc/news.scm: Add entry for linux-libre 6.7 removal. Change-Id: I8fe3eb3f68023e85fcac7549c06d2cc26cd8e810 Signed-off-by: Leo Famulari <leo@famulari.name> Wilko Meyer 2024-04-23news: Update news and commit for nss-certs change....As discussed in <https://lists.gnu.org/archive/html/guix-devel/2024-04/msg00211.html>. * etc/news.scm: Update. Change-Id: Id893abe6642de3939f7993267075764e4bb5d820 Florian Pelz 2024-04-20news: Add 'de' translation....* etc/news.scm: Add German translation for nss-certs entry. Change-Id: I82343fdc81c370a2a11e0c7bce55e5914187861f Florian Pelz 2024-04-18news: Add entry for nss-certs being added to %base-packages....* etc/news.scm: New entry. * NEWS: Update news. Change-Id: I40e0b859f2af0bb0e652925a53d6447ea6fbacfb Maxim Cournoyer 2024-04-08news: Add entry for the linux-libre-lts 6.6 update....* etc/news.scm: Add entry. Change-Id: Ic57c76c300712e4a6053052611e6483b4d72f0c5 Signed-off-by: Leo Famulari <leo@famulari.name> Ahmad Draidi via Guix-patches via 2024-03-16Merge remote-tracking branch 'savannah/master' into gnome-team...Change-Id: I775274c2693536e2efa36c9abca4c54c5c458e26 Christopher Baines 2024-03-12news: Update commit for fixed-output derivation vulnerability....* etc/news.scm: Update. Change-Id: Ia34408882f8928a0fd05acc12d4edc66b3dcb3b7 Ludovic Courtès 2024-03-12news: Add 'de' translation....* etc/news.scm: Add German translation. Change-Id: Ia2a11f71cdee5ccbf2a7fbe176e713418771599e Florian Pelz 2024-03-12news: Give upgrade instructions for foreign distros....* etc/news.scm: Update entry. Change-Id: Ia7c326bc97042d92a8d499ee27dd41d15f1f0d29 Ludovic Courtès 2024-03-11news: Add entry for the daemon fixed-output derivation vulnerability....* etc/news.scm: Add entry. Change-Id: Ib3f9c22eda1e8b9075620ec01b4edf2f24cfcf93 Ludovic Courtès 2024-02-28news: Add entry for changes in GNOME 44 and its desktop service....* etc/news.scm: Add entry. Liliana Marie Prikler 2024-02-28news: Add entry for GDM defaulting to Wayland....* etc/news.scm: Add entry. Change-Id: Icddcf269ff59a7ee2a14680ed95a167758ecddaf Signed-off-by: Liliana Marie Prikler <liliana.prikler@gmail.com> Vivien Kraus 2024-02-28news: Add entry for hwdb support in udev-service-type....* etc/news.scm: Add entry. Change-Id: I3c27b10eab501cca6ed0e32a1b30d92f212266b4 Signed-off-by: Liliana Marie Prikler <liliana.prikler@gmail.com> Vivien Kraus 2024-01-22news: Add entry for removing linux-libre 4.14 (EoL)....* etc/news.scm: Add entry for linux-libre 4.14 removal and add my copyright header. Change-Id: I5c2418bc22a4ae2bba63c1cf77e66d2574766e01 Wilko Meyer 2024-01-13news: Fix 'de' translation....* etc/news.scm: Fix typo. Change-Id: I943fed38a444d1403cc5f979a7d6b9f52bedf5dd Florian Pelz 2024-01-09news: Add entry for the new '--max-layers=N' option....* etc/news.scm: Add entry. Change-Id: I286c04fd2cef820007606d1092ab45be4466fb19 Oleg Pykhalov 2023-10-03news: Add 'de' translation....* etc/news.scm: Add German translation of offloading entry. Florian Pelz 2023-10-03news: Fix typo....* etc/news.scm: Fix typo in the English text on offloading. Florian Pelz 2023-10-01news: Add entry for declarative offloading....* etc/news.scm: Add entry. Ludovic Courtès 2023-07-23news: Add entry about the removal of linux-libre 6.3....* etc/news.scm: Add entry. Leo Famulari 2023-07-23news: Add entry for the linux-libre 6.4 update....* etc/news.scm: Add entry. Leo Famulari