Files
nixos/modules/server/default.nix
T
oqyude 0aa4bed7f2 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-19 18:23:19 +03:00

82 lines
3.2 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.
{
lib,
pkgs,
xlib,
...
}:
{
imports = [
../containers/3x-ui.nix
../containers/open-webui.nix
../containers/tape-rotation.nix
../pkgs/beets.nix
./acme.nix
./authelia.nix
./bentopdf.nix
./builder.nix
./calibre-web.nix
./chrony.nix
./coredns.nix
./gitea.nix
./gitea-runner.nix
./glances.nix
./homebox.nix
./immich.nix
./miniflux.nix
./navidrome.nix
./nextcloud.nix
./nginx.nix
./nix-serve.nix
./onlyoffice.nix
./postgresql.nix
./power.nix
./samba.nix
./syncthing.nix
./systemd.nix
./ttyd.nix
./vtimeline.nix
./uptime-kuma.nix
./engipy-frontend.nix
./engipy-backend.nix
# T16: 14 modules archived to ../archive/{server-modules,containers}/
# (13 in modules/server/default.nix:37-50, 2 in modules/containers/).
# T15: kokoro-tts and openhands (not imported) also archived.
# stirling-pdf.nix was deleted in 5dd7a58 (absorbed into bentopdf.nix).
# open-webui.nix was never commented — migrated to containers/,
# still active via ../containers/open-webui.nix above.
];
# Server's 3x-ui is the controller panel at x.zeroq.su (nginx HTTP
# terminates TLS upstream, no SNI-routing on 443 needed here because
# there are other vhosts on the same port). Cert is still mounted in
# case 3x-ui is later reconfigured to terminate TLS itself (e.g. for
# direct node-API access); nginx doesn't have to use it.
host."3x-ui".certDomain = "x.zeroq.su";
# Authelia SSO — currently protects vtimeline.zeroq.su (replaces the
# previous nginx auth_basic htpasswd). Cookie domain is .zeroq.su so a
# single Authelia session covers every protected vhost under the zone.
host.authelia = {
enable = true;
cookieDomain = "zeroq.su";
};
# engipy webapp — split architecture:
# - sapphira : host.engipy-frontend.enable → nginx vhost (engipy.zeroq.su)
# с /api/* на rydiwo:8000 и / → /var/lib/engipy/web
# - rydiwo : host.engipy-backend.enable → systemd engipy (uvicorn + ML)
# Оба модуля импортируются для всех server/deviced хостов, и через
# host.*.enable выбирается только то, что нужно на конкретной машине.
# Причина — sapphira слабая (2 cores, 5.6 GB RAM) и не вытянет torch;
# rydiwo 4 cores / 11 GB держит uvicorn+sentence-transformers без свопа.
# engipy webapp (uvicorn) тащит python311 + fastapi + pydantic +
# sentence-transformers. sphinx-9.1.0 не поддерживается для python3.11
# (см. https://nixos.org/manual/nixpkgs/unstable#sec-problems — unsupportedPython).
# sphinx не используется в runtime, поэтому глушим evaluation-error до
# warning. Альтернатива — переезд на pkgs.python312, но проще держать
# python311 в соответствие с тем, как код собирается локально.
nixpkgs.config.problems.handlers.sphinx.unsupportedPython = "warn";
systemd.tmpfiles.rules = [
(xlib.helpers.mkTmpfile "d" "/mnt" "0755" "root" "root")
(xlib.helpers.mkTmpfile "d" xlib.dirs.services-mnt-folder "0755" "root" "root")
];
}