Files
nixos/configurations/mini-laptop.nix
T
oqyude f99f2d057b
test-runner / smoke (push) Successful in 1s
feat(server): split engipy — frontend на sapphira, backend на rydiwo
Sapphira (2 cores, 5.6 GB RAM) не вытянет torch/sentence-transformers —
первый nixos-rebuild на ней упал с No space left on device и долгим
копированием 50+ MB ML-deps с узкого cache.nixos.org канала. Разносим
архитектуру:

  * engipy-frontend.nix (sapphira) — только nginx vhost engipy.zeroq.su.
    /api/* → proxyPass на 192.168.1.102:8000 (rydiwo). Статика
    /var/lib/engipy/web на root fs (без bind-mount, External не нужен).
    Authelia forward-auth через wildcard *.zeroq.su → one_factor.

  * engipy-backend.nix (rydiwo) — systemd unit engipy с uvicorn +
    FastAPI + полный ML-стек. bindAddress=0.0.0.0, чтобы sapphira
    могла проксировать по LAN. Sandbox через PrivateTmp/ProtectSystem
    + LD_LIBRARY_PATH для libgomp/openblas (нужно torch CPU-wheel'у).

  * requirements.nix — wheels с PyPI + torch 2.6.0+cpu c
    https://download.pytorch.org/whl/cpu. Все sha256-хэши посчитаны
    в WSL nixos через 'pip download --only-binary=:all: --platform
    manylinux_2_17_x86_64' + 'nix hash path --type sha256'. Никакой
    компиляции — только скачивание wheels на rydiwo (~5-10 мин rebuild).

  * configurations/server.nix — host.engipy-frontend.enable = true +
    backendHost = 192.168.1.102.

  * configurations/mini-laptop.nix — host.engipy-backend.enable = true +
    bindAddress = 0.0.0.0 + logind.lidSwitch = ignore (rydiwo
    используется как headless-сервер, не засыпать при закрытии крышки).

nsot: старый engipy.nix (185 строк) удалён — он делал всё сразу на одном
хосте, что перегружало sapphira. nginx.nix vhost перенесён в
engipy-frontend.nix, чтобы не дублировать.
2026-10-16 13:31:54 +03:00

91 lines
3.1 KiB
Nix
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 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
];
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 + SBERT + torch.
# Python-окружение через fetchPip — wheels с PyPI, без компиляции
# (см. modules/server/engipy-backend.nix). Sapphira проксирует
# engipy.zeroq.su/api/* на 192.168.1.102:8000 — это адрес rydiwo
# в LAN.
#
# Сгенерировано в WSL nixos — см. requirements.nix + gen_reqs.py.
host.engipy-backend = {
enable = true;
bindAddress = "0.0.0.0";
};
# Не засыпать при закрытии крышки: rydiwo используется как
# headless-сервер для engipy (sapphira проксирует /api/* на него).
# Если пользователь берёт ноутбук в руки — пусть остаётся правило
# по умолчанию (suspend); но для unattended-режима нужно ignore.
services.logind.lidSwitch = "ignore";
services.logind.lidSwitchDocked = "ignore";
system.stateVersion = "26.05";
# --------------------------------------------------------------------------
# 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";
bridge.prefixLength = 24;
bootloader.ipxeBinary = "snp.efi"; # SNP-only build, 310K, virtio-net-friendly
vm = {
enable = true;
autostart = false; # start manually when testing
memory = "4G"; # iPXE needs 2G+ heap to sanboot a 2G raw image
};
dhcp.guests = [
{
mac = "52:54:00:12:34:56";
ip = "10.66.0.10";
hostname = "pxe-vm-01"; # optional
}
];
};
# --------------------------------------------------------------------------
}