nixos: services: wireguard: add VPN conflicts

It's now easier to do the right thing when starting a VPN service,
whether the other one is running or not.
This commit is contained in:
Bruno BELANYI 2023-12-12 14:09:10 +00:00
parent 16fade92b4
commit f23e6251ce

View file

@ -261,5 +261,17 @@ in
(lib.mkIf (cfg.internal.enable && !cfg.internal.startAtBoot) {
systemd.services."wg-quick-${cfg.internal.name}".wantedBy = lib.mkForce [ ];
})
# Make systemd shut down one service when starting the other
(lib.mkIf (cfg.internal.enable) {
systemd.services."wg-quick-${cfg.iface}" = {
conflicts = [ "wg-quick-${cfg.internal.name}.service" ];
after = [ "wg-quick-${cfg.internal.name}.service" ];
};
systemd.services."wg-quick-${cfg.internal.name}" = {
conflicts = [ "wg-quick-${cfg.iface}.service" ];
after = [ "wg-quick-${cfg.iface}.service" ];
};
})
]);
}