diff options
author | Carlo Zancanaro <carlo@zancanaro.id.au> | 2025-02-28 21:31:10 +1100 |
---|---|---|
committer | Maxim Cournoyer <maxim.cournoyer@gmail.com> | 2025-03-03 00:31:45 +0900 |
commit | 4319fb1aa910181599381d0dd14a21b67dbd7725 (patch) | |
tree | 6b932ba5e8ab540dbcaed2c8d8634e7239857be2 | |
parent | c1bcaba4d88dcca3889e884566310e9abdeead6c (diff) |
services: wireguard: Add the auto-start? field.
* gnu/services/vpn.scm (<wireguard-configuration>): Add auto-start?.
(wireguard-shepherd-service): Pass auto-start? to Shepherd service.
* doc/guix.texi (VPN Services)[wireguard]: Document it.
Change-Id: I7880a8c8e9860250f875e845e94eb118a4b852fa
Signed-off-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
-rw-r--r-- | doc/guix.texi | 8 | ||||
-rw-r--r-- | gnu/services/vpn.scm | 8 |
2 files changed, 14 insertions, 2 deletions
diff --git a/doc/guix.texi b/doc/guix.texi index 0ca109a214..9f5a776202 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -43,7 +43,7 @@ Copyright @copyright{} 2016, 2017, 2018, 2019, 2020, 2021 Christopher Baines@* Copyright @copyright{} 2017, 2018, 2019 Clément Lassieur@* Copyright @copyright{} 2017, 2018, 2020, 2021, 2022 Mathieu Othacehe@* Copyright @copyright{} 2017 Federico Beffa@* -Copyright @copyright{} 2017, 2018, 2024 Carlo Zancanaro@* +Copyright @copyright{} 2017, 2018, 2024, 2025 Carlo Zancanaro@* Copyright @copyright{} 2017 Thomas Danckaert@* Copyright @copyright{} 2017 humanitiesNerd@* Copyright @copyright{} 2017, 2021 Christine Lemmer-Webber@* @@ -35570,6 +35570,12 @@ 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"}) +Whether the Wireguard network should be started automatically by the +Shepherd. If it is @code{#f} the service has to be started manually +with @code{herd start wireguard-$interface} (for example: @code{herd +start wireguard-wg0}). + @end table @end deftp diff --git a/gnu/services/vpn.scm b/gnu/services/vpn.scm index c66622ad6c..478a0d543e 100644 --- a/gnu/services/vpn.scm +++ b/gnu/services/vpn.scm @@ -13,6 +13,7 @@ ;;; Copyright © 2022 Timo Wilken <guix@twilken.net> ;;; Copyright © 2023 Maxim Cournoyer <maxim.cournoyer@gmail.com> ;;; Copyright © 2024 Richard Sent <richard@freakingpenguin.com> +;;; Copyright © 2025 Carlo Zancanaro <carlo@zancanaro.id.au> ;;; ;;; This file is part of GNU Guix. ;;; @@ -88,6 +89,7 @@ wireguard-configuration-pre-down wireguard-configuration-post-down wireguard-configuration-table + wireguard-configuration-auto-start? wireguard-service-type)) @@ -764,7 +766,9 @@ strongSwan."))) (post-down wireguard-configuration-post-down ;list of strings (default '())) (table wireguard-configuration-table ;string - (default "auto"))) + (default "auto")) + (auto-start? wireguard-configuration-auto-start? ;boolean + (default #t))) (define (wireguard-configuration-file config) (define (peer->config peer) @@ -916,6 +920,7 @@ public key, if any." (match-record config <wireguard-configuration> (wireguard interface) (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)) @@ -926,6 +931,7 @@ public key, if any." (invoke #$wg-quick "down" #$config) #f)) ;stopped! (actions (list (shepherd-configuration-action config))) + (auto-start? auto-start?) (documentation "Run the Wireguard VPN tunnel")))))) (define (wireguard-monitoring-jobs config) |