diff options
author | pennae <github@quasiparticle.net> | 2023-02-13 10:34:28 +0100 |
---|---|---|
committer | pennae <82953136+pennae@users.noreply.github.com> | 2023-02-16 11:56:12 +0100 |
commit | 047bd73c5e05e8f60abb0ea2a3b22c845404f9cd (patch) | |
tree | df1416a80c219fb89f5b0e8e54e975050640ded2 | |
parent | f080d59315e4f0eaf45ef7b3aa8136c21c549fee (diff) |
nixos/wireguard: make publicKeys singleLineStrs
using readFile instead of fileContents (or using indented strings) can leave a trailing newline that causes build errors in systemd units and has previously caused runtime errors in wireguard scripts. use singleLineStr to strip a trailing newline if it exists, and to fail if more than one is present.
-rw-r--r-- | nixos/modules/services/networking/wireguard.nix | 2 | ||||
-rw-r--r-- | nixos/tests/wireguard/snakeoil-keys.nix | 3 |
2 files changed, 3 insertions, 2 deletions
diff --git a/nixos/modules/services/networking/wireguard.nix b/nixos/modules/services/networking/wireguard.nix index 1d6556f626be9..b08f1015e8b8a 100644 --- a/nixos/modules/services/networking/wireguard.nix +++ b/nixos/modules/services/networking/wireguard.nix @@ -176,7 +176,7 @@ let publicKey = mkOption { example = "xTIBA5rboUvnH4htodjb6e697QjLERt1NAB4mZqp8Dg="; - type = types.str; + type = types.singleLineStr; description = lib.mdDoc "The base64 public key of the peer."; }; diff --git a/nixos/tests/wireguard/snakeoil-keys.nix b/nixos/tests/wireguard/snakeoil-keys.nix index 55ad582d40595..c979f0e0c8a96 100644 --- a/nixos/tests/wireguard/snakeoil-keys.nix +++ b/nixos/tests/wireguard/snakeoil-keys.nix @@ -6,6 +6,7 @@ peer1 = { privateKey = "uO8JVo/sanx2DOM0L9GUEtzKZ82RGkRnYgpaYc7iXmg="; - publicKey = "Ks9yRJIi/0vYgRmn14mIOQRwkcUGBujYINbMpik2SBI="; + # readFile'd keys may have trailing newlines, emulate this + publicKey = "Ks9yRJIi/0vYgRmn14mIOQRwkcUGBujYINbMpik2SBI=\n"; }; } |