Subject: [PATCH] services: wireguard: Add the shepherd-requirement field.
From: Sergey Trofimov <[email-masked]>
To: [email-masked]
Cc: Sergey Trofimov <[email-masked]>
Date: Sun, 16 Mar 2025 08:55:37 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

* gnu/services/vpn.scm
(<wireguard-configuration>): Add shepherd-requirement.
(wireguard-shepherd-service): Pass shepherd-requirement.
* doc/guix.texi (VPN Services):[wireguard]: Document it.
---
 doc/guix.texi        | 4 ++++
 gnu/services/vpn.scm | 7 +++++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 883cdc2803..681200e5f9 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -35711,6 +35711,10 @@ VPN Services
 List of strings or G-expressions.  These are script snippets which will
 be executed after tearing down the interface.
 
+@item @code{shepherd-requirement} (default: @code{'()}) (type: list-of-symbols)
+A list of symbols naming Shepherd services that this service
+will depend on.
+
 @item @code{table} (default: @code{"auto"})
 The routing table to which routes are added, as a string.  There are two
 special values: @code{"off"} that disables the creation of routes
diff --git a/gnu/services/vpn.scm b/gnu/services/vpn.scm
index 478a0d543e..2b5886c9fa 100644
--- a/gnu/services/vpn.scm
+++ b/gnu/services/vpn.scm
@@ -88,6 +88,7 @@ (define-module (gnu services vpn)
             wireguard-configuration-post-up
             wireguard-configuration-pre-down
             wireguard-configuration-post-down
+            wireguard-configuration-shepherd-requirement
             wireguard-configuration-table
             wireguard-configuration-auto-start?
 
@@ -765,6 +766,8 @@ (define-record-type* <wireguard-configuration>
                           (default '()))
   (post-down              wireguard-configuration-post-down ;list of strings
                           (default '()))
+  (shepherd-requirement   wireguard-configuration-shepherd-requirement ; list of symbols
+                          (default '()))
   (table                  wireguard-configuration-table ;string
                           (default "auto"))
   (auto-start?            wireguard-configuration-auto-start? ;boolean
@@ -918,12 +921,12 @@ (define (endpoint-host-names peers)
 
 (define (wireguard-shepherd-service config)
   (match-record config <wireguard-configuration>
-    (wireguard interface)
+    (wireguard interface shepherd-requirement)
     (let ((wg-quick (file-append wireguard "/bin/wg-quick"))
           (auto-start? (wireguard-configuration-auto-start? config))
           (config (wireguard-configuration-file config)))
       (list (shepherd-service
-             (requirement '(networking))
+             (requirement `(networking ,@shepherd-requirement))
              (provision (list (wireguard-service-name interface)))
              (start #~(lambda _
                        (invoke #$wg-quick "up" #$config)))

base-commit: b8024fa1ade69a4f97990f0e3379eef01dfd40c2
prerequisite-patch-id: f9cc903b8048c8c6fde576fbf38ab110263020e3
prerequisite-patch-id: 54f1264dad23a74efa9aa3823350b2ee055bda97
prerequisite-patch-id: 220ddf11addf3a6c7ab3b349077bca6849241556
prerequisite-patch-id: 18f3d7d0a9ed1f267adeb3630b3801a0c179d9ea
-- 
2.48.1