From patchwork Sun Aug 6 21:07:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 52599 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 55BF927BBEA; Sun, 6 Aug 2023 22:09:22 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id DF9CA27BBE2 for ; Sun, 6 Aug 2023 22:09:20 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qSkzo-0007L4-Gb; Sun, 06 Aug 2023 17:09:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qSkzm-0007Jr-TW for guix-patches@gnu.org; Sun, 06 Aug 2023 17:09:02 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qSkzm-0001Yy-LD for guix-patches@gnu.org; Sun, 06 Aug 2023 17:09:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qSkzm-0005kq-Ge for guix-patches@gnu.org; Sun, 06 Aug 2023 17:09:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#65119] [PATCH 8/8] home: services: Add Syncthing. Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: , guix-patches@gnu.org Resent-Date: Sun, 06 Aug 2023 21:09:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 65119 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 65119@debbugs.gnu.org Cc: Ludovic =?utf-8?q?Court=C3=A8s?= , ( , Andrew Tropin , Ludovic =?utf-8?q?Court=C3=A8s?= X-Debbugs-Original-Xcc: ( , Andrew Tropin , Ludovic =?utf-8?q?Court=C3=A8s?= Received: via spool by 65119-submit@debbugs.gnu.org id=B65119.169135608822040 (code B ref 65119); Sun, 06 Aug 2023 21:09:02 +0000 Received: (at 65119) by debbugs.gnu.org; 6 Aug 2023 21:08:08 +0000 Received: from localhost ([127.0.0.1]:60142 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qSkyt-0005jK-Vq for submit@debbugs.gnu.org; Sun, 06 Aug 2023 17:08:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54158) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qSkyo-0005gt-A1 for 65119@debbugs.gnu.org; Sun, 06 Aug 2023 17:08:04 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qSkyj-0001Qw-4E; Sun, 06 Aug 2023 17:07:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=PRWEc0ELfnr0sixGrxe0jZ+hbTqDRGNBJzcGfGpP1N8=; b=lUSgWnMdn/Bma0wZKSGo Fi7yH4xY1hknjb3kI790YFZy3Ng1qajU+K857/DrN9WymXl7sgKuAmV5Jvf7KlxsebEYhF0KiyzFr GCXvu1zKlVARX94dTZJ6gAJyydw0GQdi0haG2YuNSxQC/s50qbVanchc6FVU8N2a2zW7pCw6dcmkH S/OBGHkElJBlUQ0T3uzSmMieYTcJLO+uyIxSlmKZVBXUg8Cxvzayw8S+G+nwQhGbE8blrSBblPAwi Bxzo14kwazZ1rXEFQ/bCEdfYUyx06NhqBjnRAAMbmfRAyHFOsF3qAch3IsgeAPScjEI8LzfxZhbgm 7+EsWjqE6wmFHA==; From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Sun, 6 Aug 2023 23:07:35 +0200 Message-ID: X-Mailer: git-send-email 2.41.0 In-Reply-To: References: MIME-Version: 1.0 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-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * gnu/home/services/syncthing.scm: New file. * gnu/local.mk (GNU_SYSTEM_MODULES): Add it. * gnu/services/syncthing.scm ()[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. --- doc/guix.texi | 51 ++++++++++++++++++++++++++++++++- gnu/home/services/syncthing.scm | 30 +++++++++++++++++++ gnu/local.mk | 1 + gnu/services/syncthing.scm | 26 ++++++++++------- 4 files changed, 97 insertions(+), 11 deletions(-) create mode 100644 gnu/home/services/syncthing.scm diff --git a/doc/guix.texi b/doc/guix.texi index dd272636a3..a4993b7ae7 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -446,6 +446,7 @@ Top * Mail: Mail Home Services. Services for managing mail. * Messaging: Messaging Home Services. Services for managing messaging. * Media: Media Home Services. Services for managing media. +* Networking: Networking Home Services. Networking services. * Miscellaneous: Miscellaneous Home Services. More services. Platforms @@ -21226,6 +21227,8 @@ Networking Services @end table @end deftp +@cindex Syncthing, file synchronization service +@cindex backup service, Syncthing The @code{(gnu services syncthing)} module provides the following services: @cindex syncthing @@ -21243,7 +21246,14 @@ Networking Services (syncthing-configuration (user "alice"))) @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}. +@end defvar @deftp {Data Type} syncthing-configuration Data type representing the configuration for @code{syncthing-service-type}. @@ -21273,7 +21283,6 @@ Networking Services @end table @end deftp -@end defvar Furthermore, @code{(gnu services ssh)} provides the following services. @cindex SSH @@ -42620,6 +42629,7 @@ Home Services * Mail: Mail Home Services. Services for managing mail. * Messaging: Messaging Home Services. Services for managing messaging. * Media: Media Home Services. Services for managing media. +* Networking: Networking Home Services. Networking services. * Miscellaneous: Miscellaneous Home Services. More services. @end menu @c In addition to that Home Services can provide @@ -44210,6 +44220,45 @@ Media Home Services @end table @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 @subsection Miscellaneous Home Services diff --git a/gnu/home/services/syncthing.scm b/gnu/home/services/syncthing.scm new file mode 100644 index 0000000000..9c9eb94ea1 --- /dev/null +++ b/gnu/home/services/syncthing.scm @@ -0,0 +1,30 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2023 Ludovic Courtès +;;; +;;; 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 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))))) diff --git a/gnu/local.mk b/gnu/local.mk index b496b53a97..d98ecfb7b4 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -104,6 +104,7 @@ GNU_SYSTEM_MODULES = \ %D%/home/services/shepherd.scm \ %D%/home/services/sound.scm \ %D%/home/services/ssh.scm \ + %D%/home/services/syncthing.scm \ %D%/home/services/mcron.scm \ %D%/home/services/utils.scm \ %D%/home/services/xdg.scm \ diff --git a/gnu/services/syncthing.scm b/gnu/services/syncthing.scm index 8f94aef088..f97a1a2ff4 100644 --- a/gnu/services/syncthing.scm +++ b/gnu/services/syncthing.scm @@ -48,32 +48,38 @@ (define-record-type* (group syncthing-configuration-group ;string (default "users")) (home syncthing-configuration-home ;string - (default #f))) + (default #f)) + (home-service? syncthing-configuration-home-service? + (default for-home?) (innate))) (define syncthing-shepherd-service (match-record-lambda - (syncthing arguments logflags user group home) + (syncthing arguments logflags user group home home-service?) (list (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.") - (requirement '(loopback)) + (requirement (if home-service? '() '(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 + #:user #$(and (not home-service?) user) + #:group #$(and (not home-service?) 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))) + (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))))))