diff mbox series

[bug#71639,WIP,3/5] services: backup: Add extra-packages field to restic-backup-job

Message ID 146d362c149771810d673e927b56d3ec44bc9bba.1718747513.git.richard@freakingpenguin.com
State New
Headers show
Series Improve on restic-backup-service | expand

Commit Message

Richard Sent June 18, 2024, 10:08 p.m. UTC
* gnu/services/backup.scm (restic-backup-job): Create extra-packages.
(restic-guix-wrapper-package): Add the extra-packages field of every job as
inputs.
* doc/guix.texi (Miscellaneous Services): Document it.

Change-Id: I4f0b070bc6dc895553ba69256d14e45898291c02
---
 doc/guix.texi           |  4 ++++
 gnu/services/backup.scm | 33 ++++++++++++++++++++-------------
 2 files changed, 24 insertions(+), 13 deletions(-)
diff mbox series

Patch

diff --git a/doc/guix.texi b/doc/guix.texi
index f22d679023..32ce0c86b9 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -41367,6 +41367,10 @@  Miscellaneous Services
 @item @code{verbose?} (default: @code{#f}) (type: boolean)
 Whether to enable verbose output for the current backup job.
 
+@item @code{extra-packages} (default: @code{'()} (type: list-of-packages)
+The list of extra packages needed for restic to run the current backup
+job.
+
 @item @code{extra-flags} (default: @code{'()}) (type: list-of-lowerables)
 A list of values that are lowered to strings.  These will be passed as
 command-line arguments to the current job @command{restic backup}
diff --git a/gnu/services/backup.scm b/gnu/services/backup.scm
index 2471d0ea7b..a6d8404a5a 100644
--- a/gnu/services/backup.scm
+++ b/gnu/services/backup.scm
@@ -41,6 +41,7 @@  (define-module (gnu services backup)
             restic-backup-job-files
             restic-backup-job-init?
             restic-backup-job-verbose?
+            restic-backup-job-extra-packages
             restic-backup-job-extra-flags
 
             restic-backup-configuration
@@ -102,6 +103,9 @@  (define-configuration/no-serialization restic-backup-job
    (list-of-lowerables '())
    "The list of files or directories to be backed up.  It must be a list of
 values that can be lowered to strings.")
+  (extra-packages
+   (list-of-packages '())
+   "The list of extra packages needed for restic to run this backup job.")
   (verbose?
    (boolean #f)
    "Whether to enable verbose output for the current backup job.")
@@ -239,22 +243,25 @@  (define (restic-backup-job->mcron-job config)
            #:user #$user)))
 
 (define (restic-guix-wrapper-package jobs)
-  (package
-    (name "restic-backup-service-wrapper")
-    (version "0.0.0")
-    (source (restic-guix jobs))
-    (build-system copy-build-system)
-    (arguments
-     (list #:install-plan #~'(("./" "/bin"))))
-    (home-page "https://restic.net")
-    (synopsis
-     "Easily interact from the CLI with Guix configured backups")
-    (description
-     "This package provides a simple wrapper around @code{restic}, handled
+  (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))
+      (build-system copy-build-system)
+      (arguments
+       (list #:install-plan #~'(("./" "/bin"))))
+      (home-page "https://restic.net")
+      (synopsis
+       "Easily interact from the CLI with Guix configured backups")
+      (description
+       "This package provides a simple wrapper around @code{restic}, handled
 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.")
-    (license license:gpl3+)))
+      (inputs extra-packages)
+      (license license:gpl3+))))
 
 (define restic-backup-service-profile
   (lambda (config)