{ pkgs, lib, ... }: let host = "127.0.0.1"; port = 8989; vm-index = 1; vm-mac = "00:00:00:00:00:01"; vm-name = "sonarr"; in { config.microvm.autostart = [vm-name]; config.system.activationScripts."make${vm-name}DataDir" = lib.stringAfter ["var"] '' mkdir -p /var/lib/${vm-name} chmod -R 777 /var/lib/${vm-name} chown -R microvm /var/lib/${vm-name} ''; config.microvm.vms.${vm-name} = { config = { system.stateVersion = "24.11"; # Storage share configuration microvm.shares = [ { tag = "ro-store"; source = "/nix/store"; mountPoint = "/nix/.ro-store"; } { tag = "data-dir"; source = "/var/lib/${vm-name}"; mountPoint = "/var/lib/sonarr"; proto = "virtiofs"; } ]; # Allow the service to use the share system.activationScripts."chownDataDir" = lib.stringAfter ["var"] '' mkdir -p /var/lib/sonarr chmod -R 770 /var/lib/sonarr chown -R sonarr:sonarr /var/lib/sonarr ''; systemd.services.sonarr.serviceConfig.ExecStartPre = "/run/current-system/sw/bin/sleep 5"; microvm.hypervisor = "qemu"; # VM Networking microvm.interfaces = [ { id = "vm${toString vm-index}"; type = "tap"; mac = vm-mac; } ]; networking.useNetworkd = true; systemd.network.networks."10-eth" = { matchConfig.MACAddress = vm-mac; address = [ "10.0.0.${toString vm-index}/32" ]; routes = [ # Host Route { Destination = "10.0.0.0/32"; GatewayOnLink = true; } # Default route { Destination = "0.0.0.0/0"; Gateway = "10.0.0.0"; GatewayOnLink = true; } ]; networkConfig = { DNS = [ "9.9.9.9" "8.8.8.8" "8.8.4.4" ]; }; }; networking.useDHCP = false; networking.nameservers = [ "10.0.101.1" "8.8.8.8" "8.8.4.4" ]; # Service services.sonarr = { enable = true; openFirewall = true; }; # Debug user users.users."root" = { password = "1234"; }; environment.systemPackages = [pkgs.dig]; services.openssh = { enable = true; settings = { PermitRootLogin = "yes"; AllowUsers = null; PasswordAuthentication = true; KbdInteractiveAuthentication = true; }; }; }; }; }