diff options
author | Richard Sent <richard@freakingpenguin.com> | 2024-12-04 15:59:35 -0500 |
---|---|---|
committer | Mathieu Othacehe <othacehe@gnu.org> | 2024-12-06 20:09:28 +0100 |
commit | 0972a27572a12158c0cb5a3bbc28a86eaf82dc33 (patch) | |
tree | bcbd7e8276856a69008e8d247fed1d4da92b45fd /gnu/services | |
parent | 1a17a0f90d340599f4f29775c100b44610bf87a8 (diff) | |
download | guix-0972a27572a12158c0cb5a3bbc28a86eaf82dc33.tar guix-0972a27572a12158c0cb5a3bbc28a86eaf82dc33.tar.gz |
services: wireguard: Support lists of gexps for most fields.
In order to support more flexibility in Wireguard configuration, ungexp the
configuration fields directly instead of ungexp-splicing a sexp
calculator. This allows for the fields to take arbitrary gexps instead of only
strings which is particularly helpful for the Pre/Post Up/Down commands.
* gnu/services/vpn.scm (wireguard-configuration-file): Ungexp configuration
lists instead of ungexp-splicing the code surrounding them.
* doc/guix.texi (VPN Services)[wireguard]: Document it.
Change-Id: If074cbb78473b6fd34e0e4e990d2ed268001d6c7
Signed-off-by: Mathieu Othacehe <othacehe@gnu.org>
Diffstat (limited to 'gnu/services')
-rw-r--r-- | gnu/services/vpn.scm | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/gnu/services/vpn.scm b/gnu/services/vpn.scm index f9693fb099..8e90032c93 100644 --- a/gnu/services/vpn.scm +++ b/gnu/services/vpn.scm @@ -12,6 +12,7 @@ ;;; Copyright © 2022 Cameron V Chaparro <cameron@cameronchaparro.com> ;;; Copyright © 2022 Timo Wilken <guix@twilken.net> ;;; Copyright © 2023 Maxim Cournoyer <maxim.cournoyer@gmail.com> +;;; Copyright © 2024 Richard Sent <richard@freakingpenguin.com> ;;; ;;; This file is part of GNU Guix. ;;; @@ -800,33 +801,33 @@ strongSwan."))) (define lines (list "[Interface]" - #$@(if (null? addresses) - '() - (list (format #f "Address = ~{~a~^, ~}" - addresses))) + (if (null? '#$addresses) + "" + (format #f "Address = ~{~a~^, ~}" + (list #$@addresses))) (format #f "~@[Table = ~a~]" #$table) - #$@(if (null? pre-up) - '() - (list (format #f "~{PreUp = ~a~%~}" pre-up))) + (if (null? '#$pre-up) + "" + (format #f "~{PreUp = ~a~%~}" (list #$@pre-up))) (if #$private-key (format #f "PostUp = ~a set %i private-key ~a\ ~{ peer ~a preshared-key ~a~}" #$(file-append wireguard "/bin/wg") - #$private-key '#$peer-keys) + #$private-key (list #$@peer-keys)) "") - #$@(if (null? post-up) - '() - (list (format #f "~{PostUp = ~a~%~}" post-up))) - #$@(if (null? pre-down) - '() - (list (format #f "~{PreDown = ~a~%~}" pre-down))) - #$@(if (null? post-down) - '() - (list (format #f "~{PostDown = ~a~%~}" post-down))) + (if (null? '#$post-up) + "" + (format #f "~{PostUp = ~a~%~}" (list #$@post-up))) + (if (null? '#$pre-down) + "" + (format #f "~{PreDown = ~a~%~}" (list #$@pre-down))) + (if (null? '#$post-down) + "" + (format #f "~{PostDown = ~a~%~}" (list #$@post-down))) (format #f "~@[ListenPort = ~a~]" #$port) - #$@(if (null? dns) - '() - (list (format #f "DNS = ~{~a~^, ~}" dns))))) + (if (null? '#$dns) + "" + (format #f "DNS = ~{~a~^, ~}" (list #$@dns))))) (mkdir #$output) (chdir #$output) |