diff --git a/nixos/vm.nix b/nixos/vm.nix index 7994aaa..9d42d2e 100644 --- a/nixos/vm.nix +++ b/nixos/vm.nix @@ -1,8 +1,14 @@ +{ lib, ... }: { virtualisation.vmVariant.virtualisation = { cores = 2; diskSize = 8192; graphics = false; memorySize = 4096; + + qemu.networkingOptions = lib.mkForce [ + "-nic bridge,br=virbr0,id=hn0,model=virt-net-pci,helper=\${QEMU_BRIDGE_HELPER_PATH}" + "-device virtio-net-pci,netdev=hn0,id=nic1,\${QEMU_NET_OPTS:+,$QEMU_NET_OPTS}" + ]; }; } diff --git a/shells/default.nix b/shells/default.nix index 8391bee..90f8fd0 100644 --- a/shells/default.nix +++ b/shells/default.nix @@ -5,6 +5,24 @@ { devShells.default = pkgs.mkShell { name = "configuration.nix"; + + shellHook = '' + for path in \ + /usr/lib/qemu/qemu-bridge-helper \ + /run/wrappers/bin/qemu-bridge-helper + do + if [ -x "$path" ]; then + export QEMU_BRIDGE_HELPER_PATH="$path" + break + fi + done + + if [ -z "$QEMU_BRIDGE_HELPER_PATH" ]; then + printf "\033[1;33m%s\033[0m\n" \ + "WARN: 'qemu-bridge-helper' not found, make sure it is installed and the nix shell hook is looking for it" >&2 + fi + ''; + packages = with pkgs; [ bat cachix