Files
nixos/configurations/mini-laptop.nix
T
oqyude 0ae07a3720
nixos flake checks / invariant-checks (push) Failing after 8s
test-runner / smoke (push) Successful in 1s
rydiwo: temporarily shrink /swapfile to 0.5 GiB so the switch fits
The box has 20 GiB free and the pending nixos-rebuild switch needs 22.2 GiB unpacked. Shrinking the 6 GiB swap file to 512 MiB lets the build fit; it goes back to 6144 after the switch and the garbage collection that follows.
2026-11-12 05:32:52 +03:00

166 lines
7.5 KiB
Nix

# Host: "rydiwo" (device: secondary)
#
# The host record lives in configurations/default.nix; this file is only the
# module body. `xlib` (identity, dirs, helpers) arrives as a module argument.
{
lib,
pkgs,
xlib,
inputs,
...
}:
{
imports = with inputs; [
nixos-hardware.nixosModules.chuwi-minibook-x
./hardware/mini-laptop.nix
self.nixosModules.default
../modules/pxe-infra
../modules/server/engipy-backend.nix
];
boot = {
kernelPackages = lib.mkDefault pkgs.linuxPackages_xanmod_stable;
loader = {
systemd-boot.enable = lib.mkDefault true;
efi.canTouchEfiVariables = lib.mkDefault true;
};
};
fileSystems = xlib.helpers.mkNtfsMount {
path = xlib.dirs.lamet-drive;
uuid = "DC76BD3576BD116E";
mask = "0000";
};
host.ssh.enable = true;
hardware.intel-gpu-tools.enable = true;
# engipy webapp backend на rydiwo: uvicorn + FastAPI + ONNX-SBERT.
# Python-окружение через pip-venv на rydiwo (см. modules/server/engipy-backend.nix).
# Sapphira проксирует engipy.zeroq.su/api/* на 192.168.1.102:8000.
#
# model = путь к локальной ONNX-папке (экспорт `cointegrated/rubert-tiny2`
# сделан в WSL nixos и разложен на rydiwo). HF Hub id
# `cointegrated/rubert-tiny2` НЕ должен здесь стоять — это
# триггерит optimum через from_pretrained() скачивать с HF и
# конвертировать через torch, что падает в
# `RuntimeError: could not create a primitive` в GELU activation.
#
# T-MULTI-MODEL-REGISTRY (commit cd64a8e, 2026-10-18): 3 модели
# (rubert-tiny2 default + BAAI/bge-m3 + intfloat/multilingual-e5-large)
# лежат на /mnt/lamet/engipy-models/. `model` указывает на default
# (rubert-tiny2), `ENGIPY_MODELS_DIR` (`modelsDir`) — корень для всех
# трёх (см. modules/server/engipy-backend.nix). Старая папка
# /var/lib/engipy/model/cointegrated__rubert-tiny2/ больше не
# используется и может быть удалена вручную после успешного deploy.
host.engipy-backend = {
enable = true;
bindAddress = "0.0.0.0";
# Default ONNX-чекпойнт rubert-tiny2 теперь лежит на /mnt/lamet/
# (в ENGIPY_MODELS_DIR — см. engipy-backend.nix). Имя подпапки
# фиксировано в `app/services/models.py:build_default_registry`.
model = "/mnt/lamet/engipy-models/rubert-tiny2";
# `modelsDir` остаётся дефолтным (/mnt/lamet/engipy-models).
};
# Не засыпать при закрытии крышки: rydiwo используется как
# headless-сервер для engipy (sapphira проксирует /api/* на него).
# Если пользователь берёт ноутбук в руки — пусть остаётся правило
# по умолчанию (suspend); но для unattended-режима нужно ignore.
#
# 2026-11-01: `services.logind.lidSwitch` / `lidSwitchDocked` переименованы
# в nixpkgs (`services.logind.settings.Login.HandleLidSwitch{,Docked}`) —
# старое имя работает, но печатает предупреждение при каждой оценке.
# Значения те же, что и у systemd в logind.conf.
services.logind.settings.Login = {
HandleLidSwitch = "ignore";
HandleLidSwitchDocked = "ignore";
};
system.stateVersion = "26.05";
# TEMPORARY 2026-11-12: the box has 20 GiB free and the pending
# `nixos-rebuild switch` needs 22.2 GiB unpacked, so the 6 GiB swap file is
# shrunk to 0.5 GiB to make the build fit; it goes back to 6144 after the
# switch and the garbage collection that follows. Not a permanent choice.
# Measured 2026-11-11: a 6 GiB /swapfile exists and is active, but only
# because somebody ran `swapon` by hand — there is no swapDevices in the
# config and no swap line in the generated /etc/fstab, so a reboot loses
# swap. On this 11 GiB box (it runs qemu VMs) that turned a build into an
# OOM kill.
swapDevices = [
{
device = "/swapfile";
size = 512;
}
];
# Measured 2026-11-11: nixos-prebuild.service (daily 04:00 nix build of the
# whole toplevel, Nice 10, CPUQuota 20% — defined in
# modules/essentials/systemd-routines.nix, shared by every host, so no cap
# there) had no memory bound and was what got killed when memory ran out.
# Host-scoped bound: 6 GiB of the 11 GiB box stays for engipy/the VMs.
systemd.services.nixos-prebuild.serviceConfig.MemoryMax = "6G";
# --------------------------------------------------------------------------
# PXE infrastructure rig (L2 of docs/ARCHITECTURE.md).
# The rig gives rydiwo an isolated Linux bridge
# (`pxe-infra.bridge.name`, default `pxe0`) plus a MAC-filtered
# dnsmasq DHCP server bound only to that bridge — the real LAN is
# not touched. The QEMU guest (L4) is configured but NOT
# autostarted: start it by hand with
# systemctl start pxe-infra-vm
# when a test session needs it, and stop it the same way. Set
# `vm.autostart = true` here to bring the VM up on every boot
# (e.g. for a long unattended test run). See `modules/options.nix`
# (options.pxe-infra.*) for the full option surface and
# `modules/pxe-infra/` for the implementation.
pxe-infra = {
enable = true;
bridge = {
address = "10.66.0.1";
prefixLength = 24;
};
# ipxe.efi (universal, ~600K) instead of snp.efi (SNP-only, 310K).
# snp.efi worked on linux-virt 6.18.56 but breaks on 6.18.57
# (delivered via aports 2b1f5137, 2026-10-16, kernel commit
# c967b365 — `PCI: Make pci_match_one_device() match on ID
# instead of device`). The new drivers/pci/search.c
# `match_pci_dev_by_id()` (uses pci_match_one_id()+pci_id_from_device())
# fails to match the virtio-blk PCI device that snp.efi
# presents through its SAN hook (the IDs reported by the SAN
# path are not full device IDs). The kernel boots, but rootfs
# fails to mount: `UUID=...: Can't lookup blockdev` →
# `Mounting root: failed.` The universal `ipxe.efi` presents
# the SAN device through a different code path that
# successfully matches against the new pci_match machinery.
# Verified end-to-end on rydiwo 2026-10-17 with explicit
# `bootMode=pxe`: two independent verdict=PASS reports
# (20261017T180654Z, 20261017T180730Z). See pxe-infra-automation
# T14 in .agent/tasks/manifest.json for full RCA. The ~290K
# extra TFTP volume vs snp.efi is negligible.
bootloader.ipxeBinary = "ipxe.efi";
vm = {
enable = true;
autostart = false; # start manually when testing
memory = "4G"; # iPXE needs 2G+ heap to sanboot a 2G raw image
# bootMode=pxe: the guest boots over the network (TFTP → iPXE →
# HTTP → kernel+initrd) instead of from the attached raw image.
# This is the production path for the READ-ONLY payload (T24):
# the initramfs carries the squashfs rootfs inside itself, so
# the guest needs no disk at all and the chain does not depend on
# iPXE's SAN-boot extensions (T14/R1). `direct` remains the
# legacy disk profile (the attached alpine-worker.raw).
bootMode = "pxe";
};
dhcp.guests = [
{
mac = "52:54:00:12:34:56";
ip = "10.66.0.10";
hostname = "pxe-vm-01"; # optional
}
];
};
# --------------------------------------------------------------------------
}