From 0235bc98757778df5e336f937ebcfeff7faaad1f Mon Sep 17 00:00:00 2001 From: rope Date: Mon, 3 Aug 2026 14:07:34 +0100 Subject: [PATCH] flake: add mediaserver-vm host for testing services from scratch Co-Authored-By: Claude Opus 5 --- HEAD | 1 + flake.nix | 12 +++++++---- hosts/hardware/vm.nix | 48 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+), 4 deletions(-) create mode 160000 HEAD create mode 100644 hosts/hardware/vm.nix diff --git a/HEAD b/HEAD new file mode 160000 index 0000000..11f73e9 --- /dev/null +++ b/HEAD @@ -0,0 +1 @@ +Subproject commit 11f73e9e6aa6ac3343750590e00b53a6dd70fe2e diff --git a/flake.nix b/flake.nix index ce78b5e..b2936f7 100644 --- a/flake.nix +++ b/flake.nix @@ -39,7 +39,6 @@ specialArgs = { inherit inputs; }; modules = [ ./hosts/${hostname}.nix - ./hosts/hardware/${hostname}.nix ./common.nix home-manager.nixosModules.home-manager stylix.nixosModules.stylix @@ -49,9 +48,14 @@ in { nixosConfigurations = { - FredOS-Gaming = mkHost "FredOS-Gaming" []; - FredOS-Mediaserver = mkHost "FredOS-Mediaserver" []; - FredOS-Macbook = mkHost "FredOS-Macbook" []; + FredOS-Gaming = mkHost "FredOS-Gaming" [ ./hosts/hardware/FredOS-Gaming.nix ]; + FredOS-Mediaserver = mkHost "FredOS-Mediaserver" [ ./hosts/hardware/FredOS-Mediaserver.nix ]; + FredOS-Macbook = mkHost "FredOS-Macbook" [ ./hosts/hardware/FredOS-Macbook.nix ]; + + # Mediaserver's services on fake hardware, for testing from-scratch + # bring-up (arr-interconnect especially) in a throwaway VM: + # nixos-rebuild build-vm --flake .#mediaserver-vm + mediaserver-vm = mkHost "FredOS-Mediaserver" [ ./hosts/hardware/vm.nix ]; }; }; } diff --git a/hosts/hardware/vm.nix b/hosts/hardware/vm.nix new file mode 100644 index 0000000..4a2b362 --- /dev/null +++ b/hosts/hardware/vm.nix @@ -0,0 +1,48 @@ +#./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 + forwardPorts = [ + { from = "host"; host.port = 2222; guest.port = 22; } + { from = "host"; host.port = 8989; guest.port = 8989; } # sonarr + { from = "host"; host.port = 7878; guest.port = 7878; } # radarr + { from = "host"; host.port = 9696; guest.port = 9696; } # prowlarr + { from = "host"; host.port = 6767; guest.port = 6767; } # bazarr + { from = "host"; host.port = 8080; guest.port = 8080; } # qbittorrent + { from = "host"; host.port = 8096; guest.port = 8096; } # jellyfin + { from = "host"; host.port = 5055; guest.port = 5055; } # seerr + ]; + }; +}