Set up wireguard networks using functions.
This commit is contained in:
parent
e22b5c1c6c
commit
e8dff5ece1
@ -5,30 +5,42 @@
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
activatedWg = name: {
|
||||
networking.wg-quick.interfaces."${name}".configFile = "/persist/manual/wireguard/${name}.conf";
|
||||
systemd.services."wg-quick-${name}" = {
|
||||
after = [
|
||||
"nss-lookup.target"
|
||||
"systemd-resolved.service"
|
||||
"multi-user.target"
|
||||
];
|
||||
preStart = "${pkgs.toybox}/bin/sleep 10";
|
||||
};
|
||||
# systemd.services."wg-quick-${name}".after = [
|
||||
# "nss-lookup.target"
|
||||
# "systemd-resolved.service"
|
||||
# "multi-user.target"
|
||||
# ];
|
||||
# systemd.services."wg-quick-${name}".preStart = "${pkgs.toybox}/bin/sleep 10";
|
||||
};
|
||||
deactivatedWg = name: {
|
||||
networking.wg-quick.interfaces."${name}" = {
|
||||
configFile = "/persist/manual/wireguard/${name}.conf";
|
||||
autostart = false;
|
||||
};
|
||||
};
|
||||
wgConfig = lib.attrsets.recursiveUpdate (lib.attrsets.recursiveUpdate (lib.attrsets.recursiveUpdate
|
||||
(lib.attrsets.recursiveUpdate {
|
||||
networking.firewall.allowedUDPPorts = [ 51821 ];
|
||||
networking.wireguard.enable = true;
|
||||
} (activatedWg "drmario"))
|
||||
(activatedWg "wgh")
|
||||
) (activatedWg "colo")) (deactivatedWg "wgf");
|
||||
in
|
||||
{
|
||||
imports = [ ];
|
||||
|
||||
config = lib.mkIf (!config.me.buildingIso) {
|
||||
networking.firewall.allowedUDPPorts = [ 51821 ];
|
||||
networking.wireguard.enable = true;
|
||||
networking.wg-quick.interfaces.drmario.configFile = "/persist/manual/wireguard/drmario.conf";
|
||||
systemd.services."wg-quick-drmario".after = [
|
||||
"nss-lookup.target"
|
||||
"systemd-resolved.service"
|
||||
"multi-user.target"
|
||||
];
|
||||
|
||||
systemd.services."wg-quick-drmario".preStart = "${pkgs.toybox}/bin/sleep 10";
|
||||
|
||||
networking.wg-quick.interfaces.wgh.configFile = "/persist/manual/wireguard/wgh.conf";
|
||||
systemd.services."wg-quick-wgh".after = [
|
||||
"nss-lookup.target"
|
||||
"systemd-resolved.service"
|
||||
"multi-user.target"
|
||||
];
|
||||
|
||||
systemd.services."wg-quick-wgh".preStart = "${pkgs.toybox}/bin/sleep 10";
|
||||
};
|
||||
config = lib.mkIf (!config.me.buildingIso) wgConfig;
|
||||
|
||||
# environment.systemPackages = with pkgs; [
|
||||
# wireguard-tools
|
||||
|
Loading…
x
Reference in New Issue
Block a user