{ inputs, lib, pkgs, ... }:

{
  # Home Manager activation is provided by the home-manager.nixosModules.home-manager
  # module wired up in flake.nix. It runs as a systemd user service per user and
  # deploys ~/.config/hypr, ~/.config/nomarchy, ~/.config/waybar, etc. before the
  # graphical session starts.

  # Shared VM configuration
  virtualisation.vmVariant = {
    virtualisation.graphics = true;
    virtualisation.qemu.options = [ "-device" "virtio-vga" ];
  };

  # Improve VM resolution and guest experience
  services.spice-vdagentd.enable = true;
  services.qemuGuest.enable = true;
  services.xserver.videoDrivers = [ "qxl" "virtio" "modesetting" ];

  # Provide the flake to the VM for local rebuilding
  environment.etc."nomarchy".source = lib.mkDefault inputs.self;

  # Dummy hardware config for VM
  fileSystems."/" = lib.mkDefault { device = "/dev/disk/by-label/nixos"; };
  boot.loader.grub.device = lib.mkDefault "/dev/vda";
  boot.initrd.availableKernelModules = [ "virtio_pci" "virtio_blk" "virtio_gpu" "virtio_net" "virtio_mmio" ];
  
  # Force early KMS for Plymouth
  boot.initrd.kernelModules = [ "virtio_gpu" ];
}
