From f997b72f4027d32b79b6edb7af220594eccab93f Mon Sep 17 00:00:00 2001 From: Git Sagar Date: Sun, 7 Jun 2026 10:39:35 +0530 Subject: [PATCH] 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) --- nixos/vms/config.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nixos/vms/config.nix b/nixos/vms/config.nix index cae926d..6be8a44 100644 --- a/nixos/vms/config.nix +++ b/nixos/vms/config.nix @@ -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 ]; @@ -248,9 +248,9 @@ let ProtectSystem = lib.mkForce false; SupplementaryGroups = [ "kvm" ]; }; - wantedBy = lib.mkIf vmCfg.autostart [ "multi-user.target" ]; + wantedBy = lib.mkIf vmCfg.autostart [ "multi-user.target" ]; }; - + } // lib.optionalAttrs (allMacvtaps != []) { "macvtaps.vm.vmix@${vmCfg.name}" = rec { bindsTo = [ "net.vmix@${spaceName}.target" ]; after = bindsTo;