From 7f4c9783cad8e3574ab43a6dec9e13713ef3311b Mon Sep 17 00:00:00 2001 From: apoorv569 Date: Wed, 25 Sep 2024 09:10:36 +0530 Subject: [PATCH V3] Wireguard: Add auto-start? field --- doc/guix.texi | 4 ++++ gnu/services/vpn.scm | 9 +++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 52e36e4354..50676997e2 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -34396,6 +34396,10 @@ special values: @code{"off"} that disables the creation of routes altogether, and @code{"auto"} (the default) that adds routes to the default table and enables special handling of default routes. +@item @code{auto-start?} (default: @code{#t}) (type: boolean) +Whether the service should be started automatically. If it +is @code{#f} the service has to be started manually with @command{herd start}. + @end table @end deftp diff --git a/gnu/services/vpn.scm b/gnu/services/vpn.scm index 449909e34d..1b0cc4d337 100644 --- a/gnu/services/vpn.scm +++ b/gnu/services/vpn.scm @@ -86,6 +86,7 @@ (define-module (gnu services vpn) wireguard-configuration-pre-down wireguard-configuration-post-down wireguard-configuration-table + wireguard-configuration-autostart? wireguard-service-type)) @@ -760,7 +761,9 @@ (define-record-type* (post-down wireguard-configuration-post-down ;list of strings (default '())) (table wireguard-configuration-table ;string - (default "auto"))) + (default "auto")) + (auto-start? wireguard-configuration-autostart? ;boolean + (default #t))) (define (wireguard-configuration-file config) (define (peer->config peer) @@ -907,7 +910,8 @@ (define (wireguard-shepherd-service config) (match-record config (wireguard interface) (let ((wg-quick (file-append wireguard "/bin/wg-quick")) - (config (wireguard-configuration-file config))) + (config (wireguard-configuration-file config)) + (autostart (wireguard-configuration-autostart? config))) (list (shepherd-service (requirement '(networking)) (provision (list (wireguard-service-name interface))) @@ -916,6 +920,7 @@ (define (wireguard-shepherd-service config) (stop #~(lambda _ (invoke #$wg-quick "down" #$config) #f)) ;stopped! + (auto-start? autostart) (actions (list (shepherd-configuration-action config))) (documentation "Run the Wireguard VPN tunnel")))))) -- 2.46.0