45 Commits
Author SHA1 Message Date
oqyude 0c8f286499 3xui-reconfig: автозапуск при загрузке хоста и при рестарте контейнера панели
nixos flake checks / invariant-checks (push) Successful in 4m19s
test-runner / smoke (push) Successful in 2s
Дополнение владельца: «Пусть будет автоматически стартовать после перезагрузки
хоста и перезагрузки 3x-ui контейнера».

Механизм — декларативный Wants, без ExecStartPost и без OnSuccess:
- wantedBy = [ "podman-3xui_app.service" ] → nixpkgs создаёт symlink
  podman-3xui_app.service.wants/3xui-reconfig.service, поэтому юнит
  стартует (а) при загрузке хоста (контейнер панели тянется из
  multi-user.target) и (б) при каждом старте/перезапуске контейнера панели;
- after = [ "podman-3xui_app.service" "nginx.service" ] — контейнер и nginx
  уже подняты к моменту запуска;
- OnSuccess= неприменим: podman-3xui_app.service — Type=notify
  (долгоживущий), OnSuccess= на нём не срабатывает никогда.

Обёртка ждёт готовности панели (PANEL_WAIT_SECONDS, по умолчанию 90 c):
при автозапуске контейнер и nginx поднимаются параллельно, HTTP-сервер
панели может начать слушать позже. Без ожидания юнит падал бы на загрузке.
При недоступной панели — внятное сообщение и exit 1, загрузка не ломается
(юнит только Wants, не Requires).

Отсутствие ordering-цикла доказано: systemd-analyze verify по собранному
дереву юнитов обоих хостов (404 юнита на sapphira, 357 на otreca) —
0 упоминаний «ordering cycle», вывод побайтово совпадает с базовой
ревизией e9bc6f6; сфокусированная проверка 3x-ui-кластера — exit 0.
Живая проверка механики Wants на самой машине (синтетическая пара юнитов,
панель не трогали): старт и restart «контейнерного» юнита → зависимый
выполнился оба раза.

Идемпотентность: повторный POST на свежем конфиге безвреден — config.json
после restartXrayService побайтово не меняется (sha256 совпал), ключи
REALITY те же.

nixos-rebuild switch не выполнялся — решение владельца.
2026-11-16 19:09:16 +03:00
oqyude 17897f7dee 3xui-reconfig: PANEL_BASE/PANEL_TOKEN вычисляются из БД панели в рантайме
Юнит 3xui-reconfig.service не работал НИКОГДА: в Environment стояли
литералы "PANEL_BASE=@base" / "PANEL_TOKEN=@api_token", которые никто не
подставлял — curl уходил на "https://pubray1.zeroq.su@base/panel/api/..."
и падал с "Could not resolve host: base".

- modules/3x-ui/default.nix: новая опция modules."3x-ui".reconfigRunner —
  читает webBasePath и apiToken из таблицы settings БД панели в рантайме
  (podman exec 3xui_app python3 -c …) и отдаёт их скрипту reconfig через
  PANEL_BASE/PANEL_TOKEN; токен не попадает ни в nix store, ни в журнал
  (в журнал — только длина), ни в argv curl (заголовок уходит через
  curl --config -, то есть stdin).
- скрипт reconfig: grep добавлен в runtimeInputs — в минимальном PATH
  юнита его не было, и скрипт падал с "grep: command not found".
- modules/server/default.nix (sapphira): PANEL_URL=https://x.zeroq.su.
  Локальный https://127.0.0.1:2049 не мог работать: панель внутри
  контейнера говорит по HTTP (webCertFile пуст) и отвечает только на
  свой webDomain (x.zeroq.su) — с чужим Host идёт 403 с пустым телом.
- modules/vds/default.nix (otreca): PANEL_URL=https://pubray1.zeroq.su.
- оба юнита: ExecStart → обёртка, After=podman-3xui_app.service,
  комментарии переписаны (почему локальный адрес не работает и что
  PANEL_BASE = webBasePath из БД, а не константа).
- modules/containers/3x-ui.nix: исправлен протухший комментарий про
  несуществующий modules/3x-ui/scripts/reconfig.sh.
- метасостояние: R1.20 в rules/project-rules.md, инвариант 19 и строка
  «Ловушек» в AGENTS.md, находка в tasks/manifest.md (в реестр задач не
  внесена — manifest.json в этой сессии не трогается).

Проверено на sapphira вживую: энд-знд прогон обёртки → {"success":true},
config.json после рестарта побайтово не изменился (ключи REALITY те же),
токен в журнале — 0 совпадений.

nixos-rebuild switch не выполнялся — это решение владельца.
2026-11-16 18:33:15 +03:00
oqyude 0ab45578d1 refactor: реестр адресов флота lib/xlib/net.nix
Один адрес — одно имя. Раньше 192.168.1.20 был написан 41 раз, 100.64.0.0
— семь, а зона CoreDNS и vhost'ы nginx жили в разных файлах и разъезжались
(например, kuma.zeroq.su остался в DNS после отключения uptime-kuma).

Реестр: хосты (LAN/tailscale/public), публичные DNS, сети, общие порты.
Все хардкоды адресов флота переведены на xlib.net.*.

Намеренно не тронуто: 127.0.0.1 и 0.0.0.0 (константы языка, не топология),
сеть 10.66.0.0/24 (у PXE-инфраструктуры своя опционная поверхность) и
home/modules/opencode.nix (рабочая конфигурация агента владельца, её
рефакторинг запрещён ADR-0009).

Поведение не изменилось: config-fingerprint до/после совпадает по всем
шести хостам.
2026-11-15 06:34:12 +03:00
oqyude d6d64d21c3 treefmt + samba dir changed
nixos flake checks / invariant-checks (push) Failing after 7s
test-runner / smoke (push) Successful in 1s
2026-11-07 18:37:42 +03:00
oqyude 066b3acec1 refactor(nix): consolidate fragmented attribute-path writes
Same owner written as '.a = ...; .b = ...;' repeated dotted paths is now one
attrset block. Behaviour-preserving (values, list order and comments kept):

- 3xui-reconfig description/serviceConfig in server/ and vds/ (separate units,
  different PANEL_URL - deliberately not extracted into a shared module)
- authelia after/wants inside the existing config = mkIf wrapper
- gitea-actions-runner settings: runner/metrics/health_check/container
- boot.loader.grub, services.logind, pxe-infra.bridge, pipewire.alsa
- nix.{distributedBuilds,buildMachines}; nix.settings on WSL (mkForce kept)
- build.activation on termux (nix-on-droid freeform)

Also in this commit: lamet.opencodes.zeroq.su upstream 6061 -> 4096
(verified by nix eval of the vhost proxyPass).

nix-instantiate --parse: 12/12 files OK.
2026-10-25 02:10:05 +03:00
oqyude 39e1887d78 docs(modules): уточнить пути и счётчики в комментариях
test-runner / smoke (push) Successful in 1s
nixos flake checks / invariant-checks (push) Canceled after 0s
- xlib: mkXlib из lib/xlib/default.nix (было lib/xlib.nix);
- архив: ../../archive/ от modules/server, 12+3 модуля;
- убраны устаревшие номера строк в ссылке на T16.

Проверки: PASS 3, FAIL 0; граф импортов 120 файлов, 119 ссылок.
2026-10-24 02:17:25 +03:00
oqyude 13e90d06b5 chore(modules): delete 12 unreferenced modules (T41)
None of these are reachable from any import, so removing them cannot change
evaluation. Verified with the import-graph check added in 1b188fb, which is
green before and after (132 -> 120 .nix files, 119 references resolve), and
with an exact import-shaped grep for each path (zero hits outside archive/).

Deleted:
  modules/other/{daw,musnix,virtual,wine}.nix
  modules/other/gaming/{aagl,nix-gaming}.nix
  modules/other/self/fingerprint.nix
      modules/default.nix only imports ./<device-type>, and `other` is not a
      device type (lib/xlib/device.nix:12-41). Four of these also import flake
      inputs that are commented out in flake.nix (:8 fingerprint, :102
      nix-gaming, :103 aagl, :110 musnix), so they could not even evaluate.
  modules/server/requirements.nix
      Orphaned copy of a subset of the pins that modules/server/engipy-backend.nix
      embeds inline at :46-67. The two lists had already diverged: the orphan
      had 14 entries, the live one has 20+ (structlog, pandas, openpyxl,
      python-multipart, python-dotenv were missing from the orphan).
  modules/containers/remnanode.nix
      tmpfiles-only; its three rules duplicate modules that are imported.
  modules/containers/remnawave-examples/{docker-compose-local,docker-compose-prod}.nix
      compose2nix snapshots of the abandoned remnawave stack; the real module
      is preserved in archive/containers/remnawave.nix.
  modules/vds/glances.nix
      Byte-identical to modules/server/glances.nix (md5 f0133606...), whose
      import at modules/vds/default.nix:13 was commented out.

Also drops the now-dangling `# ./glances.nix` line from modules/vds/default.nix.

Deliberately NOT deleted, because "not imported" there means "disabled on
purpose" rather than "abandoned", and git history alone would not recover the
intent:
  modules/vds/netbird.nix            (40 lines, every option `enable = false`)
  modules/wsl/tools/default.nix      (16 lines, a commented-out dev toolchain)
  home/apps/v2rayn.nix               (23 lines, pairs with a package that is
                                      still installed in home/modules/packages.nix:19)

Note: the commented-out flake inputs in flake.nix that existed only for
modules/other/ are now vestigial. Left in place — removing them also rewrites
flake.lock behaviour and needs a nix run, see .agent/tasks/manifest.md T54.

Not pushed.
2026-10-24 01:46:23 +03:00
oqyude 299116495c test(ci): проверка целостности графа импортов вынесена в скрипт
test-runner / smoke (push) Successful in 1s
nixos flake checks / invariant-checks (push) Canceled after 0s
.ci/tests/import-graph.py — проверяет, что каждый .nix ссылается только
на существующие файлы и каталоги. Раньше логика жила инлайн в
checks.sh и не была переиспользуема.

Проверки: PASS 3, FAIL 0.
2026-10-24 01:45:59 +03:00
oqyude af12e286c0 feat(3x-ui): вынести панель в отдельный модуль и подключить на сервере и VDS
test-runner / smoke (push) Successful in 1s
- modules/3x-ui/: новый модуль вместо правок внутри modules/containers/
- modules/server/default.nix и modules/vds/default.nix: подключение модуля
2026-10-23 00:30:01 +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 958247b22c soft coding 2026-10-02 23:05:00 +03:00
oqyude d49fd5a358 big refactoring 2026-10-01 14:16:17 +03:00
oqyude ac561815ed 3x-ui fix 2026-09-24 22:49:52 +03:00
oqyude 72b4bdfbd8 glances fix 2026-09-22 18:31:00 +03:00
oqyude 44b85e1ebc cleaning 2026-09-22 18:05:10 +03:00
oqyude e1d276097d refactoring 2026-08-29 04:05:38 +03:00
oqyude 7f5ea81f37 3x-ui: make module generic via xlib.services.3x-ui options
The 3x-ui container config was hardcoded for vds: it mounted the LE
cert for pubray1.zeroq.su and published host:15380→container:443 for
Xray REALITY. The server imports the same module but for x.zeroq.su
(no REALITY inbound, no cert needed by 3x-ui itself yet).

Add two options so each device picks what it needs:
  - xlib.services.3x-ui.certDomain: domain whose LE cert is mounted
    at /root/cert/{fullchain,key}.pem. null means no cert mount.
  - xlib.services.3x-ui.reality443Forwarding: when true, also publish
    host:15380→container:443 for nginx stream SNI-routed REALITY.

vds sets both. Server sets only certDomain (kept harmless; nginx
still terminates TLS for x.zeroq.su, so the mounted cert is unused
until/unless 3x-ui is reconfigured to terminate TLS itself).
2026-08-28 01:17:59 +03:00
oqyude 11af2c150a vds: drop pubrayx1.zeroq.su from SNI map — Xray now served under pubray1
All Xray REALITY clients already connect to VDS_IP via
pubray1.zeroq.su (or any of its subdomains). Removing the explicit
pubrayx1.zeroq.su → xray rule means the default route catches it.
This way we only have to publish one domain (pubray1.zeroq.su)
in subscriptions instead of two.

Companion change in x-ui.db (separate runbook step): subURI set
to https://pubray1.zeroq.su/subs/ so regenerated subscriptions
emit URLs under pubray1.zeroq.su, not x.zeroq.su.
2026-08-28 00:56:28 +03:00
oqyude 26e53e96bd vds: SNI-route TLS on 443 to Xray (15380→443) and 3x-ui panel (2049)
nginx stream + ssl_preread reads the ClientHello SNI and forwards the
raw TCP stream (no TLS termination) to either:
  - 3x-ui panel on 127.0.0.1:2049 (SNI=pubray1.zeroq.su)
  - Xray on 127.0.0.1:15380 (SNI=pubrayx1.zeroq.su or default)

podman maps host:15380 → container:443 so Xray inside sees the client
on port 443 (matching its REALITY config) even though the host-side
port from podman's perspective is 15380. Host:2049 still maps to
container:2049 — 3x-ui now terminates TLS itself using the Let's
Encrypt cert mounted from /var/lib/acme/pubray1.zeroq.su/.

x-ui.db: webCertFile, webKeyFile and webDomain set so the panel
answers HTTPS on 2049. nginx no longer owns a server block on 443 —
only an ACME-only vhost for cert renewal.

REALITY inbound on container:443 still needs to be created via the
panel UI (the xrayTemplateConfig doesn't have it yet). The host-side
and routing plumbing is ready for it.
2026-08-28 00:36:54 +03:00
oqyude 0c2b45ea6f Revert "vds/nginx: forward real client IP to 3x-ui"
This reverts commit 2cd636b6d4.
2026-08-28 00:12:14 +03:00
oqyude 2cd636b6d4 vds/nginx: forward real client IP to 3x-ui
With podman bridge networking, 3x-ui no longer sees the actual
client IP — it sees the bridge gateway. Without explicit
proxy_set_header directives, subscription URLs, geo-rules, logs
and fail2ban will all treat every request as coming from the same
IP.

Apply Host/X-Real-IP/X-Forwarded-For/X-Forwarded-Proto to all
3x-ui locations so the panel keeps working as if it were on
host network.
2026-08-27 23:28:41 +03:00
oqyude 411c118500 br v4 2026-08-11 22:13:53 +03:00
oqyude cc12ab5bba refactoring 2026-08-10 03:36:19 +03:00
oqyude e66bbef553 3x-ui on server 2026-08-09 23:51:49 +03:00
oqyude 5b3da95fc2 path refactoring 2026-08-09 01:11:23 +03:00
oqyude cedc856a02 server preparing migration 2026-08-08 19:24:14 +03:00
oqyude 63c46c80ef navidrome setup 2026-07-17 12:32:29 +03:00
oqyude 521d922961 nextcloud update 2026-07-16 23:34:06 +03:00
oqyude e5e9dfd1de samba fixup 2026-07-16 17:33:19 +03:00
oqyude 870f36ec9d opencode serve on su 2026-07-10 11:17:45 +03:00
oqyude f2740e87a0 node backup added 2026-07-04 22:54:38 +03:00
oqyude b2b4883627 try to setup gitea 2026-06-10 12:38:23 +03:00
oqyude ebd2e99066 try to fix onlyoffice
now its working in lan)
2026-06-09 23:13:35 +03:00
oqyude b001652162 bentopdf added 2026-05-31 14:26:24 +03:00
oqyude 58d631c0fb something 2026-04-17 20:46:49 +03:00
oqyude 7f1f714e8c glances added 2026-04-11 12:54:52 +03:00
oqyude f5c6d40c89 systemd-mounts...
lix frozen-removed, rovr frozen-removed
2026-04-10 14:07:07 +03:00
oqyude a5a2763f66 new domain 2026-04-10 10:57:20 +03:00
oqyude cf77fa88bf n8n enable 2026-04-01 12:50:28 +03:00
oqyude efcb4232a5 try to setup onlyoffice 2026-03-31 01:47:42 +03:00
oqyude 5909a72654 sops and onlyoffice evolution 2026-03-30 15:50:00 +03:00
oqyude c8c7c68c04 some fix 2026-03-27 17:56:12 +03:00
oqyude 6f278b36e7 disable unused 2026-03-16 18:22:17 +03:00
oqyude f1a81a6408 Init 2026-03-09 10:50:12 +03:00