services: shepherd: Factorize ‘trigger’ action.

* gnu/services/shepherd.scm (shepherd-trigger-action): New variable.
* gnu/services/admin.scm (log-cleanup-shepherd-services)
(unattended-upgrade-shepherd-services): Use it.
* gnu/services/backup.scm (restic-backup-job->shepherd-service): Use it.
* gnu/home/services/shepherd.scm: Re-export ‘shepherd-trigger-action’.

Reviewed-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
Change-Id: I834b5b9b61c78f012ee9306df6cf4fd8a93dd6d2
This commit is contained in:
Ludovic Courtès 2025-03-12 11:32:54 +01:00
parent 6de8771a14
commit aed019b646
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5
4 changed files with 13 additions and 14 deletions

View file

@ -52,7 +52,8 @@
shepherd-service-modules
shepherd-action
shepherd-configuration-action))
shepherd-configuration-action
shepherd-trigger-action))
(define-record-type* <home-shepherd-configuration>
home-shepherd-configuration make-home-shepherd-configuration

View file

@ -404,10 +404,7 @@ This service is deprecated and slated for removal after 2025-06-15.")
schedule)
(command '(#$program))))
(stop #~(make-timer-destructor))
(actions (list (shepherd-action
(name 'trigger)
(documentation "Trigger log cleanup.")
(procedure #~trigger-timer))))
(actions (list shepherd-trigger-action))
(documentation "Periodically delete old log files."))))))
(define log-cleanup-service-type
@ -671,10 +668,7 @@ which lets you search for packages that provide a given file.")
;; again.
#:wait-for-termination? #t))
(stop #~(make-timer-destructor))
(actions (list (shepherd-action
(name 'trigger)
(documentation "Trigger unattended system upgrade.")
(procedure #~trigger-timer)))))))
(actions (list shepherd-trigger-action)))))
(define unattended-upgrade-service-type
(service-type

View file

@ -255,11 +255,7 @@ command-line arguments to the current job @command{restic backup} invocation."))
max-duration)))
(stop
#~(make-timer-destructor))
(actions (list (shepherd-action
(name 'trigger)
(documentation "Manually trigger a backup,
without waiting for the scheduled time.")
(procedure #~trigger-timer)))))))
(actions (list shepherd-trigger-action)))))
(define (restic-guix-wrapper-package jobs)
(package

View file

@ -72,6 +72,7 @@
shepherd-action-procedure
shepherd-configuration-action
shepherd-trigger-action
%default-modules
@ -404,6 +405,13 @@ of the service's configuration file."
(format #t "~a~%" #$file)
#$file))))
(define shepherd-trigger-action
;; Action to trigger a timer.
(shepherd-action
(name 'trigger)
(documentation "Trigger immediate execution of this timer.")
(procedure #~trigger-timer)))
(define (shepherd-configuration-file services shepherd)
"Return the shepherd configuration file for SERVICES. SHEPHERD is used
as shepherd package."