1 import ../make-test-python.nix ({ pkgs, lib, kernelPackages ? null, nftables ? false, ... }:
3 wg-snakeoil-keys = import ./snakeoil-keys.nix;
4 peer = import ./make-peer.nix { inherit lib; };
6 boot.kernelPackages = lib.mkIf (kernelPackages != null) kernelPackages;
7 networking.nftables.enable = nftables;
8 # Make sure iptables doesn't work with nftables enabled
9 boot.blacklistedKernelModules = lib.mkIf nftables [ "nft_compat" ];
14 meta = with pkgs.lib.maintainers; {
15 maintainers = [ d-xo ];
22 extraConfig = lib.mkMerge [
25 networking.firewall.allowedUDPPorts = [ 23542 ];
26 networking.wg-quick.interfaces.wg0 = {
27 address = [ "10.23.42.1/32" "fc00::1/128" ];
30 inherit (wg-snakeoil-keys.peer0) privateKey;
32 peers = lib.singleton {
33 allowedIPs = [ "10.23.42.2/32" "fc00::2/128" ];
35 inherit (wg-snakeoil-keys.peer1) publicKey;
38 dns = [ "10.23.42.2" "fc00::2" "wg0" ];
47 extraConfig = lib.mkMerge [
50 networking.useNetworkd = true;
51 networking.wg-quick.interfaces.wg0 = {
52 address = [ "10.23.42.2/32" "fc00::2/128" ];
53 inherit (wg-snakeoil-keys.peer1) privateKey;
55 peers = lib.singleton {
56 allowedIPs = [ "0.0.0.0/0" "::/0" ];
57 endpoint = "192.168.0.1:23542";
58 persistentKeepalive = 25;
60 inherit (wg-snakeoil-keys.peer0) publicKey;
63 dns = [ "10.23.42.1" "fc00::1" "wg0" ];
73 peer0.wait_for_unit("wg-quick-wg0.service")
74 peer1.wait_for_unit("wg-quick-wg0.service")
76 peer1.succeed("ping -c5 fc00::1")
77 peer1.succeed("ping -c5 10.23.42.1")