Files
nix-config/hosts
ryan4yin | 二花 e5b95affa6 feat(nixos): default-deny host inbound, trust the LAN/tailnet (#325)
Hosts used to trust the router as the only boundary (servers ran with the
firewall off; service ports were opened globally), so any LAN device could
reach every host service. Move filtering to the hosts as defence in depth
behind the router, which keeps its firewall on and uses a port mapping for
the few ports we actually need.

- base: nftables backend; deny inbound by default; trust the home LAN by
  source and the tailnet by interface (restrict the tailnet with ACLs);
  suppress per-service `openFirewall` global ports; allow node_exporter only
  from the monitoring host. The local podman bridge, the tailnet and the pod
  CIDRs are accepted only after the node_exporter drop.
- servers: stop disabling the firewall; drop redundant global port opens
  (caddy 80/443, NFS 2049, Jellyfin, localsend/test ports); delete the
  redundant desktop firewall module; aarch64/riscv64 import the firewall
  explicitly (akane was missing it).
- k3s: Cilium pods (10.0.0.0/8, fd00::/8) may reach host services; drop the
  flannel-era cni0/flannel.1 trust.
- youko: postgres listens on localhost + the LAN with pg_hba limited to the
  LAN; the NFS export stays LAN-scoped; remove the unauthenticated v2ray
  proxy.
- tests: `security-firewall` asserts every host runs the shared firewall, has
  the LAN CIDR rule and no global ports.
2026-09-26 14:02:03 +08:00
..
2026-09-25 00:30:12 +08:00
2026-09-25 00:30:12 +08:00

Hosts

This directory contains all host-specific configurations for my NixOS and macOS systems.

Current Host Inventory

Physical Machines

idols - Main Workstations

Named after characters from "Oshi no Ko":

Host Platform Hardware Purpose Status
ai NixOS i5-13600KF + RTX 4090 Gaming & Daily Use ✅ Active
aquamarine NixOS (libvirt) Virtual Monitoring & Services ⚪ Not Used
kana NixOS (libvirt) Virtual Run AI Agents ✅ Active
ruby NixOS (libvirt) Virtual Run AI Agents ✅ Active
akane NixOS (aarch64) Virtual (UTM) aarch64 test VM ✅ Active

aquamarine is retired; its services now run directly on youko (hosts/12kingdoms-youko/homelab-services/).

darwin - macOS Systems

Named after characters from "Frieren: Beyond Journey's End":

Host Platform Hardware Purpose Status
fern macOS MacBook Pro M2 13" 16GB Personal Use ✅ Active
frieren macOS MacBook Pro M4Pro 14" 48GB Work Use ✅ Active

12kingdoms - Homelab Servers & Apple Silicon Linux

Named after "Twelve Kingdoms":

Host Platform Hardware Purpose Status
shoukei NixOS MacBook Pro M2 NixOS on Apple Silicon ✅ Active
shoryu NixOS MoreFine S500Plus (AMD Ryzen 9 5900HX) VM Host ✅ Active
shushou NixOS MinisForum UM560 (AMD Ryzen 5 5625U) VM Host ✅ Active
youko NixOS MinisForum HX99G (AMD Ryzen 9 6900HX) VM Host ✅ Active

Virtual Machines & Clusters

k8s - Kubernetes Infrastructure

  • VM Cluster: 3 physical mini PCs (shoryu, shushou, youko) running all VMs
  • K3s Testing: k3s-test-1-master-{1,2,3} (control plane) + k3s-test-1-worker-{1,2,3} (workloads; two on shushou, one on shoryu), running as microVMs

External Systems

All my riscv64 hosts:

Naming Conventions

  • idols: Characters from "Oshi no Ko" anime/manga
  • 12kingdoms: Characters from "Twelve Kingdoms" anime/novel series
  • darwin: Characters from "Frieren: Beyond Journey's End" anime/manga
  • k8s: Kubernetes-related systems follow standard naming patterns

How to Add a New Host

The easiest way to add a new host is to copy and adapt an existing similar configuration. All host configurations follow similar patterns but are customized for specific hardware and use cases.

General Process

  1. Identify a similar existing host from the directory structure above
  2. Copy the entire directory and rename it for your new host
  3. Adapt the configuration files for your specific hardware and requirements
  4. Update references in the flake outputs and networking configuration

Essential Steps

  1. Under hosts/
    1. Create a new folder under hosts/ with the name of the new host.
    2. Create & add the new host's hardware-configuration.nix to the new folder, and add the new host's configuration.nix to hosts/<name>/default.nix.
    3. If the new host need to use home-manager, add its custom config into home/hosts/linux/<name>.nix or home/hosts/darwin/<name>.nix.
  2. Under outputs/
    1. Add a new nix file named outputs/<system-architecture>/src/<name>.nix.
    2. Copy the content from one of the existing similar host, and modify it to fit the new host.
      1. Usually, you only need to modify the name and tags fields.
    3. [Optional] Add a new unit test file under outputs/<system-architecture>/tests/<name>.nix to test the new host's nix file.
    4. [Optional] Add a new integration test file under outputs/<system-architecture>/integration-tests/<name>.nix to test whether the new host's nix config can be built and deployed correctly.
  3. Under vars/networking.nix
    1. Add the new host's static IP address.
    2. Skip this step if the new host is not in the local network or is a mobile device.

File Templates

Use existing hosts as templates. The key files typically include:

  • default.nix - Main host configuration
  • hardware-configuration.nix - Auto-generated hardware settings
  • Platform-specific files (e.g., nvidia.nix, apple-silicon.nix, etc.)

Examples to Reference

  • Desktop systems: See idols-ai/ for gaming/workstation setup
  • Server systems: See 12kingdoms-shoryu/ for VM hosts
  • macOS systems: See darwin-fern/ for macOS configurations
  • Apple Silicon: See 12kingdoms-shoukei/ for ARM Linux setup

Deploying VM Hosts

The three VM hosts (shoryu, shushou, youko) attach their VMs (microVM taps and libvirt domains) to the Linux bridge br0, with the physical NIC as a bridge port. The k3s-test-1 cluster runs as microVMs on top, using Cilium as its pod network (flannel disabled).

  • switch is fine for changes that don't touch the network stack (e.g. journald or other service settings). Deploy serially (-p 1) and re-check VM reachability afterwards.
  • Use boot + a serial reboot for anything that can drop the network mid-flight — systemd.network / br0 changes, nixpkgs updates, or any broad rebuild.
  • If a host loses VM networking, check br0 and the VM taps, or reboot the host.

Common Build Commands

Use the Just recipes for host configuration checks and builds:

just eval-host <host>
just build-host <host>

eval-host only evaluates the configuration. build-host builds the system closure without activating it. Host activation remains an explicit Colmena operation such as just shoryu, just shushou, or just youko.

Distributed Building

I usually run the build command on Ai and nix will distribute the build to other NixOS machines, which is convenient and fast.

When building some packages for riscv64 or aarch64, I often have no cache available because of various changes under the hood, so I need to build much more packages than usual, which is one of the reasons why the cluster was originally built, and another reason is distributed building is cool!

References

Oshi no Ko 【推しの子】 - Wikipedia:

The Rolling Girls【ローリング☆ガールズ】 - Wikipedia:

List of Twelve Kingdoms characters

List of Frieren characters