only create macvtaps service when macvtaps are configured

Prevents unnecessary VM restarts on deploy when no macvtaps are used.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Git Sagar 2026-06-07 10:39:35 +05:30
parent 5fbdd36107
commit f997b72f40

View file

@ -231,7 +231,7 @@ let
in
lib.optionalAttrs (cfg.enable) {
"vm.vmix@${vmCfg.name}" = rec {
bindsTo = [ "net.vmix@${spaceName}.target" "macvtaps.vm.vmix@${vmCfg.name}.service" ];
bindsTo = [ "net.vmix@${spaceName}.target" ] ++ lib.optional (allMacvtaps != []) "macvtaps.vm.vmix@${vmCfg.name}.service";
unitConfig.JoinsNamespaceOf = "ns.net.vmix@${spaceName}.service";
after = bindsTo;
path = with pkgs; [ iproute2 qemu gawk coreutils ];
@ -250,7 +250,7 @@ let
};
wantedBy = lib.mkIf vmCfg.autostart [ "multi-user.target" ];
};
} // lib.optionalAttrs (allMacvtaps != []) {
"macvtaps.vm.vmix@${vmCfg.name}" = rec {
bindsTo = [ "net.vmix@${spaceName}.target" ];
after = bindsTo;