From patchwork Tue Jun 18 22:08:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sent X-Patchwork-Id: 65481 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 47AFC27BBE2; Tue, 18 Jun 2024 23:10:42 +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=unavailable 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 6770827BBF1 for ; Tue, 18 Jun 2024 23:10:31 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sJh1h-0005it-5I; Tue, 18 Jun 2024 18:10:05 -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 1sJh1f-0005iF-PQ for guix-patches@gnu.org; Tue, 18 Jun 2024 18:10:03 -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 1sJh1f-0003KO-E7; Tue, 18 Jun 2024 18:10:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sJh1g-00034y-7J; Tue, 18 Jun 2024 18:10:04 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#71639] [PATCH WIP 4/5] services: backup: Move restic package to restic-configuration Resent-From: Richard Sent Original-Sender: "Debbugs-submit" Resent-CC: pelzflorian@pelzflorian.de, ludo@gnu.org, matt@excalamus.com, maxim.cournoyer@gmail.com, guix-patches@gnu.org Resent-Date: Tue, 18 Jun 2024 22:10:04 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 71639 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 71639@debbugs.gnu.org Cc: ludo@gnu.org, Richard Sent , goodoldpaul@autistici.org, Florian Pelz , Ludovic =?utf-8?q?Court=C3=A8s?= , Matthew Trzcinski , Maxim Cournoyer X-Debbugs-Original-Xcc: Florian Pelz , Ludovic =?utf-8?q?Court=C3=A8s?= , Matthew Trzcinski , Maxim Cournoyer Received: via spool by 71639-submit@debbugs.gnu.org id=B71639.171874857711724 (code B ref 71639); Tue, 18 Jun 2024 22:10:04 +0000 Received: (at 71639) by debbugs.gnu.org; 18 Jun 2024 22:09:37 +0000 Received: from localhost ([127.0.0.1]:53639 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sJh1E-00032z-Gg for submit@debbugs.gnu.org; Tue, 18 Jun 2024 18:09:37 -0400 Received: from mail-108-mta24.mxroute.com ([136.175.108.24]:35981) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sJh1B-00032e-VO for 71639@debbugs.gnu.org; Tue, 18 Jun 2024 18:09:34 -0400 Received: from filter006.mxroute.com ([136.175.111.3] filter006.mxroute.com) (Authenticated sender: mN4UYu2MZsgR) by mail-108-mta24.mxroute.com (ZoneMTA) with ESMTPSA id 1902d65d4ed00017a3.002 for <71639@debbugs.gnu.org> (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Tue, 18 Jun 2024 22:09:26 +0000 X-Zone-Loop: b0f797caa8b26b55f62ccc43adef6761ab86e5f6f5c1 X-Originating-IP: [136.175.111.3] DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=freakingpenguin.com; s=x; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=PKqw4pzLvQWWJgeYjeiLEkGEn5gc6aE57W3QVB6MVzE=; b=lsqZl3daCbP2iR3NSryfK1JdwY RYqXKX/iGhu4p5/PZuYobhcabuspZIioL9wR4M6JVWs92FeSdALOK4pC5n4GzDXT7of0Z+UZMBOR8 gpbJwUZHOZ9oqDpK/vqlNFaQPcOOa/0XAW8caOtwb8wjTy/o501XZtvRH66Z9vSHN2SkoevulZrcx fPYQWUNjBuRO5/UidI9j7px+8U8Vxko0HaDs9mFbOAMpFnwrYlYMmUBO/hmtBDMKLBZgKMdaF/7/r Eg+L2m9Snblu9zIhoaEYHZ+vQ47nJs02JKX/shEpHt3duED73PNmuVAYTKrCZ/sL6nYbp7ETfTTpJ 2o/XkEKA==; From: Richard Sent Date: Tue, 18 Jun 2024 18:08:51 -0400 Message-ID: <7749ca0f06a80cf9accd24dc62fa8896cd35625d.1718747513.git.richard@freakingpenguin.com> In-Reply-To: References: MIME-Version: 1.0 X-Authenticated-Id: richard@freakingpenguin.com 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/services/backup.scm (restic-backup-configuration): Add restic field. (restic-backup-job-program): Add restic package to function signature. (restic-guix): Ditto. (restic-guix-wrapper-package): Ditto. Add restic package as package input. (restic-backup-service-profile): Remove excess lamba. * doc/guix.texi (Miscellaneous Services): Document it. Change-Id: I1e5f63c21cd072354225afe0ee270dca8d9d840b --- doc/guix.texi | 6 +++--- gnu/services/backup.scm | 38 ++++++++++++++++++++------------------ 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 32ce0c86b9..e4379c5e1c 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -41311,6 +41311,9 @@ Miscellaneous Services Available @code{restic-backup-configuration} fields are: @table @asis +@item @code{restic} (default: @code{restic}) (type: package) +The restic package to use for all jobs. + @item @code{jobs} (default: @code{'()}) (type: list-of-restic-backup-jobs) The list of backup jobs for the current system. @@ -41327,9 +41330,6 @@ Miscellaneous Services Available @code{restic-backup-job} fields are: @table @asis -@item @code{restic} (default: @code{restic}) (type: package) -The restic package to be used for the current job. - @item @code{user} (default: @code{"root"}) (type: string) The user used for running the current job. diff --git a/gnu/services/backup.scm b/gnu/services/backup.scm index a6d8404a5a..a59cf08c71 100644 --- a/gnu/services/backup.scm +++ b/gnu/services/backup.scm @@ -29,10 +29,10 @@ (define-module (gnu services backup) #:use-module (guix modules) #:use-module (guix packages) #:use-module (srfi srfi-1) + #:use-module (srfi srfi-26) #:export (restic-backup-job restic-backup-job? restic-backup-job-fields - restic-backup-job-restic restic-backup-job-user restic-backup-job-name restic-backup-job-repository @@ -46,6 +46,7 @@ (define-module (gnu services backup) restic-backup-configuration restic-backup-configuration? + restic-backup-configuration-restic restic-backup-configuration-fields restic-backup-configuration-jobs @@ -71,9 +72,6 @@ (define-maybe/no-serialization string) (define-maybe/no-serialization file-like) (define-configuration/no-serialization restic-backup-job - (restic - (package restic) - "The restic package to be used for the current job.") (user (string "root") "The user used for running the current job.") @@ -129,11 +127,14 @@ (define list-of-restic-backup-jobs? (list-of restic-backup-job?)) (define-configuration/no-serialization restic-backup-configuration + (restic + (package restic) + "The restic package to be used.") (jobs (list-of-restic-backup-jobs '()) "The list of backup jobs for the current system.")) -(define (restic-backup-job-program config) +(define (restic-backup-job-program restic-package config) (define (maybe-value-or-false maybe) (if (maybe-value-set? maybe) maybe @@ -143,7 +144,7 @@ (define (restic-backup-job-program config) (verify-restic-backup-job-configuration config) (let ((restic - (file-append (restic-backup-job-restic config) "/bin/restic")) + (file-append restic-package "/bin/restic")) (repository (restic-backup-job-repository config)) (password-file @@ -191,7 +192,7 @@ (define (restic-backup-job-program config) #$@extra-flags "backup" #$@files))))) -(define (restic-guix jobs) +(define (restic-guix restic-package jobs) (program-file "restic-guix" #~(begin @@ -199,7 +200,7 @@ (define (restic-guix jobs) (srfi srfi-1)) (define names '#$(map restic-backup-job-name jobs)) - (define programs '#$(map restic-backup-job-program jobs)) + (define programs '#$(map (cut restic-backup-job-program restic-package <>) jobs)) (define (get-program name) (define idx @@ -242,13 +243,13 @@ (define (restic-backup-job->mcron-job config) #$(string-append "restic-guix backup " name) #:user #$user))) -(define (restic-guix-wrapper-package jobs) +(define (restic-guix-wrapper-package restic jobs) (let ((extra-packages (append-map restic-backup-job-extra-packages jobs))) (package (name "restic-backup-service-wrapper") (version "0.0.0") - (source (restic-guix restic-package jobs)) + (source (restic-guix restic jobs)) (build-system copy-build-system) (arguments (list #:install-plan #~'(("./" "/bin")))) @@ -260,16 +261,17 @@ (define (restic-guix-wrapper-package jobs) by the @code{restic-backup-service-type}. It allows for easily interacting with Guix configured backup jobs, for example for manually triggering a backup without waiting for the scheduled job to run.") - (inputs extra-packages) + (inputs (cons restic extra-packages)) (license license:gpl3+)))) -(define restic-backup-service-profile - (lambda (config) - (define jobs (restic-backup-configuration-jobs config)) - (if (> (length jobs) 0) - (list - (restic-guix-wrapper-package jobs)) - '()))) +(define (restic-backup-service-profile config) + (let ((jobs (restic-backup-configuration-jobs config)) + (restic (restic-backup-configuration-restic config))) + ;; Even if we provide a wrapper we need to add restic to the profile so + ;; the service works in containers and VMs which only see a subset of + ;; /gnu/store. https://issues.guix.gnu.org/70553. Ergo pass restic to + ;; the wrapper package so it is added as an input. + (list (restic-guix-wrapper-package restic jobs)))) (define restic-backup-service-type (service-type (name 'restic-backup)