~ruther/guix-local

81a911eab8a0214706fe0f74556a6788984949c3 — Sergey Trofimov 1 year, 3 months ago d9bfc66
services: wireguard: Add the shepherd-requirement field.

* gnu/services/vpn.scm (<wireguard-configuration>): Add
shepherd-requirement.
(wireguard-shepherd-service): Pass shepherd-requirement. Add
user-processes to requirements.
* doc/guix.texi (VPN Services):[wireguard]: Document it.

Change-Id: Ia85add5067f6f9e023b8d65d6ce067b98eeb111e
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2 files changed, 9 insertions(+), 2 deletions(-)

M doc/guix.texi
M gnu/services/vpn.scm
M doc/guix.texi => doc/guix.texi +4 -0
@@ 35739,6 35739,10 @@ be executed before tearing down the interface.
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

M gnu/services/vpn.scm => gnu/services/vpn.scm +5 -2
@@ 88,6 88,7 @@
            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 @@ strongSwan.")))
                          (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 @@ public key, if any."

(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 user-processes ,@shepherd-requirement))
             (provision (list (wireguard-service-name interface)))
             (start #~(lambda _
                       (invoke #$wg-quick "up" #$config)))