python310Packages.pydeconz: 104 -> 105
[NixPkgs.git] / nixos / tests / wireguard / wg-quick.nix
blobbc2cba91188890a04fe0d5976712cf1c6e08aad7
1 { kernelPackages ? null }:
3 import ../make-test-python.nix ({ pkgs, lib, ... }:
4   let
5     wg-snakeoil-keys = import ./snakeoil-keys.nix;
6     peer = (import ./make-peer.nix) { inherit lib; };
7   in
8   {
9     name = "wg-quick";
10     meta = with pkgs.lib.maintainers; {
11       maintainers = [ d-xo ];
12     };
14     nodes = {
15       peer0 = peer {
16         ip4 = "192.168.0.1";
17         ip6 = "fd00::1";
18         extraConfig = {
19           boot = lib.mkIf (kernelPackages != null) { inherit kernelPackages; };
20           networking.firewall.allowedUDPPorts = [ 23542 ];
21           networking.wg-quick.interfaces.wg0 = {
22             address = [ "10.23.42.1/32" "fc00::1/128" ];
23             listenPort = 23542;
25             inherit (wg-snakeoil-keys.peer0) privateKey;
27             peers = lib.singleton {
28               allowedIPs = [ "10.23.42.2/32" "fc00::2/128" ];
30               inherit (wg-snakeoil-keys.peer1) publicKey;
31             };
33             dns = [ "10.23.42.2" "fc00::2" "wg0" ];
34           };
35         };
36       };
38       peer1 = peer {
39         ip4 = "192.168.0.2";
40         ip6 = "fd00::2";
41         extraConfig = {
42           boot = lib.mkIf (kernelPackages != null) { inherit kernelPackages; };
43           networking.useNetworkd = true;
44           networking.wg-quick.interfaces.wg0 = {
45             address = [ "10.23.42.2/32" "fc00::2/128" ];
46             inherit (wg-snakeoil-keys.peer1) privateKey;
48             peers = lib.singleton {
49               allowedIPs = [ "0.0.0.0/0" "::/0" ];
50               endpoint = "192.168.0.1:23542";
51               persistentKeepalive = 25;
53               inherit (wg-snakeoil-keys.peer0) publicKey;
54             };
56             dns = [ "10.23.42.1" "fc00::1" "wg0" ];
57           };
58         };
59       };
60     };
62     testScript = ''
63       start_all()
65       peer0.wait_for_unit("wg-quick-wg0.service")
66       peer1.wait_for_unit("wg-quick-wg0.service")
68       peer1.succeed("ping -c5 fc00::1")
69       peer1.succeed("ping -c5 10.23.42.1")
70     '';
71   }