From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id INToIrcJHGQIfQEASxT56A (envelope-from ) for ; Thu, 23 Mar 2023 09:11:35 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id 0ILVIrcJHGQCmQAAauVa8A (envelope-from ) for ; Thu, 23 Mar 2023 09:11:35 +0100 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 0804917B50 for ; Thu, 23 Mar 2023 09:11:34 +0100 (CET) Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=sarg.org.ru header.s=google header.b=jSBw9mmm; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1679559095; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=IC55tM44snyqJ+/ijujM4DRcjwXenZd2T/6a7bB1b9Q=; b=uE1G5n+bC0RSbReSHIl4/m1LvjphA/n26J9BlDIYb7iZyUM+7BVrAZi2Aj0zTuTHryp9tt vYY9b503iOVh59li9pYESHVvvfOF79Bahn9tQjaJOwxukS0JVmIY3XvucSyWKy23USGY36 yI+5Udj5oC510SbUuewLd5neCOFCV0JUDeB50RW+6/N7sdjukCz+gfyd84sSNKsWf8qRfp guvi6ZA2ZZ9wuAAaKQ91wBosDcBdlfConv93rV6OVAAbs7tF1cib80fuLWFwU0tWxPqUr1 0uc6gI4v3rOSRIYer9NdH6ohHsZfN6QgUpJGKHjAfLrM5B3O71tOehnxFLJk7A== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1679559095; a=rsa-sha256; cv=none; b=HeKYQrxLhumtIaAvPRMUE1msgAY6VRZNQwz8FidreTeNOcA4qM46TzWEvVLyVkBN5urkfn Jp5gb0iu9hoLJu1Y7I/FPxHAvaxOVJetC488FlQeXpRYgfThhDK5V4FXLmmpgWgC0PQQHe 10CLM4RxjGtyZKIANpPOrSWVdUPkRQTpK54mw8OsLUw7xeTTD61Brv5ZG2EFpaR+XqpFlW L/CX7OgW/jwoUps+qrAopeGjI1Stl8mLhQGkjGFZE5Y8SXSnnbK6hONQg9qYJ/FdnQLcKE ToKvtWQAJZ9U13GWoOHI0Zrx+MZJREdGpbzhazNZQoqHx6iFzKx5P6R8UeXfJQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=sarg.org.ru header.s=google header.b=jSBw9mmm; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=none Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pfG2N-00083T-4p; Thu, 23 Mar 2023 04:11:07 -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 1pfG2K-00082l-PK for guix-patches@gnu.org; Thu, 23 Mar 2023 04:11:04 -0400 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pfG2I-0000rn-RP; Thu, 23 Mar 2023 04:11:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pfG2H-0004jH-T4; Thu, 23 Mar 2023 04:11:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#62401] [PATCH] home: Add home-syncthing-service-type. Resent-From: Sergey Trofimov Original-Sender: "Debbugs-submit" Resent-CC: paren@disroot.org, andrew@trop.in, ludo@gnu.org, guix-patches@gnu.org Resent-Date: Thu, 23 Mar 2023 08:11:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 62401 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 62401@debbugs.gnu.org Cc: Sergey Trofimov , paren@disroot.org, andrew@trop.in, ludo@gnu.org X-Debbugs-Original-To: guix-patches@gnu.org X-Debbugs-Original-Xcc: paren@disroot.org, andrew@trop.in, ludo@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.167955903818141 (code B ref -1); Thu, 23 Mar 2023 08:11:01 +0000 Received: (at submit) by debbugs.gnu.org; 23 Mar 2023 08:10:38 +0000 Received: from localhost ([127.0.0.1]:37261 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pfG1t-0004iX-N2 for submit@debbugs.gnu.org; Thu, 23 Mar 2023 04:10:38 -0400 Received: from lists.gnu.org ([209.51.188.17]:35538) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pfG1r-0004iP-KX for submit@debbugs.gnu.org; Thu, 23 Mar 2023 04:10:36 -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 1pfG1r-000817-3c for guix-patches@gnu.org; Thu, 23 Mar 2023 04:10:35 -0400 Received: from mail-ed1-x52b.google.com ([2a00:1450:4864:20::52b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pfG1o-0000jC-I9 for guix-patches@gnu.org; Thu, 23 Mar 2023 04:10:34 -0400 Received: by mail-ed1-x52b.google.com with SMTP id x3so82888777edb.10 for ; Thu, 23 Mar 2023 01:10:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sarg.org.ru; s=google; t=1679559029; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=IC55tM44snyqJ+/ijujM4DRcjwXenZd2T/6a7bB1b9Q=; b=jSBw9mmmnJzXcYe59ENK4PvkiQ783HTBCxYiFFXayfMFgmofSgNE6aol+WlxxmXNDZ t/IuF0derBP5EO/poSNdhyuB19+iFbI1CkvcG9Pd4ui7ZSryh8C0y3agBikwsWFtoZw0 7soEb66gTt5tlQpuoAZVMN7L7/1qRiOSFbxvQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679559029; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=IC55tM44snyqJ+/ijujM4DRcjwXenZd2T/6a7bB1b9Q=; b=mMHib1Yc2saSV1WUIWoqHAxUIkd9Om9S5jfQQz8gGiPwE+sk0MzYUjO+Pr2PtEUVdq hy962ccV1Ax9hO9jysYrXGe77LdnpshPj+bhsRyvgEfUCWypnsSqqhWwwLiEo25D0e6a 3ISLFp7/++yUftUglMP3ZGKh/1ZrML167PrQFXXWXxt8ujdB6nEYO1QBkFXOAUh/DlLG ARg4hv3LLFPnWvjzMN/hYwxOFOaigfydi+FQNEijh1T0NBqma1butwHhMpEPfyViqe90 wno+o/lp4bioQEKDUWhrZ3iiIlrQ1tB/KBY+g/hLPWHFn+Rl6Rctp9f56Udz2wwxrp/L jPWQ== X-Gm-Message-State: AO0yUKWuUQb5kk2r6S+P3TuCWWnDchfdDZzr1NLvU3EOZvaWbnmLGBnx aGIc9r0lKMU87oi9PcE0g9EAJlPm+FT+TvSeb9M= X-Google-Smtp-Source: AK7set/Ircpz9aM6aLc2nuc8voKJh6EBrTbEdVymTCXJkuaBPI+2PnAD6EYGGwO51mE4KRBvAtPZfA== X-Received: by 2002:a17:906:580c:b0:933:3aa7:57a7 with SMTP id m12-20020a170906580c00b009333aa757a7mr9232455ejq.49.1679559029378; Thu, 23 Mar 2023 01:10:29 -0700 (PDT) Received: from localhost ([95.168.147.255]) by smtp.gmail.com with ESMTPSA id e3-20020a170906504300b00930c6c01c9esm8498224ejk.143.2023.03.23.01.10.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Mar 2023 01:10:29 -0700 (PDT) From: Sergey Trofimov Date: Thu, 23 Mar 2023 09:10:26 +0100 Message-Id: <20230323081026.13850-1-sarg@sarg.org.ru> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Received-SPF: none client-ip=2a00:1450:4864:20::52b; envelope-from=sarg@sarg.org.ru; helo=mail-ed1-x52b.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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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: X-Migadu-Queue-Id: 0804917B50 X-Spam-Score: 0.06 X-Migadu-Spam-Score: 0.06 X-Migadu-Scanner: scn0.migadu.com List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN X-TUID: 3F4YPbF4xnUV * gnu/home/services/syncthing.scm (home-syncthing-service-type): New variable. (home-syncthing-configuration): New procedure. * gnu/services/syncthing.scm (syncthing-shepherd-service): Adapt to be used as a home service. * doc/guix.texi: Ditto. --- doc/guix.texi | 42 ++++++++++++++++++++++++++++- gnu/home/services/syncthing.scm | 48 +++++++++++++++++++++++++++++++++ gnu/services/syncthing.scm | 15 +++++++---- 3 files changed, 99 insertions(+), 6 deletions(-) create mode 100644 gnu/home/services/syncthing.scm diff --git a/doc/guix.texi b/doc/guix.texi index dfdb26103a..a2fe2514db 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -20735,7 +20735,7 @@ List of command-line arguments passing to @code{syncthing} binary. Sum of logging flags, see @uref{https://docs.syncthing.net/users/syncthing.html#cmdoption-logflags, Syncthing documentation logflags}. -@item @code{user} (default: @var{#f}) +@item @code{user} The user as which the Syncthing service is to be run. This assumes that the specified user exists. @@ -41790,6 +41790,7 @@ services)}. * Sound: Sound Home Services. Dealing with audio. * Messaging: Messaging Home Services. Services for managing messaging. * Media: Media Home Services. Services for managing media. +* Networking: Networking Home Services. @end menu @c In addition to that Home Services can provide @@ -42978,6 +42979,45 @@ kodi} for more information. @end table @end deftp +@node Networking Home Services +@subsection Networking Home Services + +@cindex syncthing +With the @code{(gnu home services syncthing)} service, you can configure +@uref{https://github.com/syncthing/syncthing, Syncthing} to run upon +login. + +Here is an example of a service and its configuration that you could add +to the @code{services} field of your @code{home-environment}: + +@lisp +(service home-syncthing-service-type + (home-syncthing-configuration + (arguments '("--paused")))) +@end lisp + +@defvar home-syncthing-service-type +This is the type of the @code{syncthing} home service, whose value is an +@code{home-syncthing-configuration} object. +@end defvar + +@deftp {Data Type} home-syncthing-configuration +Data type representing the configuration for @code{home-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 logging flags, see +@uref{https://docs.syncthing.net/users/syncthing.html#cmdoption-logflags, Syncthing documentation logflags}. + +@end table +@end deftp + @node Invoking guix home @section Invoking @command{guix home} diff --git a/gnu/home/services/syncthing.scm b/gnu/home/services/syncthing.scm new file mode 100644 index 0000000000..928a23986b --- /dev/null +++ b/gnu/home/services/syncthing.scm @@ -0,0 +1,48 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2021 Oleg Pykhalov +;;; Copyright © 2023 Sergey Trofimov +;;; +;;; 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 services syncthing) + #:use-module (gnu services shepherd) + #:use-module (gnu home services shepherd) + + #:export (home-syncthing-service-type + home-syncthing-configuration)) + +(define syncthing-home-shepherd-service + (lambda (configuration) + (map (lambda (srv) (shepherd-service (inherit srv) (requirement '()))) + ((@@ (gnu services syncthing) syncthing-shepherd-service) configuration)))) + +(define-syntax-rule (home-syncthing-configuration args ...) + (syncthing-configuration + (user #f) + args ...)) + +(define home-syncthing-service-type + (service-type (name 'syncthing) + (extensions (list (service-extension home-shepherd-service-type + syncthing-home-shepherd-service))) + (default-value (home-syncthing-configuration)) + (description + "Run @uref{https://github.com/syncthing/syncthing, Syncthing} +decentralized continuous file system synchronization."))) + +;;; syncthing.scm ends here diff --git a/gnu/services/syncthing.scm b/gnu/services/syncthing.scm index 7c3d5b027d..960f0a1db8 100644 --- a/gnu/services/syncthing.scm +++ b/gnu/services/syncthing.scm @@ -43,8 +43,7 @@ (define-record-type* (default '())) (logflags syncthing-configuration-logflags ;number (default 0)) - (user syncthing-configuration-user ;string - (default #f)) + (user syncthing-configuration-user) ;string (group syncthing-configuration-group ;string (default "users")) (home syncthing-configuration-home ;string @@ -55,9 +54,12 @@ (define syncthing-shepherd-service (($ syncthing arguments logflags user group home) (list (shepherd-service - (provision (list (string->symbol (string-append "syncthing-" user)))) + (provision (list + (or (and user (string->symbol (string-append "syncthing-" user))) + 'syncthing))) (documentation "Run syncthing.") (requirement '(loopback)) + (modules '((srfi srfi-1) (shepherd support))) (start #~(make-forkexec-constructor (append (list (string-append #$syncthing "/bin/syncthing") "-no-browser" @@ -65,9 +67,12 @@ (define syncthing-shepherd-service (string-append "-logflags=" (number->string #$logflags))) '#$arguments) #:user #$user - #:group #$group + #:group (and #$user #$group) #:environment-variables - (append (list (string-append "HOME=" (or #$home (passwd:dir (getpw #$user)))) + (append (list (string-append "HOME=" + (or #$home + (and #$user (passwd:dir (getpw #$user))) + user-homedir)) "SSL_CERT_DIR=/etc/ssl/certs" "SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt") (remove (lambda (str) -- 2.39.2