From patchwork Fri Jan 1 10:39:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Oleg Pykhalov X-Patchwork-Id: 26147 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 413F027BC08; Fri, 1 Jan 2021 10:40:10 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,T_DKIM_INVALID,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 1BD1C27BC06 for ; Fri, 1 Jan 2021 10:40:09 +0000 (GMT) Received: from localhost ([::1]:45320 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kvHqq-0006gO-8j for patchwork@mira.cbaines.net; Fri, 01 Jan 2021 05:40:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:42450) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kvHqk-0006gE-EA for guix-patches@gnu.org; Fri, 01 Jan 2021 05:40:02 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:43844) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kvHqk-00071Z-71 for guix-patches@gnu.org; Fri, 01 Jan 2021 05:40:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kvHqk-0005lr-2Z for guix-patches@gnu.org; Fri, 01 Jan 2021 05:40:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#45590] [PATCH] services: Add syncthing service. Resent-From: Oleg Pykhalov Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 01 Jan 2021 10:40:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 45590 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 45590@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.160949757222136 (code B ref -1); Fri, 01 Jan 2021 10:40:01 +0000 Received: (at submit) by debbugs.gnu.org; 1 Jan 2021 10:39:32 +0000 Received: from localhost ([127.0.0.1]:55390 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kvHqB-0005ks-IV for submit@debbugs.gnu.org; Fri, 01 Jan 2021 05:39:32 -0500 Received: from lists.gnu.org ([209.51.188.17]:39470) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kvHq9-0005kk-F4 for submit@debbugs.gnu.org; Fri, 01 Jan 2021 05:39:26 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:42434) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kvHq9-0006du-8B for guix-patches@gnu.org; Fri, 01 Jan 2021 05:39:25 -0500 Received: from mail-lf1-x133.google.com ([2a00:1450:4864:20::133]:45707) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kvHq7-0006nv-7W for guix-patches@gnu.org; Fri, 01 Jan 2021 05:39:25 -0500 Received: by mail-lf1-x133.google.com with SMTP id x20so48436363lfe.12 for ; Fri, 01 Jan 2021 02:39:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Sa7ceWKuEBWRUznlChjbtt+TY2erg7znlUp+LcyDveE=; b=hcKL9ipbIwMdFqwUXNwEbDK7WDv/J2jeNmD1tfolhE2ejh2laRk1Jvp/MyYZHx4A0i MI/CUd7p0QJ4BpCtrHE8ZzcfBIknWOeKgCWQVv0x4eF4X5MjExPsrAplReRZb0nCNy14 uBgcdIQ97ptbU13d64Ny1uql1FQPj6UXToY0n4cD9fzpga2H7El3ZDyFMBv0SyKHEw7u Q8UvwNEmXNvlEIB2Nv9vsZ4mDmcZXwIghLc8OhCnIiNiCI9MX0Fbwthks65Bc+ZMrAtu RDl9vOCwjoJnbG+Fo2Eb6N2HoO4Ta2uaBrgxx55OHNcDEy0D9ScyCrufRuNrAD944Cim Aecg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Sa7ceWKuEBWRUznlChjbtt+TY2erg7znlUp+LcyDveE=; b=rxEGc53vl5MsR9qgDvkjoV+bcvwhOORApp9tElIzNQ0qKl28q6eFAQbade1YOn8HRS 8hMW6WtDuUVDK7qMYF1QMUw2ETmYyWRjWkQaUiB/dO8PjELyy0ISCznLhfL+LV+OyBVy bZY+Sk8iCBa7v7drVp2SNMoRgIGq5kDv1A0DK0nfW9HaQnf1hdA2JVJFcBBnlmfXCXZC xR9hlqSiLKK2YskDxAC0gijuNDvipZhIG4FeMpA6OCTElUgmxC/csIf9HLLvFBTc8bG3 8mom3QyRHJWbYDEzB8Fj44I9Uqd9yvmtrFb4d+ICm/ljXA2jO01rlZGIXeEb8lDcJXkk HAmA== X-Gm-Message-State: AOAM533vT6X2LISpa5YqZfpAhAyt3HQ8lY9VF1E8tNnus6hTZxpRsTIr wNJNEZBPcMB+MOc5noBXR21ph5krnDM= X-Google-Smtp-Source: ABdhPJyetEJYctQbqIq550X56rRaSMhRjDIij1QK6LjAjj/wqLrf8qs55/h5VG0WMe0dr087rMyFpA== X-Received: by 2002:a19:4b16:: with SMTP id y22mr29656655lfa.594.1609497560758; Fri, 01 Jan 2021 02:39:20 -0800 (PST) Received: from localhost.localdomain ([178.71.74.207]) by smtp.gmail.com with ESMTPSA id y9sm7815414ljm.94.2021.01.01.02.39.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Jan 2021 02:39:20 -0800 (PST) From: Oleg Pykhalov Date: Fri, 1 Jan 2021 13:39:11 +0300 Message-Id: <20210101103911.18054-1-go.wigust@gmail.com> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::133; envelope-from=go.wigust@gmail.com; helo=mail-lf1-x133.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * gnu/services/syncthing.scm: New file. * gnu/local.mk: Add this. * doc/guix.texi: Document this. --- doc/guix.texi | 49 +++++++++++++++++++++ gnu/local.mk | 3 +- gnu/services/syncthing.scm | 89 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 140 insertions(+), 1 deletion(-) create mode 100644 gnu/services/syncthing.scm diff --git a/doc/guix.texi b/doc/guix.texi index 1081ed26a3..cb6fe065ac 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -16505,6 +16505,55 @@ Group name or group ID that will be used when accessing the module. @end table @end deftp +The @code{(gnu services syncthing)} module provides the following services: +@cindex syncthing + +You might want a syncthing daemon if you have files between two or more +computers and want to sync them in real time, safely protected from +prying eyes. + +@deffn {Scheme Variable} syncthing-service-type +This is the service type for the @uref{https://syncthing.net/, +syncthing} daemon, The value for this service type is a +@command{syncthing-configuration} record as in this example: + +@lisp +(service syncthing-service-type + (syncthing-configuration (user "alice"))) +@end lisp + +See below for details about @code{syncthing-configuration}. + +@deftp {Data Type} syncthing-configuration +Data type representing the configuration for @code{syncthing-service-type}. + +@table @asis +@item @code{syncthing} (default: @var{syncthing}) +@code{syncthing} package to use. + +@item @code{arguments} (default: @var{'()}) +List of command-line arguments passing to @code{syncthing} binary. + +@item @code{logflags} (default: @var{0}) +Sum of loging flags, see +@uref{https://docs.syncthing.net/users/syncthing.html#cmdoption-logflags, Syncthing documentation logflags}. + +@item @code{user} (default: @var{#f}) +The user as which the Syncthing service is to be run. +This assumes that the specified user exists. + +@item @code{group} (default: @var{"users"}) +The group as which the Syncthing service is to be run. +This assumes that the specified group exists. + +@item @code{home} (default: @var{#f}) +Common configuration and data directory. The default configuration +directory is @file{$HOME} of the specified Syncthing @code{user}. + +@end table +@end deftp +@end deffn + Furthermore, @code{(gnu services ssh)} provides the following services. @cindex SSH @cindex SSH server diff --git a/gnu/local.mk b/gnu/local.mk index 2402b1e349..eed786c0fd 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -17,7 +17,7 @@ # Copyright © 2017, 2020 Mathieu Othacehe # Copyright © 2017, 2018, 2019 Gábor Boskovits # Copyright © 2018 Amirouche Boubekki -# Copyright © 2018, 2019, 2020 Oleg Pykhalov +# Copyright © 2018, 2019, 2020, 2021 Oleg Pykhalov # Copyright © 2018 Stefan Stefanović # Copyright © 2018, 2020 Maxim Cournoyer # Copyright © 2019, 2020 Guillaume Le Vaillant @@ -629,6 +629,7 @@ GNU_SYSTEM_MODULES = \ %D%/services/sddm.scm \ %D%/services/spice.scm \ %D%/services/ssh.scm \ + %D%/services/syncthing.scm \ %D%/services/sysctl.scm \ %D%/services/telephony.scm \ %D%/services/version-control.scm \ diff --git a/gnu/services/syncthing.scm b/gnu/services/syncthing.scm new file mode 100644 index 0000000000..12ebe7c107 --- /dev/null +++ b/gnu/services/syncthing.scm @@ -0,0 +1,89 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2021 Oleg Pykhalov +;;; +;;; 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 . + +(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 make-syncthing-configuration + syncthing-configuration? + (syncthing syncthing-configuration-syncthing ; + (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))) + +(define syncthing-shepherd-service + (match-lambda + (($ 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."))) + +;;; syncthing.scm ends here