mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-01-01 02:23:54 +00:00
4f0dadbf38
After final improvements to the official formatter implementation, this commit now performs the first treewide reformat of Nix files using it. This is part of the implementation of RFC 166. Only "inactive" files are reformatted, meaning only files that aren't being touched by any PR with activity in the past 2 months. This is to avoid conflicts for PRs that might soon be merged. Later we can do a full treewide reformat to get the rest, which should not cause as many conflicts. A CI check has already been running for some time to ensure that new and already-formatted files are formatted, so the files being reformatted here should also stay formatted. This commit was automatically created and can be verified using nix-builda08b3a4d19
.tar.gz \ --argstr baseRevb32a094368
result/bin/apply-formatting $NIXPKGS_PATH
92 lines
2.7 KiB
Nix
92 lines
2.7 KiB
Nix
let
|
|
listenPort = 12345;
|
|
socketNamespace = "foo";
|
|
interfaceNamespace = "bar";
|
|
node = {
|
|
networking.wireguard.interfaces.wg0 = {
|
|
listenPort = listenPort;
|
|
ips = [ "10.10.10.1/24" ];
|
|
privateKeyFile = "/etc/wireguard/private";
|
|
generatePrivateKeyFile = true;
|
|
};
|
|
};
|
|
|
|
in
|
|
|
|
import ../make-test-python.nix (
|
|
{
|
|
pkgs,
|
|
lib,
|
|
kernelPackages ? null,
|
|
...
|
|
}:
|
|
{
|
|
name = "wireguard-with-namespaces";
|
|
meta = with pkgs.lib.maintainers; {
|
|
maintainers = [ asymmetric ];
|
|
};
|
|
|
|
nodes = {
|
|
# interface should be created in the socketNamespace
|
|
# and not moved from there
|
|
peer0 = pkgs.lib.attrsets.recursiveUpdate node {
|
|
boot = lib.mkIf (kernelPackages != null) { inherit kernelPackages; };
|
|
networking.wireguard.interfaces.wg0 = {
|
|
preSetup = ''
|
|
ip netns add ${socketNamespace}
|
|
'';
|
|
inherit socketNamespace;
|
|
};
|
|
};
|
|
# interface should be created in the init namespace
|
|
# and moved to the interfaceNamespace
|
|
peer1 = pkgs.lib.attrsets.recursiveUpdate node {
|
|
boot = lib.mkIf (kernelPackages != null) { inherit kernelPackages; };
|
|
networking.wireguard.interfaces.wg0 = {
|
|
preSetup = ''
|
|
ip netns add ${interfaceNamespace}
|
|
'';
|
|
mtu = 1280;
|
|
inherit interfaceNamespace;
|
|
};
|
|
};
|
|
# interface should be created in the socketNamespace
|
|
# and moved to the interfaceNamespace
|
|
peer2 = pkgs.lib.attrsets.recursiveUpdate node {
|
|
boot = lib.mkIf (kernelPackages != null) { inherit kernelPackages; };
|
|
networking.wireguard.interfaces.wg0 = {
|
|
preSetup = ''
|
|
ip netns add ${socketNamespace}
|
|
ip netns add ${interfaceNamespace}
|
|
'';
|
|
inherit socketNamespace interfaceNamespace;
|
|
};
|
|
};
|
|
# interface should be created in the socketNamespace
|
|
# and moved to the init namespace
|
|
peer3 = pkgs.lib.attrsets.recursiveUpdate node {
|
|
boot = lib.mkIf (kernelPackages != null) { inherit kernelPackages; };
|
|
networking.wireguard.interfaces.wg0 = {
|
|
preSetup = ''
|
|
ip netns add ${socketNamespace}
|
|
'';
|
|
inherit socketNamespace;
|
|
interfaceNamespace = "init";
|
|
};
|
|
};
|
|
};
|
|
|
|
testScript = ''
|
|
start_all()
|
|
|
|
for machine in peer0, peer1, peer2, peer3:
|
|
machine.wait_for_unit("wireguard-wg0.service")
|
|
|
|
peer0.succeed("ip -n ${socketNamespace} link show wg0")
|
|
peer1.succeed("ip -n ${interfaceNamespace} link show wg0")
|
|
peer2.succeed("ip -n ${interfaceNamespace} link show wg0")
|
|
peer3.succeed("ip link show wg0")
|
|
'';
|
|
}
|
|
)
|