[PATCH 0/4] Adding the 'timer' and 'transient' Shepherd services

  • Done
  • quality assurance status badge
Details
2 participants
  • Ludovic Courtès
  • Maxim Cournoyer
Owner
unassigned
Submitted by
Ludovic Courtès
Severity
normal

Debbugs page

Ludovic Courtès wrote 2 months ago
(address . guix-patches@gnu.org)(name . Ludovic Courtès)(address . ludo@gnu.org)
cover.1737152077.git.ludo@gnu.org
Hello!

Shepherd party! 🐑🎉

This patch series adds the famous ‘transient’ and ‘timer’ services
from Shepherd 1.0 that everyone has been waiting for.

Thoughts?

Ludo’.

Ludovic Courtès (4):
services: shepherd: Add ‘transient’ and ‘timer’.
services: Add the Shepherd’s ‘transient’ and ‘timer’ to
‘%base-services’.
home: services: shepherd: Add ‘transient’ and ‘timer’ services.
home: services: Add ‘transient’ and ‘timer’ to ‘%base-home-services’.

doc/guix.texi | 45 +++++++++++++++++++++++++++
gnu/home.scm | 7 +++--
gnu/home/services/shepherd.scm | 21 +++++++++++--
gnu/services/base.scm | 4 +++
gnu/services/shepherd.scm | 56 ++++++++++++++++++++++++++++++++--
5 files changed, 127 insertions(+), 6 deletions(-)


base-commit: a42d57a935009e4dd9b9e9464458540def2cb576
--
2.47.1
Ludovic Courtès wrote 2 months ago
[PATCH 1/4] services: shepherd: Add ‘tran sient’ and ‘timer’.
(address . 75637@debbugs.gnu.org)(name . Ludovic Courtès)(address . ludo@gnu.org)
cb5e08911572a5b7a845e8120f3e7593bf8f0bab.1737152077.git.ludo@gnu.org
* gnu/services/shepherd.scm (shepherd-timer-service-type)
(shepherd-transient-service-type): New variables.
* doc/guix.texi (Shepherd Services): Document them.

Change-Id: I9b622e7e947e7a6384c2701a313d0c7080a0a5f6
---
doc/guix.texi | 33 ++++++++++++++++++++++++
gnu/services/shepherd.scm | 54 +++++++++++++++++++++++++++++++++++++--
2 files changed, 85 insertions(+), 2 deletions(-)

Toggle diff (120 lines)
diff --git a/doc/guix.texi b/doc/guix.texi
index 0015d739bb..3e377ca9f4 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -45684,6 +45684,39 @@ Shepherd Services
(shepherd my-shepherd))))))
@end lisp
+@cindex @code{transient} service, Shepherd
+@defvar shepherd-transient-service-type
+This service type represents the Shepherd's @code{transient} service,
+which lets you spawn commands in the background and interact with them
+as regular Shepherd service; it is similar to @command{systemd-run}.
+
+For example, the command below spawns @command{rsync} in the background,
+in an environment where the @env{SSH_AUTH_SOCK} environment variable has
+the given value:
+
+@example
+herd spawn transient -E SSH_AUTH_SOCK=$SSH_AUTH_SOCK -- \
+ rsync -e ssh -vur . backup.example.org:
+@end example
+
+@xref{Transient Service Maker,,, shepherd, The GNU Shepherd Manual}, for
+more info on the @code{transient} service.
+@end defvar
+
+@cindex @code{timer} service, Shepherd
+@defvar shepherd-timer-service-type
+This is the service type representing the Shepherd's @code{timer}
+service, which lets you schedule the execution of commands, similar to
+the venerable @command{at} command. Here is an example:
+
+@example
+herd schedule timer at 07:00 -- mpg123 Music/alarm.mp3
+@end example
+
+@xref{Timer Service,,, shepherd, The GNU Shepherd Manual}, for more info
+on the @code{timer} service.
+@end defvar
+
@defvar %shepherd-root-service
This service represents PID@tie{}1.
@end defvar
diff --git a/gnu/services/shepherd.scm b/gnu/services/shepherd.scm
index 0de3c9c55c..5f2625ac20 100644
--- a/gnu/services/shepherd.scm
+++ b/gnu/services/shepherd.scm
@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2013-2016, 2018-2024 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2013-2016, 2018-2025 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2017 Clément Lassieur <clement@lassieur.org>
;;; Copyright © 2018 Carlo Zancanaro <carlo@zancanaro.id.au>
;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
@@ -81,6 +81,8 @@ (define-module (gnu services shepherd)
shepherd-service-upgrade
user-processes-service-type
+ shepherd-timer-service-type
+ shepherd-transient-service-type
assert-valid-graph))
@@ -668,4 +670,52 @@ (define user-processes-service-type
seconds after @code{SIGTERM} has been sent are terminated with
@code{SIGKILL}.")))
-;;; shepherd.scm ends here
+
+;;;
+;;; Timer and transient service maker.
+;;;
+
+(define shepherd-timer-service-type
+ (shepherd-service-type
+ 'shepherd-timer
+ (const (shepherd-service
+ (provision '(timer))
+ (requirement '(user-processes))
+ (modules '((shepherd service timer)))
+ (free-form #~(timer-service
+ '#$provision
+ #:requirement '#$requirement))))
+ #t ;ignored
+ (description "The Shepherd @code{timer} service lets you schedule commands
+dynamically, similar to the @code{at} command that your grandparents would use
+on that Slackware they got on a floppy disk. For example, consider this
+command:
+
+@example
+herd schedule timer at 07:00 -- mpg123 Music/alarm.mp3
+@end example
+
+It does exactly what you would expect.")))
+
+(define shepherd-transient-service-type
+ (shepherd-service-type
+ 'shepherd-transient
+ (const (shepherd-service
+ (provision '(transient))
+ (requirement '(user-processes))
+ (modules '((shepherd service transient)))
+ (free-form #~(transient-service
+ '#$provision
+ #:requirement '#$requirement))))
+ #t ;ignored
+ (description "The Shepherd @code{transient} service lets you run commands
+asynchronously, in the background, similar to @command{systemd-run}, as in
+this example:
+
+@example
+herd spawn transient -E SSH_AUTH_SOCK=$SSH_AUTH_SOCK -- \\
+ rsync -e ssh -vur . backup.example.org:
+@end example
+
+This runs @command{rsync} in the background, as a service that you can inspect
+with @command{herd status} and stop with @command{herd stop}.")))
--
2.47.1
Ludovic Courtès wrote 2 months ago
[PATCH 2/4] services: Add the Shepherd’s ‘transient’ and ‘timer’ to ‘%base-services’.
(address . 75637@debbugs.gnu.org)(name . Ludovic Courtès)(address . ludo@gnu.org)
c73d1431aac07bb2a570484089b524895eb98595.1737152077.git.ludo@gnu.org
* gnu/services/base.scm (%base-services): Add instances of
‘shepherd-timer-service-type’ and ‘shepherd-transient-service-type’.

Change-Id: I28a35d0dce40b142ee71b330b1cf7a3d222ef6bd
---
gnu/services/base.scm | 4 ++++
gnu/services/shepherd.scm | 34 ++++++++++++++++++----------------
2 files changed, 22 insertions(+), 16 deletions(-)

Toggle diff (69 lines)
diff --git a/gnu/services/base.scm b/gnu/services/base.scm
index 5967457002..7331c030d7 100644
--- a/gnu/services/base.scm
+++ b/gnu/services/base.scm
@@ -3750,6 +3750,10 @@ (define %base-services
(service log-rotation-service-type)
+ ;; Convenient services brought by the Shepherd.
+ (service shepherd-timer-service-type)
+ (service shepherd-transient-service-type)
+
;; Periodically delete old build logs.
(service log-cleanup-service-type
(log-cleanup-configuration
diff --git a/gnu/services/shepherd.scm b/gnu/services/shepherd.scm
index 5f2625ac20..328bfbedff 100644
--- a/gnu/services/shepherd.scm
+++ b/gnu/services/shepherd.scm
@@ -678,14 +678,15 @@ (define user-processes-service-type
(define shepherd-timer-service-type
(shepherd-service-type
'shepherd-timer
- (const (shepherd-service
- (provision '(timer))
- (requirement '(user-processes))
- (modules '((shepherd service timer)))
- (free-form #~(timer-service
- '#$provision
- #:requirement '#$requirement))))
- #t ;ignored
+ (lambda (requirement)
+ (shepherd-service
+ (provision '(timer))
+ (requirement requirement)
+ (modules '((shepherd service timer)))
+ (free-form #~(timer-service
+ '#$provision
+ #:requirement '#$requirement))))
+ '(user-processes)
(description "The Shepherd @code{timer} service lets you schedule commands
dynamically, similar to the @code{at} command that your grandparents would use
on that Slackware they got on a floppy disk. For example, consider this
@@ -700,14 +701,15 @@ (define shepherd-timer-service-type
(define shepherd-transient-service-type
(shepherd-service-type
'shepherd-transient
- (const (shepherd-service
- (provision '(transient))
- (requirement '(user-processes))
- (modules '((shepherd service transient)))
- (free-form #~(transient-service
- '#$provision
- #:requirement '#$requirement))))
- #t ;ignored
+ (lambda (requirement)
+ (shepherd-service
+ (provision '(transient))
+ (requirement requirement)
+ (modules '((shepherd service transient)))
+ (free-form #~(transient-service
+ '#$provision
+ #:requirement '#$requirement))))
+ '(user-processes)
(description "The Shepherd @code{transient} service lets you run commands
asynchronously, in the background, similar to @command{systemd-run}, as in
this example:
--
2.47.1
Ludovic Courtès wrote 2 months ago
[PATCH 3/4] home: services: shepherd: Add ‘transient’ and ‘timer’ s ervices.
(address . 75637@debbugs.gnu.org)(name . Ludovic Courtès)(address . ludo@gnu.org)
c784469b98168a15bd551aa1b8bbf320cf452f4d.1737152077.git.ludo@gnu.org
* gnu/home/services/shepherd.scm (home-shepherd-timer-service-type)
(home-shepherd-transient-service-type): New variables.
* doc/guix.texi (Shepherd Home Service): Document them.
(Shepherd Services): Add anchor.

Change-Id: Ia4eb7cf043f4661c64f5ca81b8989a451532aa18
---
doc/guix.texi | 12 ++++++++++++
gnu/home/services/shepherd.scm | 21 +++++++++++++++++++--
2 files changed, 31 insertions(+), 2 deletions(-)

Toggle diff (75 lines)
diff --git a/doc/guix.texi b/doc/guix.texi
index 3e377ca9f4..a33f2f3083 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -45684,6 +45684,7 @@ Shepherd Services
(shepherd my-shepherd))))))
@end lisp
+@anchor{shepherd-transient-timer-services}
@cindex @code{transient} service, Shepherd
@defvar shepherd-transient-service-type
This service type represents the Shepherd's @code{transient} service,
@@ -47347,6 +47348,17 @@ Shepherd Home Service
This service is part of @code{%base-home-services}.
@end defvar
+@defvar home-shepherd-transient-service-type
+@defvarx home-shepherd-timer-service-type
+These are the @code{timer} and @code{transient} Shepherd services. The
+former lets you schedule command execution for later, while the latter
+can run commands in the background as a regular service.
+
+@xref{shepherd-transient-timer-services, the system @code{timer} and
+@code{transient} services}, which are their Guix System counterparts,
+for more info.
+@end defvar
+
@node Secure Shell
@subsection Secure Shell
diff --git a/gnu/home/services/shepherd.scm b/gnu/home/services/shepherd.scm
index 37ad1489d6..b2b141d4de 100644
--- a/gnu/home/services/shepherd.scm
+++ b/gnu/home/services/shepherd.scm
@@ -1,7 +1,7 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2021, 2023 Andrew Tropin <andrew@trop.in>
;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz>
-;;; Copyright © 2024 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2024-2025 Ludovic Courtès <ludo@gnu.org>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -34,7 +34,10 @@ (define-module (gnu home services shepherd)
home-shepherd-configuration-auto-start?
home-shepherd-configuration-daemonize?
home-shepherd-configuration-silent?
- home-shepherd-configuration-services)
+ home-shepherd-configuration-services
+
+ home-shepherd-transient-service-type
+ home-shepherd-timer-service-type)
#:re-export (shepherd-service
shepherd-service?
shepherd-service-documentation
@@ -181,3 +184,17 @@ (define home-shepherd-service-type
(define-service-type-mapping
shepherd-root-service-type => home-shepherd-service-type)
+
+;;;
+;;; Timer and transient service maker.
+;;;
+
+(define home-shepherd-timer-service-type
+ (service-type
+ (inherit (system->home-service-type shepherd-timer-service-type))
+ (default-value '()))) ;requirement
+
+(define home-shepherd-transient-service-type
+ (service-type
+ (inherit (system->home-service-type shepherd-transient-service-type))
+ (default-value '()))) ;requirement
--
2.47.1
Ludovic Courtès wrote 2 months ago
[PATCH 4/4] home: services: Add ‘transien t’ and ‘timer’ to ‘%bas e-home-services’.
(address . 75637@debbugs.gnu.org)(name . Ludovic Courtès)(address . ludo@gnu.org)
c4b557c6745a7dd90c9c25617be5ec6b2bfd1aaa.1737152078.git.ludo@gnu.org
* gnu/home.scm (%base-home-services): Add
‘home-shepherd-timer-service-type’ and
‘home-shepherd-transient-service-type’.

Change-Id: Ib48744b82c7e4c6ff6b8ac3d669774feda813f4b
---
gnu/home.scm | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)

Toggle diff (33 lines)
diff --git a/gnu/home.scm b/gnu/home.scm
index 3b479f64f9..1172b1a0ab 100644
--- a/gnu/home.scm
+++ b/gnu/home.scm
@@ -1,6 +1,6 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2021 Andrew Tropin <andrew@trop.in>
-;;; Copyright © 2022, 2024 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2022, 2024-2025 Ludovic Courtès <ludo@gnu.org>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -21,6 +21,7 @@ (define-module (gnu home)
#:use-module (gnu home services)
#:use-module (gnu home services symlink-manager)
#:use-module (gnu home services shells)
+ #:use-module (gnu home services shepherd)
#:use-module (gnu home services xdg)
#:use-module (gnu home services fontutils)
#:use-module (gnu home services admin)
@@ -80,7 +81,9 @@ (define-record-type* <home-environment> home-environment
(define %base-home-services
;; Non-essential but useful services to have by default.
- (list (service home-log-rotation-service-type)))
+ (list (service home-log-rotation-service-type)
+ (service home-shepherd-timer-service-type)
+ (service home-shepherd-transient-service-type)))
(define (home-environment-default-essential-services he)
"Return the list of essential services for home environment."
--
2.47.1
Maxim Cournoyer wrote 2 months ago
Re: [bug#75637] [PATCH 3/4] home: services: shepherd: Add ‘transient’ and ‘timer’ services.
(name . Ludovic Courtès)(address . ludo@gnu.org)
87h65v8802.fsf@gmail.com
Ludovic Courtès <ludo@gnu.org> writes:

Toggle quote (7 lines)
> * gnu/home/services/shepherd.scm (home-shepherd-timer-service-type)
> (home-shepherd-transient-service-type): New variables.
> * doc/guix.texi (Shepherd Home Service): Document them.
> (Shepherd Services): Add anchor.
>
> Change-Id: Ia4eb7cf043f4661c64f5ca81b8989a451532aa18

Reviewed-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>

--
Thanks,
Maxim
Maxim Cournoyer wrote 2 months ago
Re: [bug#75637] [PATCH 4/4] home: services: Add ‘ transient’ and ‘timer’ to ‘%base-home-services ’.
(name . Ludovic Courtès)(address . ludo@gnu.org)
87cygj87za.fsf@gmail.com
Ludovic Courtès <ludo@gnu.org> writes:

Toggle quote (6 lines)
> * gnu/home.scm (%base-home-services): Add
> ‘home-shepherd-timer-service-type’ and
> ‘home-shepherd-transient-service-type’.
>
> Change-Id: Ib48744b82c7e4c6ff6b8ac3d669774feda813f4b

Reviewed-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>

--
Thanks,
Maxim
Ludovic Courtès wrote 1 months ago
(name . Maxim Cournoyer)(address . maxim.cournoyer@gmail.com)
87wmeh5l4i.fsf@gnu.org
Pushed as 4fa122bc4d3ccdca5b4613c3d700558c4af593fe, thank you!
Closed
?
Your comment

This issue is archived.

To comment on this conversation send an email to 75637@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 75637
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch
You may also tag this issue. See list of standard tags. For example, to set the confirmed and easy tags
mumi command -t +confirmed -t +easy
Or, remove the moreinfo tag and set the help tag
mumi command -t -moreinfo -t +help