test-runner / smoke (push) Successful in 0s
В v2 без явного выбора CLI берёт модель из реестра сам (opencode/minimax-m3.1-flash-free) и передаёт её явно — она перебивает модель агента, заданную oh-my-opencode-slim. Проверено по сообщению в БД: без фикса запрос шёл на бесплатной модели. Рабочая машина обходится за счёт «помни последний использованный» в TUI, серверная БД пустая.
155 lines
7.3 KiB
Nix
155 lines
7.3 KiB
Nix
{
|
||
config,
|
||
lib,
|
||
pkgs,
|
||
xlib,
|
||
...
|
||
}:
|
||
let
|
||
panel = "${xlib.dirs.services-nodes-folder}/${xlib.device.hostname}/3x-ui";
|
||
# Domain whose Let's Encrypt cert (at /var/lib/acme/<domain>/) gets mounted
|
||
# read-only into the 3x-ui container so the panel can terminate TLS itself.
|
||
# Null when 3x-ui serves plain HTTP and TLS is terminated by an upstream
|
||
# nginx.
|
||
certDomain = config.host."3x-ui".certDomain;
|
||
certMounts =
|
||
if certDomain == null then
|
||
[ ]
|
||
else
|
||
# LE cert mounted read-only so 3x-ui can terminate TLS itself.
|
||
# The 3x-ui settings table must point webCertFile / webKeyFile at
|
||
# /root/cert/fullchain.pem and /root/cert/key.pem.
|
||
map (f: "/var/lib/acme/${certDomain}/${f}:/root/cert/${f}:ro") [
|
||
"fullchain.pem"
|
||
"key.pem"
|
||
];
|
||
basePorts = [
|
||
# Local-only upstreams for the 3x-ui panel and subscription endpoint.
|
||
# The direct Xray inbound remains publicly reachable on 8443.
|
||
"127.0.0.1:2049:2049/tcp"
|
||
"127.0.0.1:2096:2096/tcp"
|
||
"0.0.0.0:8443:8443/tcp"
|
||
];
|
||
# VDS-only: nginx stream forwards host:443 → 127.0.0.1:15380 →
|
||
# container:443, so Xray sees its REALITY inbound on port 443.
|
||
realityPorts = lib.optional config.host."3x-ui".reality443Forwarding "127.0.0.1:15380:443/tcp";
|
||
in
|
||
{
|
||
# `host."3x-ui"` options are declared in modules/options.nix: they are set
|
||
# by modules/server and modules/vds, so this module cannot be the only place
|
||
# that knows they exist.
|
||
config = {
|
||
virtualisation = {
|
||
podman = {
|
||
enable = true;
|
||
autoPrune = {
|
||
enable = true;
|
||
flags = [ "--all" ];
|
||
};
|
||
dockerCompat = true;
|
||
};
|
||
oci-containers = {
|
||
backend = "podman";
|
||
containers."3xui_app" = {
|
||
# Тег образа ЗАПИНЕН (2026-10-20, R1.16). До этого был `:latest`,
|
||
# и это был вектор тихого дрейфа: 2026-10-14 вышел 3x-ui v3.10.x с
|
||
# ядром Xray **26.10.10** (26.7.x → 26.10.x мимо рук), а ядро ≥ 26.9.8
|
||
# требует в REALITY ClientHello key share `X25519MLKEM768` (см. R1.16).
|
||
# Итог: все клиентские ссылки перестали работать молча — TCP есть,
|
||
# TLS «есть», трафика нет. Пришлось чинить fingerprint и minClientVer
|
||
# на живых хостах. Панель обновлять — только вместе с записью в
|
||
# `.agent/decisions/` или `.agent/decisions/notes/` (R1.5).
|
||
image = "ghcr.io/mhsanaei/3x-ui:v3.10.2";
|
||
environment = {
|
||
"XRAY_VMESS_AEAD_FORCED" = "false";
|
||
"XUI_ENABLE_FAIL2BAN" = "true";
|
||
"TZ" = "Europe/Moscow";
|
||
};
|
||
volumes = [
|
||
"${panel}/cert/:/root/cert:rw"
|
||
"${panel}/db/:/etc/x-ui:rw"
|
||
]
|
||
++ certMounts;
|
||
log-driver = "journald";
|
||
# Adding a new inbound through the 3x-ui panel on a port outside
|
||
# the 14380-15379 range requires extending basePorts and rebuilding.
|
||
ports = basePorts ++ realityPorts;
|
||
};
|
||
};
|
||
};
|
||
|
||
systemd = {
|
||
services = {
|
||
"podman-3xui_app" = {
|
||
serviceConfig = xlib.helpers.mkStorageGuard xlib // {
|
||
Restart = lib.mkOverride 90 "always";
|
||
};
|
||
partOf = [ "podman-compose-3x-ui-root.target" ];
|
||
wantedBy = [ "podman-compose-3x-ui-root.target" ];
|
||
};
|
||
# Auto-update was removed intentionally: the `podman pull` path on the
|
||
# auto-update timer caused the declarative Nix state to diverge from the
|
||
# runtime state in 2026-10-04 (see
|
||
# .agent/decisions/notes/3x-ui-xray-26.9.md). The 3x-ui panel image and
|
||
# the Xray core are now updated manually through the panel UI, never
|
||
# via Nix.
|
||
|
||
# ───────────────────────────────────────────────────────────────────
|
||
# 3xui-reconfig.service (R1.18, 2026-10-21)
|
||
#
|
||
# Лечит «панель показывает новое, сервер крутит старое». Правка REALITY
|
||
# в UI меняет `inbounds.stream_settings` в БД, но **не** переписывает
|
||
# `/app/bin/config.json` на диске и **не** рестартит xray с новым
|
||
# файлом. UI-«restart» — это мягкий сигнал, xray читает файл с диска
|
||
# и видит старые ключи -> ссылки на новые ключи тихо отбрасываются.
|
||
#
|
||
# Юнит oneshot, вручную: `sudo systemctl start 3xui-reconfig.service`.
|
||
# Скрипт делает `POST /panel/api/server/restartXrayService` — это тот
|
||
# эндпоинт, который панель пишет конфиг из БД и перезапускает xray.
|
||
# Все параметры — из `Environment` (URL/BASE прописаны сразу,
|
||
# `PANEL_TOKEN` — через `@api_token` владельца, как `mkUserSecret`).
|
||
"3xui-reconfig" = {
|
||
description = "Перегенерировать config.json 3x-ui из БД и рестартнуть xray (R1.18). Использовать после любой правки инбаунда в UI панели.";
|
||
serviceConfig = {
|
||
Type = "oneshot";
|
||
# Значения подставляются препроцессором Nix-конфига владельца
|
||
# (точно так же, как `mkUserSecret` в modules/users.nix). Прямое
|
||
# упоминание в ExecStart даёт детерминированный путь подстановки
|
||
# независимо от того, что умеет конкретная редакция /etc.
|
||
ExecStart = "/bin/sh -c 'PANEL_URL=https://127.0.0.1:2049 PANEL_BASE=\"@base\" PANEL_TOKEN=\"@api_token\" /modules/3x-ui/scripts/reconfig.sh'";
|
||
};
|
||
};
|
||
};
|
||
# Starts/stops together with all 3x-ui compose resources.
|
||
targets."podman-compose-3x-ui-root" = {
|
||
unitConfig.Description = "Root target generated by compose2nix.";
|
||
wantedBy = [ "multi-user.target" ];
|
||
};
|
||
tmpfiles.rules = [
|
||
(xlib.helpers.mkTmpfile "d" xlib.dirs.services-mnt-folder "0755" "root" "root")
|
||
(xlib.helpers.mkTmpfile "d" xlib.dirs.services-nodes-folder "0755" "root" "root")
|
||
(xlib.helpers.mkTmpfile "d" "${xlib.dirs.services-nodes-folder}/${xlib.device.hostname}" "0755"
|
||
"root"
|
||
"root"
|
||
)
|
||
(xlib.helpers.mkTmpfile "d" panel "0755" "root" "root")
|
||
(xlib.helpers.mkTmpfile "d" "${panel}/db" "0755" "root" "root")
|
||
(xlib.helpers.mkTmpfile "d" "${panel}/cert" "0755" "root" "root")
|
||
# Relabel panel dir for SELinux so containers can access it.
|
||
(xlib.helpers.mkTmpfile "Z" panel "0755" "root" "root")
|
||
];
|
||
};
|
||
|
||
# Enable container name DNS for all Podman networks.
|
||
networking.firewall = {
|
||
interfaces =
|
||
let
|
||
matchAll = if !config.networking.nftables.enable then "podman+" else "podman*";
|
||
in
|
||
{
|
||
"${matchAll}".allowedUDPPorts = [ 53 ];
|
||
};
|
||
};
|
||
};
|
||
}
|