nixos/hosts/hardware/vm.nix

51 lines
2.3 KiB
Nix
Raw Normal View History

#./hosts/hardware/vm.nix
# Stand-in "hardware" for `nixos-rebuild build-vm --flake .#mediaserver-vm`.
#
# Keeps hostName = FredOS-Mediaserver so every hostname-gated module under
# services/ switches on, but throws away the real disks, NICs and GPU. The
# point is watching arr-interconnect wire a *fresh* stack from empty state —
# something the live host can't demonstrate anymore, since its /var/lib is
# already populated and the script is a reconciler, not an installer.
{ lib, ... }:
{
networking.hostName = "FredOS-Mediaserver";
system.stateVersion = "25.11";
nixpkgs.hostPlatform = "x86_64-linux";
# qemu-vm.nix supplies "/" and the bootloader. Only the media pool has to
# exist by hand, so the *arr root folders resolve — contents are throwaway.
fileSystems."/mnt/storage" = {
device = "tmpfs";
fsType = "tmpfs";
options = [ "mode=0777" ];
};
# --- Undo router.nix. This VM is not a router. ---
# Its networkd units match NIC names pinned to the real MACs, so the VM's
# NIC matches nothing and comes up unconfigured; its nft input chain is
# policy-drop, which would eat the forwarded ports below. Scripted DHCP on
# QEMU's user-mode NIC replaces both.
networking.useNetworkd = lib.mkForce false;
networking.nftables.tables = lib.mkForce { };
services.dnsmasq.enable = lib.mkForce false;
virtualisation.vmVariant.virtualisation = {
memorySize = 8192;
cores = 4;
diskSize = 32768; # docker images for shelfarr/profilarr are not small
graphics = false; # serial console; ctrl-a x to quit
# Host side is offset by 10000 so the VM can run on the mediaserver
# itself without fighting the live services for those ports.
forwardPorts = [
{ from = "host"; host.port = 10022; guest.port = 22; } # ssh
{ from = "host"; host.port = 18989; guest.port = 8989; } # sonarr
{ from = "host"; host.port = 17878; guest.port = 7878; } # radarr
{ from = "host"; host.port = 19696; guest.port = 9696; } # prowlarr
{ from = "host"; host.port = 16767; guest.port = 6767; } # bazarr
{ from = "host"; host.port = 18080; guest.port = 8080; } # qbittorrent
{ from = "host"; host.port = 18096; guest.port = 8096; } # jellyfin
{ from = "host"; host.port = 15055; guest.port = 5055; } # seerr
];
};
}