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.
This commit is contained in:
pennae 2023-02-13 10:34:28 +01:00 committed by pennae
parent f080d59315
commit 047bd73c5e
2 changed files with 3 additions and 2 deletions

View File

@ -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.";
};

View File

@ -6,6 +6,7 @@
peer1 = {
privateKey = "uO8JVo/sanx2DOM0L9GUEtzKZ82RGkRnYgpaYc7iXmg=";
publicKey = "Ks9yRJIi/0vYgRmn14mIOQRwkcUGBujYINbMpik2SBI=";
# readFile'd keys may have trailing newlines, emulate this
publicKey = "Ks9yRJIi/0vYgRmn14mIOQRwkcUGBujYINbMpik2SBI=\n";
};
}