1 { kernelPackages ? null }:
2 import ../make-test-python.nix ({ pkgs, lib, ...} :
4 wg-snakeoil-keys = import ./snakeoil-keys.nix;
5 peer = (import ./make-peer.nix) { inherit lib; };
9 meta = with pkgs.lib.maintainers; {
10 maintainers = [ ma27 ];
18 boot = lib.mkIf (kernelPackages != null) { inherit kernelPackages; };
19 networking.firewall.allowedUDPPorts = [ 23542 ];
20 networking.wireguard.interfaces.wg0 = {
21 ips = [ "10.23.42.1/32" "fc00::1/128" ];
24 inherit (wg-snakeoil-keys.peer0) privateKey;
26 peers = lib.singleton {
27 allowedIPs = [ "10.23.42.2/32" "fc00::2/128" ];
29 inherit (wg-snakeoil-keys.peer1) publicKey;
39 boot = lib.mkIf (kernelPackages != null) { inherit kernelPackages; };
40 networking.wireguard.interfaces.wg0 = {
41 ips = [ "10.23.42.2/32" "fc00::2/128" ];
43 allowedIPsAsRoutes = false;
45 inherit (wg-snakeoil-keys.peer1) privateKey;
47 peers = lib.singleton {
48 allowedIPs = [ "0.0.0.0/0" "::/0" ];
49 endpoint = "192.168.0.1:23542";
50 persistentKeepalive = 25;
52 inherit (wg-snakeoil-keys.peer0) publicKey;
55 postSetup = let inherit (pkgs) iproute2; in ''
56 ${iproute2}/bin/ip route replace 10.23.42.1/32 dev wg0
57 ${iproute2}/bin/ip route replace fc00::1/128 dev wg0
67 peer0.wait_for_unit("wireguard-wg0.service")
68 peer1.wait_for_unit("wireguard-wg0.service")
70 peer1.succeed("ping -c5 fc00::1")
71 peer1.succeed("ping -c5 10.23.42.1")