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.

pennae 047bd73c f080d593

Changed files
+3 -2
nixos
modules
services
networking
tests
wireguard
+1 -1
nixos/modules/services/networking/wireguard.nix
···
publicKey = mkOption {
example = "xTIBA5rboUvnH4htodjb6e697QjLERt1NAB4mZqp8Dg=";
-
type = types.str;
description = lib.mdDoc "The base64 public key of the peer.";
};
···
publicKey = mkOption {
example = "xTIBA5rboUvnH4htodjb6e697QjLERt1NAB4mZqp8Dg=";
+
type = types.singleLineStr;
description = lib.mdDoc "The base64 public key of the peer.";
};
+2 -1
nixos/tests/wireguard/snakeoil-keys.nix
···
peer1 = {
privateKey = "uO8JVo/sanx2DOM0L9GUEtzKZ82RGkRnYgpaYc7iXmg=";
-
publicKey = "Ks9yRJIi/0vYgRmn14mIOQRwkcUGBujYINbMpik2SBI=";
};
}
···
peer1 = {
privateKey = "uO8JVo/sanx2DOM0L9GUEtzKZ82RGkRnYgpaYc7iXmg=";
+
# readFile'd keys may have trailing newlines, emulate this
+
publicKey = "Ks9yRJIi/0vYgRmn14mIOQRwkcUGBujYINbMpik2SBI=\n";
};
}