Subject: Re: bug#76169: home: Add home-restic-backup service.

From: Ludovic Courtès <[email-masked]>
Date: Thu, 13 Feb 2025 12:48:02 +0100

Hi,

Giacomo Leidi <[email-masked]> skribis:

> +(define (restic-backup-job->home-shepherd-service config)
> +  (let ((schedule (restic-backup-job-schedule config))
> +        (name (restic-backup-job-name config))
> +        (files (restic-backup-job-files config))
> +        (max-duration (restic-backup-job-max-duration config))
> +        (wait-for-termination? (restic-backup-job-wait-for-termination? config))
> +        (log-file (home-restic-job-log-file config))
> +        (requirement (restic-backup-job-requirement config)))
> +    (shepherd-service (provision `(,(string->symbol name)))
> +                      (requirement
> +                       `(,@requirement))
> +                      (documentation
> +                       "Run @code{restic} backed backups on a regular basis.")
> +                      (modules '((shepherd service timer)
> +                                 ;;for %user-log-dir
> +                                 (shepherd support)))
> +                      (start
> +                       #~(make-timer-constructor
> +                          (if (string? #$schedule)
> +                              (cron-string->calendar-event #$schedule)
> +                              #$schedule)

Instead of duplicating the whole thing, I’d suggest using ‘for-home?’ as
is done for example with ‘home-dicod-service-type’.  That way, we end up
with a single source that works for both system and home services.

Ludo’.