1 import ../make-test-python.nix (
9 wg-snakeoil-keys = import ./snakeoil-keys.nix;
10 peer = (import ./make-peer.nix) { inherit lib; };
13 name = "wireguard-networkd";
14 meta = with pkgs.lib.maintainers; {
15 maintainers = [ majiir ];
23 boot = lib.mkIf (kernelPackages != null) { inherit kernelPackages; };
24 networking.firewall.allowedUDPPorts = [ 23542 ];
25 networking.wireguard.useNetworkd = true;
26 networking.wireguard.interfaces.wg0 = {
33 # !!! Don't do this with real keys. The /nix store is world-readable!
34 privateKeyFile = toString (pkgs.writeText "privateKey" wg-snakeoil-keys.peer0.privateKey);
36 peers = lib.singleton {
42 # !!! Don't do this with real keys. The /nix store is world-readable!
43 presharedKeyFile = toString (pkgs.writeText "presharedKey" wg-snakeoil-keys.presharedKey);
45 inherit (wg-snakeoil-keys.peer1) publicKey;
55 boot = lib.mkIf (kernelPackages != null) { inherit kernelPackages; };
56 networking.wireguard.useNetworkd = true;
57 networking.wireguard.interfaces.wg0 = {
64 # !!! Don't do this with real keys. The /nix store is world-readable!
65 privateKeyFile = toString (pkgs.writeText "privateKey" wg-snakeoil-keys.peer1.privateKey);
67 peers = lib.singleton {
72 endpoint = "192.168.0.1:23542";
73 persistentKeepalive = 25;
75 # !!! Don't do this with real keys. The /nix store is world-readable!
76 presharedKeyFile = toString (pkgs.writeText "presharedKey" wg-snakeoil-keys.presharedKey);
78 inherit (wg-snakeoil-keys.peer0) publicKey;
88 peer0.systemctl("start network-online.target")
89 peer0.wait_for_unit("network-online.target")
91 peer1.systemctl("start network-online.target")
92 peer1.wait_for_unit("network-online.target")
94 peer1.succeed("ping -c5 fc00::1")
95 peer1.succeed("ping -c5 10.23.42.1")
97 with subtest("Has PSK set"):
98 peer0.succeed("wg | grep 'preshared key'")
99 peer1.succeed("wg | grep 'preshared key'")