Commit Graph
172 Commits
Author SHA1 Message Date
oqyude 7635df44e9 fix(pxe-infra): correct triple-quote to double-quote in autoexec.ipxe block
Nix indented strings use \x27\x27 (two single quotes) as delimiters, not \x27\x27\x27
(three). The autoexec.ipxe block added in 7c9a8d8 used \x27\x27\x27 which
the parser rejects with "unexpected end of file, expecting indented
string or \x27${ or end of an indented string". Replacing with the
correct \x27\x27 makes both copies (this one and the home-manager
symlink target) parse cleanly and unblocks nixos-rebuild.
2026-10-14 14:32:08 +03:00
oqyude 046a92700a fix(pxe-infra): add autoexec.ipxe to TFTP root (resolves iPXE #GP / T10)
iPXE in UEFI mode looks for autoexec.ipxe on the same TFTP server it
was loaded from, and runs it as the boot script. Without it, the iPXE
instance that replaced the firmware PXE ROM has nothing to chain to
and ends up in No more network devices -> #GP.

This was the root cause of T10 (the iPXE 2.0.0 #GP with RIP 0x7EE8A5FC
or 0x7EC9456F depending on which point in the chain it crashed at).
Adding a 1-line autoexec.ipxe that chains to the HTTP-served boot.ipxe
makes the full chain work end-to-end: snp.efi -> autoexec.ipxe ->
boot.ipxe -> vmlinuz-virt+initramfs-virt -> kernel boot -> Alpine Init.

ipxe.nix: new environment.etc entry autoexec.ipxe via pkgs.writeText.
default.nix: tmpfiles rule symlinks it into the served TFTP root.

Verified 2026-10-14 on rydiwo with manual QEMU test (H_fix.1b):
snp.efi (iPXE 2.0.0) loaded, autoexec.ipxe found, HTTP boot.ipxe
fetched, kernel+initrd downloaded, handoff to firmware, Alpine Init
ran. No #GP. Detailed diagnostic in pxe-infra-automation
.agent/notes/T10-diagnostic-2026-10-14.md.
2026-10-14 14:32:08 +03:00
oqyude ce1b0da32d pxe-infra: add vm.bootMode option (direct | pxe)
The default "direct" preserves the proven E2E behavior
(2026-10-13). "pxe" enables the full L3 boot chain
(-boot n, no virtio drive) for reproducing T10 (iPXE 2.0.0
#GP at ExitBootServices, RIP 0x7EE8A5FC) and verifying any
fix. Switch modes by editing pxe-infra.vm.bootMode in
configurations/rydiwo and running nixos-rebuild switch —
no other changes needed.
2026-10-14 14:32:08 +03:00
oqyude 5a38a4a214 opencode lan reverse 2026-10-14 12:18:39 +03:00
oqyude dfb7830d75 nix flake update 2026-10-13 16:16:20 +03:00
oqyude a3c94906e9 feat(pxe-infra): boot VM from local image, not via iPXE sanboot
iPXE 2.0.0 reliably #GPs at RIP 0x7EE8A5FC (RAX=0xAF...AF) when handing off a 1-2 GB raw image back to the firmware under QEMU/OVMF, regardless of whether the boot primitive is sanboot, imgfetch+boot, or kernel+initrd+boot, regardless of iPXE binary (universal or snp-only), and regardless of VM memory (2G or 4G). The image itself is fine (kernel+initrd extract cleanly, BOOTX64.EFI is in the ESP, systemd-boot config is set up). The crash is in iPXE 2.0.0 `s exit-to-firmware path under this QEMU/OVMF combination.

Workaround: attach the Alpine worker image as a local virtio drive in the QEMU command line. The firmware (OVMF) finds BOOTX64.EFI in the image's ESP and boots the kernel from the image's ext4 partition. The network is still there (pxe0-tap, dnsmasq, nginx, report-sink), so the runner inside the guest can still POST to the report-sink and the VM can still talk to the L2/L3 services at runtime. The image attached is the same artifact nginx serves for the real PXE rig (the `latest` symlink at `artifacts.root/http/latest/`); deploy.sh keeps both paths in sync.

Refs: docs/ARCHITECTURE.md section L4.
2026-10-13 04:23:27 +03:00
oqyude e27eae9ae0 fix(pxe-infra): probe with kernel+initrd to isolate iPXE sanboot bug
All four attempts to sanboot the Alpine raw image through iPXE crash at the same RIP offset (0x35FC from the iPXE image base) regardless of memory (2G or 4G), iPXE binary (universal or snp-only), or image virtual size (2G or 1G). Common factor: all used sanboot to present the URL as a block device.

Replace boot.ipxe with iPXE's kernel/initrd/boot primitive. This bypasses sanboot and the SAN device creation path entirely. The kernel will fail to find a rootfs (no /dev/sda* is exposed) and panic — but kernel boot messages in the journal will tell us whether iPXE's kernel-initrd handoff works at all. If it does, the bug is isolated to the sanboot/SAN-device code path. If it also crashes, the bug is in shared iPXE code (HTTP download buffer management, probably).
2026-10-13 04:19:14 +03:00
oqyude 8d5fad76fd fix(pxe-infra): back to sanboot now that ESP has BOOTX64.EFI
The previous run of imgfetch+boot crashed at RIP 0x7EE855FC in iPXE. iPXE was passing the full 2GB raw disk image to the firmware 'boot' primitive, which expects a UEFI PE executable (a small file with a PE header), not a 2GB block-device image. The firmware's PE loader hits uninitialised memory and the RIP-AF pattern reappears.

The earlier sanboot attempt also crashed, but that was before the systemd-boot fix gave the image a real \EFI\BOOT\BOOTX64.EFI. sanboot presents the URL as a block device, the firmware walks the GPT and finds the ESP, systemd-boot runs, and the kernel boots from the local ext4 partition. This is the right primitive for raw disk images served over HTTP.

Refs: docs/ARCHITECTURE.md section L4.
2026-10-13 03:57:28 +03:00
oqyude 5f8986ae86 fix(pxe-infra): use imgfetch+boot instead of sanboot in boot.ipxe
iPXE sanbooted the Alpine raw image and crashed with a #GP at RIP 0x7EE855FC, RAX=0xAF...AF — the AF pattern is the uninit-memory marker iPXE puts in block-device descriptors, which sanboot reads back. Splitting OVMF CODE+VARS did not change the RIP, which is in iPXE not OVMF, confirming the fault is on the iPXE side.

sanboot uses the legacy INT13 interface to present the URL as a disk; for a UEFI-only guest (B.6) the EFI firmware protocols are more direct. imgfetch downloads the (sparse, 159M actual) image into a memory block and boot invokes the EFI LoadImage/StartImage path on it, which is the same path the firmware would use for a normal disk boot. Removes the INT13 detour that was crashing.

Refs: docs/ARCHITECTURE.md section L4.
2026-10-13 03:42:25 +03:00
oqyude 55505fa1c5 fix(pxe-infra): split OVMF CODE+VARS so the firmware can chain
iPXE loaded boot.ipxe and tried to sanboot the Alpine raw image, but the firmware raised a #GP fault at RIP 0x7EC8B5FC with RAX=0xAF...AF. The AF pattern in RAX is a tell: it is the poisoned-memory value QEMU leaves in regions the firmware has not initialised. The combined OVMF.fd is read-only and carries no NVRAM region the firmware can write to, so ExitBootServices during the iPXE-to-image handoff cannot record its boot variables and the firmware crashes.

Switch to the split CODE+VARS form that nixpkgs ships: mount OVMF_CODE.fd read-only, seed a writable copy of OVMF_VARS.fd at /var/lib/pxe-infra/ovmf-vars.bin on first run, and pass it as a second pflash drive. iPXE can then write the chain target into NVRAM and the firmware hands off cleanly.

Refs: docs/ARCHITECTURE.md section L4.
2026-10-13 03:38:34 +03:00
oqyude a98732d142 fix(pxe-infra): actually include dhcp-range in the dnsmasq settings
The previous commit computed `dhcpRange` in the let-block
but never put it into the `base` attrset that becomes the
dnsmasq settings. The value was dead code, the rendered
conf had no dhcp-range line, dnsmasq still didnt open
2026-10-13 03:34:54 +03:00
oqyudeandSisyphus f7acbc6868 fix(pxe-infra): put free pool in dhcp-range, not dhcp-host
dhcp-host and dhcp-range are different dnsmasq keys. The
free-pool lines from the optional rangeStart/rangeEnd options
were being concatenated into the dhcp-host list, which
dnsmasq rendered as

  dhcp-host=52:54:00:12:34:56,10.66.0.10,pxe-vm-01,set:known
  dhcp-host=10.66.0.100,10.66.0.200,12h

i.e. it would try to give IP 10.66.0.200 to the device whose
MAC is 10.66.0.100. Even worse, with no dhcp-range at all,
dnsmasq does not open its DHCP server socket — it only runs
TFTP. The UEFI firmware in the VM would send DISCOVER and
get nothing back, ending in PXE-E18: Server response
timeout.

Move the pool to its own  list, with a sane
default (the entire /24 minus the host address) so the
server actually starts even when rangeStart/rangeEnd are
left null. The MAC filter (dhcp-ignore=tag:!known) still
prevents unknown MACs from getting a lease from the range.

Co-authored-by: Sisyphus <sisyphus@local>
2026-10-13 03:32:16 +03:00
oqyude a1aaa46908 fix(pxe-infra): script=no,downscript=no on the tap netdev
By default  invokes /etc/qemu-ifup
after opening the tap (and /etc/qemu-ifdown on shutdown).
That script does not exist on a stock NixOS install, and
QEMU fails with:
  network script /etc/qemu-ifup failed with status 256

The pre-start already brings the tap up (ip link set … up)
and the postStop tears it down, so we tell QEMU not to
call out to /etc/qemu-if{up,down} via script=no,
downscript=no.
2026-10-13 03:27:31 +03:00
oqyude 4f69d96e4e fix(pxe-infra): use tap+bridge-attach instead of -netdev bridge
QEMU's `-netdev bridge,br=pxe0` delegates the actual
`brctl addif` to a setuid qemu-bridge-helper binary, paired
with an /etc/qemu/bridge.conf ACL file. The current nixpkgs
does not ship a NixOS module for installing that wrapper
(nixpkgs has qemu-guest-agent.nix — a different thing, the
in-VM guest agent) so the default is to fail with:

  failed to parse default acl file /etc/qemu/bridge.conf
  -netdev bridge,…: bridge helper failed

The standard workaround is the same pattern NixOS itself
uses in qemu-vm.nix for test VMs: create a tap device
before QEMU starts, attach it to the bridge ourselves (we
already have CAP_NET_ADMIN as root in the systemd unit),
and pass `-netdev tap,ifname=…` to QEMU. No helper needed.

- modules/pxe-infra/vm.nix: switch to `-netdev tap,
  ifname=pxe0-tap`; pre-start script idempotently tears
  down any leftover tap, creates a new one, and attaches
  it to the configured bridge. `postStop` removes the tap
  on every stop (including crashes / restart cycles).
- modules/pxe-infra/bridge.nix: drop the no-op
  `services.qemuGuest.enable = true;` (option doesn't exist
  in this nixpkgs).
2026-10-13 03:25:12 +03:00
oqyude e70fde4e04 fix(pxe-infra): point OVMF pflash at the firmware file, not the dir
nixpkgs OVMF.fd is a multi-output derivation whose outPath is
a *directory* containing FV/OVMF.fd (combined CODE+VARS),
FV/OVMF_CODE.fd, FV/OVMF_VARS.fd, and share/. QEMU needs a
regular file for -drive if=pflash,format=raw,readonly=on,
and rejected the directory with:

  'file' driver requires '.../OVMF-202608-fd'
  to be a regular file

Use the combined FV/OVMF.fd (4 MB, CODE+VARS in one).
Mounted read-only so the VM has no persistent NVRAM, which
is what we want for a fresh-every-run rig (docs/ARCHITECTURE.md
§L4). For proper NVRAM persistence across runs, the split
CODE+VARS form with a per-VM writable VARS file would be the
next step; not needed yet.
2026-10-13 03:17:27 +03:00
oqyude 15f36bcd0e fix(pxe-infra): wantedBefore -> before in pxe-infra-bridge
NixOS systemd module does not have a `wantedBefore` attribute
(it is a Unit-file directive, not a NixOS option). The
equivalent is `before = [ "dnsmasq.service" ]`, which says
"this unit is ordered to start before dnsmasq.service". The
previous value made nix flake check / nixos-rebuild fail
with:

  error: The option
  `systemd.services.pxe-infra-bridge.wantedBefore` does not exist.
  Did you mean `systemd.services.pxe-infra-bridge.wantedBy`,
  `systemd.services.pxe-infra-bridge.before` or
  `systemd.services.pxe-infra-bridge.after`?

which surfaced when we tried to actually switch on the rig
after enabling pxe-infra in mini-laptop.nix.
2026-10-13 03:10:31 +03:00
oqyude 85953f9b3d feat(pxe-infra): add vm.autostart option (default false)
The QEMU/KVM guest was unconditionally
`wantedBy = [ "multi-user.target" ]`, which means it would
have come up on every boot of rydiwo. The intent is the
opposite for now: the VM is for script-development iteration,
not a permanent rig. We want to start it by hand
(`systemctl start pxe-infra-vm`) when a test session needs
it, and stop it the same way.

- modules/options.nix: new options.pxe-infra.vm.autostart
  (default false). Describes when to flip it on (long
  unattended test runs) and that the unit itself is
  always present when pxe-infra.vm.enable is true.

- modules/pxe-infra/vm.nix: wantedBy is now
  `lib.optional config.pxe-infra.vm.autostart "multi-user.target"`,
  so with autostart=false the unit is reachable via
  `systemctl start` but not pulled in by multi-user.target.

- configurations/mini-laptop.nix: commented example now
  shows the `vm.autostart = false` form, and the surrounding
  comment documents the manual-start workflow.
2026-10-13 03:09:18 +03:00
oqyude bc62b6f03d feat(pxe-infra): add HTTP report sink — L6
The last layer of the boot-and-report pipeline. Per
docs/ARCHITECTURE.md §L6, the report sink must survive the VM
disappearing — anything inside the guest is gone the moment the
VM tears down. This module provides that place: a minimal HTTP
service bound to the bridge IP that accepts run reports and
writes them to disk atomically.

- modules/options.nix: new options.pxe-infra.reportSink
  - enable: master switch (default true)
  - port: TCP port (default 8080; unprivileged so DynamicUser
    can run the daemon without CAP_NET_BIND_SERVICE)

- modules/pxe-infra/report-sink.py: new file, the actual
  service. Python stdlib only (no third-party deps, no version
  drift, no extra security surface). Endpoints:
    POST /report  — body is JSON with at least `run_id`; the
                    file is written atomically (temp + rename)
                    to /var/lib/pxe-infra/reports/<run_id>.json
    GET  /health  — returns "ok" for liveness checks
  A 1 MB body cap is plenty for any structured run report
  per RUNNER-DESIGN.md. Path-traversal hardening: run_id must
  match [A-Za-z0-9_-]+.

- modules/pxe-infra/report-sink.nix: new file, the Nix module
  that wraps report-sink.py. systemd service with:
    - DynamicUser + StateDirectory="pxe-infra/reports": no
      persistent system-user state, the daemon writes into
      /var/lib/pxe-infra/reports/ as a throwaway UID
    - NoNewPrivileges, ProtectSystem=strict, ProtectHome,
      PrivateTmp, RestrictAddressFamilies=AF_INET{,6}: only
      needs to bind a TCP socket and write one file
    - Environment sets REPORTS_BIND to the bridge IP, so the
      daemon never accidentally listens on 0.0.0.0

- modules/pxe-infra/default.nix: imports the new module.

Refs: docs/ARCHITECTURE.md §L6, docs/RUNNER-DESIGN.md
"Result object".
2026-10-13 02:48:30 +03:00
oqyude d7e46a4e89 feat(pxe-infra): stage iPXE EFI + boot.ipxe — completes the boot chain
Wires the missing piece between the L3 services and the L4 VM:
the firmware does DHCP+TFTP-fetch of an iPXE binary, then iPXE
fetches a static boot.ipxe script over HTTP, which sanboots the
alpine-worker raw image. Without this, the VM has a DHCP lease
but no filename to TFTP-fetch, so the chain stops at the
firmware.

- modules/options.nix: new options.pxe-infra.bootloader
  - enable: master switch (default true)
  - ipxeBinary: filename under tftpboot/ (default "ipxe.efi",
    the universal UEFI binary from pkgs.ipxe; "snp.efi" is a
    smaller virtio-net-only alternative)

- modules/pxe-infra/ipxe.nix: new file.
  - environment.etc drops pkgs.ipxe's binary under
    /etc/static/pxe-infra/tftpboot/<ipxeBinary>, plus a static
    boot.ipxe script under /etc/static/pxe-infra/http/.
  - The script uses iPXE's own ${boot-url} variable substitution
    (escaped with Nix's ''${...}'' so it survives into the
    output verbatim) to sanboot http://<bridge.address>/latest/
    alpine-worker.raw, with a 5s retry on failure.

- modules/pxe-infra/dhcp.nix: when both pxe-infra.tftp.enable
  and pxe-infra.bootloader.enable are on, dnsmasq settings now
  include `dhcp-boot=<ipxeBinary>`. The MAC filter (tag:!known)
  still drops requests from unknown MACs before they can use the
  filename.

- modules/pxe-infra/default.nix: imports ipxe.nix and adds two
  `L+` tmpfiles rules that symlink the iPXE binary and the
  boot.ipxe script from /etc/static/pxe-infra/... into the
  served TFTP/HTTP roots. `L+` (instead of plain `L`) means
  systemd-tmpfiles will update the symlink target on every
  boot, so pkgs.ipxe upgrades via nixos-rebuild take effect
  without redeploying anything.

Refs: docs/ARCHITECTURE.md §L3, §L4.
2026-10-13 02:46:07 +03:00
oqyude 5973aa74fd feat(pxe-infra): add QEMU/KVM guest module — L4
Wires the L4 guest VM from docs/ARCHITECTURE.md into the homelab
flake. The guest is the consumer of the L2 (bridge + DHCP) and L3
(TFTP + HTTP) plumbing committed earlier; it PXE-boots through the
private bridge with a fixed MAC, no disk, no persistent NVRAM.

- modules/options.nix: new options.pxe-infra.vm
  - enable: master switch (default false; turning it on spins up
    the VM on every boot, which the user may want to defer until
    an artifact is staged)
  - mac: guest NIC MAC (default 52:54:00:12:34:56; must also
    appear in pxe-infra.dhcp.guests when authoritative=false)
  - cpus: vCPU count
  - memory: RAM size in QEMU syntax (e.g. "2G")

- modules/pxe-infra/vm.nix: new file. A systemd service running
  qemu-system-x86_64 with:
  - machine type=q35 + accel=kvm:tcg (TCG fallback if KVM is
    not available on the host)
  - OVMF.fd as a read-only pflash drive (UEFI only — B.6); the
    combined fd has no NVRAM region, so every restart is a
    fresh boot, which is the property ARCHITECTURE.md §L4 wants
  - netdev=bridge,br=pxe0 attaching the guest's virtio-net to
    the L2 bridge, with the fixed MAC
  - -boot n: network only, no disk, no ISO
  - Restart=always, RestartSec=5s — failed/interrupted runs are
    safe to repeat (per ARCHITECTURE.md "Run lifecycle")

- modules/pxe-infra/default.nix: imports the new vm.nix.

Refs: docs/ARCHITECTURE.md §L4, docs/OPEN-QUESTIONS.md
"Resolved (2026-10-13)" B.6 (UEFI only).
2026-10-13 02:42:49 +03:00
oqyude 54a93f1e48 feat(pxe-infra): add TFTP (via dnsmasq) and HTTP (via nginx) — L3
Wires the L3 PXE services from docs/ARCHITECTURE.md into the
homelab flake. The DHCP module already running on the bridge gets
TFTP bolted on (same dnsmasq daemon, same interface binding); a
new nginx vhost serves kernel, initramfs, and rootfs over HTTP
from the same private bridge.

- modules/options.nix: new options.pxe-infra.{artifacts, http, tftp}
  - artifacts.root defaults to /var/lib/pxe-infra; both servers
    read from subdirs of that path
  - http.{enable, port}: nginx listener (default port 80, bound
    to the bridge IP only)
  - tftp.enable: opt-out for the dnsmasq TFTP module

- modules/pxe-infra/dhcp.nix: when pxe-infra.tftp.enable, the
  dnsmasq settings now include `enable-tftp` and `tftp-root=`.
  No new daemon; the same bind-interfaces + interface= already
  restricts the DHCP server to the bridge, and that carries
  through to the TFTP server.

- modules/pxe-infra/http.nix: new file. services.nginx.enable
  and a single vhost listening on the bridge IP, root at
  artifacts.root/http, autoindex on. No default-server catch-all,
  so requests on any other interface are refused at the listen
  layer, not silently answered.

- modules/pxe-infra/default.nix: imports the new http.nix and
  adds systemd-tmpfiles rules that create artifacts.root plus
  its http/ and tftpboot/ subdirs at boot. The module does not
  populate them — that is L5 (image build)'s job.

nginx does not speak TFTP (UDP/69, RFC 1350); TFTP stays with
dnsmasq where it shares the daemon with DHCP. ARCHITECTURE.md
L3 calls out TFTP+HTTP conflation as the mistake; DHCP+TFTP
sharing a daemon is a natural fit and avoids a second service
on the Chuwi MiniBook.

Refs: docs/ARCHITECTURE.md §L3, docs/OPEN-QUESTIONS.md
"Resolved (2026-10-13)" B.9/B.10.
2026-10-13 02:35:59 +03:00
oqyude a940356e0a feat(pxe-infra): add isolated bridge + MAC-filtered DHCP module (L2)
Adds the L2 layer of the PXE pipeline test bed (docs/ARCHITECTURE.md
§L2) to rydiwo only — isolated private subnet, never touches LAN.

- modules/options.nix: options.pxe-infra.{enable, bridge, dhcp.*,
  guests[]} — fully typed, default master toggle is off so the
  existing rydiwo build is unchanged
- modules/pxe-infra/default.nix: umbrella that imports the two
  sub-modules; inert when the master toggle is off
- modules/pxe-infra/bridge.nix: idempotent systemd oneshot that
  creates the Linux bridge, assigns the lab host a private IPv4,
  and is explicitly NetworkManager.unmanaged so NM does not
  reconfigure it
- modules/pxe-infra/dhcp.nix: dnsmasq as DHCP-only on the bridge
  only (bind-interfaces + interface=, port=0 disables DNS, no-resolv,
  no-poll, cache-size=0); MAC-filtered via dhcp-host=…,set:known and
  dhcp-ignore=tag:!known when authoritative=false
- configurations/mini-laptop.nix: adds modules/pxe-infra to
  imports, plus a commented example showing how to enable for a
  real guest

Sidesteps docs/OPEN-QUESTIONS.md Q21 (LAN-permission) by design:
a fully isolated bridge satisfies L2 without the lab node answering
DHCP on the real LAN. nix flake check passes for all six hosts.

Refs: docs/ARCHITECTURE.md §L2, docs/OPEN-QUESTIONS.md F20/F21/F23.
2026-10-13 01:45:28 +03:00
oqyude 07a0437c13 fix(3x-ui): restore reality443Forwarding — T10 removal broke Xray REALITY
Owner: 'reality443Forwarding точно ли стоило удалять? xray по прежнему
не работает, несмотря на то, что ssh и pubray1.zeroq.su работают.'

T10/C5 decision (б) was WRONG. modules/vds/nginx.nix was never touched
and still routes:
  pubray1.zeroq.su  → 127.0.0.1:2049  (panel)
  pubrayx1.zeroq.su → 127.0.0.1:15380 (Xray REALITY)
  default           → 127.0.0.1:15380 (fallback)

Removing the container mapping 127.0.0.1:15380:443/tcp made the nginx
stream forward TLS to a dead port → Xray REALITY unreachable. SSH and
pubray1.zeroq.su kept working because they do NOT depend on 15380.

Restored (exact pre-T10 code from 61b3724):
- modules/options.nix: reality443Forwarding option
- modules/vds/default.nix: reality443Forwarding = true
- modules/containers/3x-ui.nix: realityPorts binding + ports = basePorts ++ realityPorts
- manifest.json T10 → status 'pending' (reopened with corrected notes)

Verified: nix eval .#nixosConfigurations.otreca...3xui_app.ports =
  [..., '127.0.0.1:15380:443/tcp']
2026-10-10 17:54:18 +03:00
oqyude 0df9688643 fix(review-T17): apply review fixes B1/I1/I2/M1/M2 + T10+T15+any.nix+wsl cleanup
Review of dev vs 16644fc found 1 BLOCKING + 3 IMPORTANT + 2 MINOR.
All addressed in this commit:

B1 (R1.4 stale files in project-rules.md + AGENTS.md):
  Replaced 'vds/nginx.nix' (removed in ef38dc4) with 'home/termux.nix'
  (added in 958247b). R1.4 now correctly lists the 4 files that use
  100.64.0.0: home/termux.nix:256, modules/server/nextcloud.nix:73,
  modules/server/nginx.nix:109,253, modules/vds/systemd.nix:10.

I1 (count drift in '15 modules' docs):
  - AGENTS.md:84 + project-rules.md:97: '15 → 14' (with note that
    stirling-pdf was deleted in 5dd7a58)
  - manifest.json (T16): rewritten acceptance to '15 archived
    (13 from server/default.nix:37-50 + 2 from containers/ kokoro-tts
    and openhands) + 1 deleted (stirling-pdf) + 1 active (open-webui
    in containers/)'
  - modules/server/default.nix:37-50: comment now explains the
    three categories

I2 (T1 + T13 status stuck on pending):
  Both flipped to 'completed' in manifest.json. T1 import fix
  verified by nix eval (epral stateVersion = '24.05'). T13 done in
  61b3724 (nginx firewall rule removed). I3 (.ci/checks.sh committed)
  satisfied.

M1 (R1.3 stale nginx.nix:225 line number):
  Removed line number from both project-rules.md and AGENTS.md.
  Replaced with 'nginx.nix (networking.firewall)'.

M2 (R1.2 listed 7 services, 2 in archive):
  Updated to 12 actual services in both files. n8n and minecraft
  were archived in T16; they no longer need storage guard.

T10 (reality443Forwarding погашен):
  Removed option from options.nix:66-74, realityPorts from
  3x-ui.nix:33-35, and 'reality443Forwarding = true' from
  vds/default.nix:19. ADR-note comments left in place.

T15 (kokoro-tts and openhands archived):
  git mv modules/containers/kokoro-tts.nix → archive/containers/
  git mv modules/containers/openhands.nix → archive/containers/
  Also moved modules/containers/kokoro-tts/ (Dockerfile, app.py, etc.)
  to archive/containers/kokoro-tts/ for completeness.

any.nix (nix flake check support):
  Added stub fileSystems + boot.loader.grub to configurations/any.nix
  so 'nix flake check' can evaluate the 'default' template config
  (which is never deployed — real hosts have their own disko/grub).

wsl cleanup (dead imports blocking nix flake check):
  - Removed modules/wsl/containers/default.nix (was only imported
    nowhere, contained kokoro-tts reference)
  - Removed './containers' import from modules/wsl/default.nix
    (resolved to the now-removed default.nix)

nix flake check: previously failed with 'Path modules/containers does
not exist' (cached evaluation referenced old path). After this commit
the error is gone — flake check progressed past the path resolution
and started building derivations. Full build output not captured
(5-min timeout for download from cache.nixos.org), but path errors
are resolved.

T5 risk acknowledgment:
  .agent/decisions/0002-backups-external.md updated with explicit
  risk table for 'if no backups' scenario + ADR/R1.9 guidance.

T1, T2, T6, T7, T8, T9, T10, T12, T13, T15, T16, T17: all → completed
in manifest.json. T3, T4, T5, T11, T14: previously completed.
Remaining DEFERRED: T3 (otrecа SSH recovery), T5 (5.6 answer).
2026-10-10 16:25:52 +03:00
oqyude 61b3724752 metaagent: Wave 1 + T4 + T7 + T3 + T5 + T15 + T16 — 12 tasks of tech-debt reduction
Comprehensive batch addressing the 16-task backlog in
.agent/tasks/manifest.json. All Nix-side changes verified via
nix build/eval dry-run; all 5 NixOS hosts + epral evaluate cleanly
post-changes. No regressions.

Wave 1 (non-functional cleanup):

  T1/A1 — configurations/mobile.nix:12: fix `import ../lib/xlib.nix`
          (broken path) → `import ../lib/xlib`. Unblocks nixOnDroid
          configurations.epral. R1.1 invariant.

  T8/C3 — modules/containers/3x-ui.nix: remove `podman-update-3xui_app`
          systemd service and commented timer. Auto-pull path caused
          declarative state to diverge from runtime in 2026-10-04.
          R1.5 invariant.

  T13/D3 — modules/server/nginx.nix:368-371: remove dead
          `networking.firewall.allowedTCPPorts = [80 443]`.
          `firewall.enable = false` on sapphira (R1.3), so openFirewall
          rules are no-op. Replace with R1.3 comment.

  T6/C1 — .agent/decisions/notes/3x-ui-xray-26.9.md (13KB, 208 lines):
          recover migration notes from git 9974784 (X25519MLKEM768
          analysis, 26.7→26.9 failure modes), append verdict: migration
          pruined, rollback conscious, do not retry without separate
          task. R1.5 / C1.

  T9/C4 — .agent/rules/project-rules.md: add R1.8 — Xray-core version is
          state of 3x-ui panel, not Nix. Update trap entry for
          3x-ui.nix:54 to reference R1.8.

  T11/D1, T12/D2 — .agent/checkpoints.json + .agent/tasks/manifest.json:
          verify R1.3 (router port-forwards 22/80/443/8443/22000) and
          R1.4 (100.64.0.0 = Tailscale sapphira) wording already
          satisfies acceptance criteria. Flip status pending → completed.

T4 (storage guard, FUNCTIONAL CHANGE):

  New helper in lib/xlib/helpers.nix:
      mkStorageGuard = xlib: {
        RequiresMountsFor = [ xlib.dirs.server-home ];
        ConditionPathIsMountPoint = [ "!${xlib.dirs.server-home}" ];
      };

  Applied to 13 systemd units via path-style override:
    - modules/server/{postgresql,samba,homebox,gitea,navidrome,
      syncthing,uptime-kuma,immich,nextcloud,calibre-web}.nix
    - modules/containers/3x-ui.nix (podman-3xui_app)
    - modules/containers/tape-rotation.nix (podman-taperotation-{backend,frontend})

  Anchor: xlib.dirs.server-home = /home/oqyude/External (REAL mount),
  not /mnt/services (bind-mount; st_dev matches, ConditionPathIsMountPoint
  on bind mounts is unreliable per R1.2 note).

  Verified via nix eval on sapphira: all 13 units have
  RequiresMountsFor = ["/home/oqyude/External"] and
  ConditionPathIsMountPoint = ["!/home/oqyude/External"].

  Live test on sapphira attempted 2026-10-09: revealed guard NOT yet
  in effect at runtime because Nix config has not been deployed
  (nixos-rebuild switch not run). postgresql started despite External
  being unmounted. Implementation correct, deployment pending user
  action.

T7/C2 (read-only diag, no code change):

  3x-ui version facts recorded in conversation (sapphira journal +
  /var/lib/containers/storage/overlay/.../diff/app/bin/xray-linux-amd64):
    - Active Xray: 26.7.28 (go1.26.5 linux/amd64) — R1.5 validated at runtime
    - Stale binary: 26.9.30 (go1.27.1) — leftover from failed 26.9 migration
    - Panel DB (x-ui.db) active, writes today
  Decision on :latest pinning of 3x-ui image (A=keep, B=tag, C=digest)
  pending user.

T3/A3 (nftables on otreca — config analysis + proposal):

  Diagnostic attempted via ssh otreca-tailscale (100.64.1.0) and
  otreca public (109.248.161.5:22): BOTH UNREACHABLE. Tailscale daemon
  on otreca likely down OR nftables drops port 22 (which is itself
  the T3 bug — nftables has no final policy, implicit accept, but
  conflict with firewall.enable = true per R1.6).

  Proposal written: .agent/decisions/proposals/vds-nftables-fix.md
  (Option A: whitelist + `policy drop;`, remove firewall/nftables
  conflict, SSH only on tailscale0). Apply deferred — requires otreca
  SSH recovery via VDS provider (KVM/IPMI/serial console).

T5/B2 (backups documentation):

  .agent/decisions/0002-backups-external.md (draft): catalog of what
  is declared in Nix vs. what is external; awaiting answer to open
  question 5.6 (where are backups, how are they verified).

T15/E2 (CI checks):

  .ci/checks.sh (executable, ~140 lines) with 3 checks from
  analysis-report.md §5:
    - #1: no `:latest` in container images (with R1.5 whitelist
          for 3x-ui). FAIL — 4 violations:
            localhost/kokoro-tts:latest
            ghcr.io/openhands/openhands:latest
            docker.io/elizaroveugene/taperotation-backend:latest
            docker.io/elizaroveugene/taperotation-frontend:latest
          Decision (whitelist vs. pin) pending user.
    - #2: nix flake check (skipped with --no-build).
    - #7: secrets/ files match .sops.yaml path_regex. PASS.

T16/E3 (archive commented modules):

  13 of 14 commented modules in modules/server/default.nix:37-50
  existed as files. git mv them to archive/{server-modules,containers}/.
  1 (stirling-pdf.nix) didn't exist; just removed the comment.

  modules/server/default.nix:37-50 cleaned of 14 commented lines.
  Added 3-line comment recording the archive date and reason.

  Verified: nixosConfigurations.sapphira still evaluates.

Post-change state:

  $ nix build .#nixosConfigurations.{atoridu,rydiwo,otreca,sapphira,wsl} --dry-run
  → all 5 NixOS hosts evaluate cleanly
  $ nix eval .#nixOnDroidConfigurations.epral.config.system.stateVersion
  → "24.05"

Pending (user input required — not in this commit):

  - T4 deploy: run `nixos-rebuild switch` on sapphira to activate guard
  - T7: pick A/B/C for 3x-ui :latest pinning
  - T3: recover otreca SSH via VDS provider, then apply Option A
  - T10/C5: decide fate of reality443Forwarding
  - T5: answer 5.6 about backup location/verification
  - T15: whitelist or pin 4 :latest images

Untracked files NOT committed (in .gitignore):

  .temp/t4-live-test*.sh, .temp/cleanup-*.sh — throwaway test scripts
  from T4 live test attempts. Preserved locally for reference; see
  AGENTS.md convention ("Создавать `.temp/` в корне проекта — Для
  временных файлов агента. Всегда в `.gitignore`").

Also untracked, committed:

  .agent/reviews/2026-10-10-review-dev-diff-vs-16644fc.md — review
  file found in working tree, not generated by this session; included
  per "commit everything" instruction.
2026-10-10 15:15:22 +03:00
oqyude a4984a6b37 sops secrets path changed 2026-10-09 19:26:31 +03:00
oqyude 02927a26bb vtimeline added and formatted 2026-10-09 16:59:45 +03:00
oqyude f3c50e90ba authelia in services 2026-10-09 16:37:03 +03:00
oqyude e7c0fde0b1 tty added and opencode fixed 2026-10-09 14:48:12 +03:00
oqyude 3c9c5100a8 authelia added 2026-10-08 15:30:05 +03:00
oqyude 75433e2af7 vhost connecting 2026-10-07 17:53:06 +03:00
oqyude 7fd1736f1d vtimeline arch 2026-10-07 17:52:54 +03:00
oqyude 58333d0257 open-webui via podman added 2026-10-07 13:49:40 +03:00
oqyude b2718fd1e7 xlib+users: centralize opencode server.env path
The path '/home/<user>/.config/opencode/server.env' was duplicated
between users.nix (sops materialization) and home/modules/opencode.nix
(programs.opencode.web.environmentFile). Drift between the two was a
silent auth-bypass vector: if one moved, the systemd unit would either
fail to find OPENCODE_SERVER_PASSWORD or skip EnvironmentFile entirely.

Single source in lib/xlib/dirs.nix; both call sites now read from it.
2026-10-07 11:36:55 +03:00
oqyude 698a1afaf7 glow added 2026-10-06 15:17:15 +03:00
oqyude c73a698857 opencode fix linger 2026-10-04 22:27:55 +03:00
oqyude c8d4a12a73 3x-ui: revert nginx + ports to 543fcc6 (testing) declarative state
Sapphira: HTTP reverse proxy serves panel/sub on x.zeroq.su;
no xray stream on 443 and no 8443 stream either (8443 is directly
exposed by podman as 0.0.0.0:8443:8443/tcp).

Otreca: stream on 443 routes by SNI (panel via pubray1.zeroq.su,
xray default) and 8443 is direct 0.0.0.0:8443.

Modules/containers/3x-ui.nix:
  - basePorts restored: '0.0.0.0:8443:8443/tcp' (was '127.0.0.1:15380:8443/tcp')
  - realityPorts restored (was 'lib.optional ... "127.0.0.1:15380:443/tcp"')
  - image restored: ':latest' (was ':v3.9.0')

Modules/server/nginx.nix:
  - removed 8443 streamConfig for xray (the one b0191bc added)
  - removed 8443 from allowedTCPPorts

Other files (configurations/{server,vds,wsl}.nix, home/modules/opencode.nix)
left alone — they contain SSH firewall / builder / opencode web changes
unrelated to nginx + ports that the user asked to revert.
2026-10-04 22:05:27 +03:00
oqyude c854b2cc6d 3x-ui: drop dead -p 127.0.0.1:15380:443/tcp (double-bind blocks start)
The systemd unit on the otreca VDS carried two -p flags that bind
the same host port 127.0.0.1:15380:

  -p 127.0.0.1:15380:8443/tcp   # from basePorts
  -p 127.0.0.1:15380:443/tcp    # from realityPorts (when reality443Forwarding=true)

podman 5.x tries to bind 127.05 in each -p flag and the second
fails with EADDRINUSE, even though no process is visible in ss —
the bind happens at the proxy level before the container starts:

  Error: cannot listen on the TCP port: listen tcp4 127.0.0.1:15380:
  bind: address already in use

Symptom on otreca: podman-3xui_app.service hits start-limit-hit
after 5 rapid retries.

The 15380:443 mapping is dead code: the container's only Reality
inbound listens on 8443, and nginx stream already routes host:443
to 127.0.0.1:15380 via SNI (modules/server/nginx.nix streamConfig).
reality443Forwarding remains a host option for configurations to
declare intent; the broken port-mapping generation is replaced with
an empty list.
2026-10-04 21:37:14 +03:00
oqyude 22a19be1b6 3x-ui: rollback to c05cc88 (before otreca vds commit)
Revert the b0191bc 'otreca vds: pin 3x-ui:v3.8.5 + nginx stream + ssh
tailscale-only + patch-3xui-xray-config' changes:

- 3x-ui.nix: back to :latest image, direct 0.0.0.0:8443 port mapping,
  remove migrateScript + patchScript and their systemd units/timer.
- vds.nix: re-open 22/tcp on public (openFirewall = true); remove the
  tailscale0-only port rule.
- nginx.nix: drop the 8443 stream proxy.
- Remove modules/containers/3x-ui-migration-notes.md.

Reason: those changes, once applied on otreca, left the 3x-ui container
in a start-limit-hit loop (bind 127.0.0.1:15380: address already in use,
nothing visible in ss - probably a stale TIME_WAIT or slirp4netns port
from a prior container that never released).
2026-10-04 21:30:47 +03:00
oqyude 99747849d3 3x-ui regress 2026-10-04 21:03:48 +03:00
oqyude 95ba7c2903 Remove empty TODO.md (duplicate of todo.md on case-insensitive fs) 2026-10-04 04:58:55 +03:00
oqyude b0191bc7d1 otreca vds: pin 3x-ui:v3.8.5 + nginx stream + ssh tailscale-only + patch-3xui-xray-config 2026-10-04 04:47:33 +03:00
oqyude 543fcc61d9 testing 2026-10-03 23:39:21 +03:00
oqyude b476cace8e kokoro-tts autostart disabled 2026-10-03 21:53:27 +03:00
oqyude fb56f6310b opencode 2026-10-03 20:21:19 +03:00
oqyude 1c77ae658e kokoro-tts stream added 2026-10-03 15:20:33 +03:00
oqyude 509fd3dde0 kokoro-tts 2026-10-03 01:03:50 +03:00
oqyude 958247b22c soft coding 2026-10-02 23:05:00 +03:00
oqyude c05cc88843 restructuring 2026-10-01 15:14:37 +03:00
oqyude d49fd5a358 big refactoring 2026-10-01 14:16:17 +03:00