You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.7 KiB
Nix

1 year ago
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
(import ./lib.nix)
{
1 year ago
name = "simple connection";
1 year ago
nodes = {
# `self` here is set by using specialArgs in `lib.nix`
1 year ago
node1 = { self, pkgs, ... }: {
virtualisation.vlans = [ 1 ];
1 year ago
imports = [ self.nixosModules.default ];
wirenix = {
enable = true;
keyProviders = ["acl"];
1 year ago
peerName = "node1";
1 year ago
aclConfig = import ./acls/simple.nix;
};
# Don't do this! This is for testing only!
environment.etc."wg-key" = {
text = "MIELhEc0I7BseAanhk/+LlY/+Yf7GK232vKWITExnEI=";
};
1 year ago
networking.firewall.enable = false;
1 year ago
};
1 year ago
node2 = { self, pkgs, ... }: {
virtualisation.vlans = [ 1 ];
1 year ago
imports = [ self.nixosModules.default ];
wirenix = {
enable = true;
keyProviders = ["acl"];
1 year ago
peerName = "node2";
1 year ago
aclConfig = import ./acls/simple.nix;
};
environment.etc."wg-key" = {
text = "yG4mJiduoAvzhUJMslRbZwOp1gowSfC+wgY8B/Mul1M=";
};
1 year ago
networking.firewall.enable = false;
1 year ago
};
};
# This is the test code that will check if our service is running correctly:
testScript = ''
start_all()
1 year ago
node1.wait_for_unit("wireguard-simple-peer-node2")
node2.wait_for_unit("wireguard-simple-peer-node1")
node1.succeed("ping -c 1 node2 >&2")
node1.succeed("wg show >&2")
node2.succeed("ping -c 1 node1 >&2")
node2.succeed("wg show >&2")
node1.succeed("ping -c 1 node2.simple")
node2.succeed("ping -c 1 node1.simple")
1 year ago
'';
}