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.
This commit is contained in:
oqyude committed 2026-10-25 02:10:05 +03:00
1 parent 69691f96d1
commit 066b3acec1
11 files changed
+83 -54

No files matched your search

+5 -3
View File
@@ -25,7 +25,9 @@
device = "/dev/sda1";
fsType = "ext4";
};
boot.loader.grub.enable = true;
boot.loader.grub.devices = [ "/dev/sda" ];
boot.loader.grub.configurationLimit = 50;
boot.loader.grub = {
enable = true;
devices = [ "/dev/sda" ];
configurationLimit = 50;
};
}
+8 -4
View File
@@ -67,8 +67,10 @@
# headless-сервер для engipy (sapphira проксирует /api/* на него).
# Если пользователь берёт ноутбук в руки — пусть остаётся правило
# по умолчанию (suspend); но для unattended-режима нужно ignore.
services.logind.lidSwitch = "ignore";
services.logind.lidSwitchDocked = "ignore";
services.logind = {
lidSwitch = "ignore";
lidSwitchDocked = "ignore";
};
system.stateVersion = "26.05";
@@ -87,8 +89,10 @@
# `modules/pxe-infra/` for the implementation.
pxe-infra = {
enable = true;
bridge.address = "10.66.0.1";
bridge.prefixLength = 24;
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
+4 -2
View File
@@ -58,8 +58,10 @@
services.pipewire = {
enable = lib.mkDefault true;
systemWide = true;
alsa.enable = false;
alsa.support32Bit = true;
alsa = {
enable = false;
support32Bit = true;
};
pulse.enable = true;
jack.enable = true;
extraConfig.pipewire = {
+4 -2
View File
@@ -192,8 +192,10 @@ in
# creates to deploy credentials; depending on its name avoids the
# "race between tmpfiles-setup and the sops materialiser" that the
# previous tmpfiles-symlink design implicitly relied on.
systemd.services.authelia.after = [ "sops-nix.service" ];
systemd.services.authelia.wants = [ "sops-nix.service" ];
systemd.services.authelia = {
after = [ "sops-nix.service" ];
wants = [ "sops-nix.service" ];
};
# sops wiring. Guarded by builtins.pathExists so the flake still
# evaluates when ./secrets/authelia.yaml hasn't been created yet —
+4 -2
View File
@@ -102,8 +102,10 @@ in
# populated. (The build-machine list still lands in /etc/nix/machines
# but nix-daemon reads `builders`, not /etc/nix/machines, when
# distributedBuilds is false.)
nix.distributedBuilds = true;
nix.buildMachines = map forNix config.host.builder.clients;
nix = {
distributedBuilds = true;
buildMachines = map forNix config.host.builder.clients;
};
# Nix 2.34's daemon does not act on `@/etc/nix/machines` (the file
# format NixOS's nix-remote-build writes to): the `builders` config
# key is parsed for display but `external-builders` stays empty and
+9 -6
View File
@@ -76,16 +76,19 @@
#
# В otreca аналогичный юнит определён в `modules/vds/default.nix` с
# другим `PANEL_URL`/`apiToken`.
systemd.services."3xui-reconfig".serviceConfig.Type = "oneshot";
systemd.services."3xui-reconfig".serviceConfig.ExecStart =
lib.getExe config.modules."3x-ui".reconfig;
systemd.services."3xui-reconfig".serviceConfig.Environment = [
systemd.services."3xui-reconfig" = {
description =
"Перегенерировать config.json 3x-ui из БД и рестартнуть xray (R1.18).";
serviceConfig = {
Type = "oneshot";
ExecStart = lib.getExe config.modules."3x-ui".reconfig;
Environment = [
"PANEL_URL=https://127.0.0.1:2049"
"PANEL_BASE=@base"
"PANEL_TOKEN=@api_token"
];
systemd.services."3xui-reconfig".description =
"Перегенерировать config.json 3x-ui из БД и рестартнуть xray (R1.18).";
};
};
# engipy webapp — split architecture:
# - sapphira : host.engipy-frontend.enable → nginx vhost (engipy.zeroq.su)
# с /api/* на rydiwo:8000 и / → /var/lib/engipy/web
+22 -14
View File
@@ -56,24 +56,30 @@ in
labels = [ "native:host" ]; # only host-executor; no docker required
settings = {
runner.capacity = 1; # sequential on 2-core host
runner.timeout = "2h";
runner.workdir_cleanup_age = "48h";
runner.idle_cleanup_interval = "20m";
runner = {
capacity = 1; # sequential on 2-core host
timeout = "2h";
workdir_cleanup_age = "48h";
idle_cleanup_interval = "20m";
};
# Localhost-only. Co-resident processes can still reach it; scrape
# via ssh+localhost if ever needed.
metrics.enabled = true;
metrics.addr = "127.0.0.1:9101";
metrics = {
enabled = true;
addr = "127.0.0.1:9101";
};
# Workspace in /tmp is tmpfs (size = ~50% of RAM ≈ 2.8 GiB
# on sapphira), so the default 4 GB threshold would always trip.
# 256 MiB is plenty for smoke-test workflows and still trips
# meaningfully if tmpfs truly fills.
health_check.enabled = true;
health_check.min_free_disk_space_mb = 256;
health_check.interval = "5m";
health_check.timeout = "30s";
health_check = {
enabled = true;
min_free_disk_space_mb = 256;
interval = "5m";
timeout = "30s";
};
# Workspace in /tmp (tmpfs). Same approach as GH Actions runners —
# ephemeral, always writable by the runner's UID. Avoids racing with
@@ -85,10 +91,12 @@ in
host.workdir_parent = "/tmp/gitea-runner-work";
# Defence in depth even though host labels never pull images.
container.docker_host = "";
container.network = "";
container.privileged = false;
container.options = "";
container = {
docker_host = "";
network = "";
privileged = false;
options = "";
};
};
# The PATH of every host-mode job. One shared list (lib/ci-tools.nix) with
+1 -1
View File
@@ -471,7 +471,7 @@ in
forceSSL = true;
enableACME = true;
locations."/" = {
proxyPass = "http://100.106.21.39:6061";
proxyPass = "http://100.106.21.39:4096";
proxyWebsockets = true;
};
};
+5 -3
View File
@@ -39,7 +39,8 @@ in
'';
# Generate the host key on first activation (idempotent).
build.activation.sshd = ''
build.activation = {
sshd = ''
if [[ ! -d "${sshdDir}" ]]; then
$DRY_RUN_CMD rm -rf "${sshdTmpDir}"
$DRY_RUN_CMD mkdir -p "${sshdTmpDir}"
@@ -56,7 +57,7 @@ in
# ~/.local/state/nix/profiles/channels (dangling until it exists), which
# home-manager cannot link into. mkdir -p refuses to traverse a dangling
# symlink, so create the real target dir instead.
build.activation.nixdefexpr = ''
nixdefexpr = ''
$DRY_RUN_CMD mkdir -p "${config.user.home}/.local/state/nix/profiles/channels/nixpkgs"
$DRY_RUN_CMD touch "${config.user.home}/.local/state/nix/profiles/channels/nixpkgs/.keep"
'';
@@ -67,13 +68,14 @@ in
# NOTE: tailscaled was removed — nixpkgs' linux build cannot run inside
# proot (SELinux blocks netlink; needs GOOS=android or root). Re-add only
# if that gets solved.
build.activation.services = ''
services = ''
$DRY_RUN_CMD rm -rf ${serviceDir}/tailscaled
$DRY_RUN_CMD mkdir -p ${serviceDir}/sshd/log
$DRY_RUN_CMD ln -sfn ${sshdRun}/bin/sshd-run ${serviceDir}/sshd/run
$DRY_RUN_CMD ln -sfn ${svLogRun}/bin/sv-log-run ${serviceDir}/sshd/log/run
$DRY_RUN_CMD ln -sfn ${serviceDir} /etc/service
'';
};
environment.packages = [
pkgs.runit
+9 -6
View File
@@ -37,16 +37,19 @@
# 3xui-reconfig.service` — без хоста. Это намеренно: владелец стартует
# их по очереди; один из них адресует локальную панель, другой — удалённую,
# и оба лечат одно и то же «сервер крутит старое».)
systemd.services."3xui-reconfig".serviceConfig.Type = "oneshot";
systemd.services."3xui-reconfig".serviceConfig.ExecStart =
lib.getExe config.modules."3x-ui".reconfig;
systemd.services."3xui-reconfig".serviceConfig.Environment = [
systemd.services."3xui-reconfig" = {
description =
"Перегенерировать config.json 3x-ui из БД и рестартнуть xray (R1.18) — вариант для Otreca (публичный домен).";
serviceConfig = {
Type = "oneshot";
ExecStart = lib.getExe config.modules."3x-ui".reconfig;
Environment = [
"PANEL_URL=https://pubray1.zeroq.su"
"PANEL_BASE=@base"
"PANEL_TOKEN=@api_token"
];
systemd.services."3xui-reconfig".description =
"Перегенерировать config.json 3x-ui из БД и рестартнуть xray (R1.18) — вариант для Otreca (публичный домен).";
};
};
systemd.tmpfiles.rules = [
(xlib.helpers.mkTmpfile "d" "/mnt" "0755" "root" "root")
+12 -11
View File
@@ -26,24 +26,25 @@
# actually deliver. `nixos-test` is dropped for the same reason — it
# wants kvm anyway.
#
# `mkForce` because the NixOS module base-config sets a non-empty
# default; without force the lists would concatenate and the WSL would
# *still* advertise kvm.
nix.settings.system-features = lib.mkForce [
"benchmark"
"big-parallel"
];
# Builds arrive over SSH as the user `oqyude` (see
# modules/server/builder.nix). On the default trusted-users = ["root"]
# only root can call nix-store, so the SSH session would fail to realise
# any .drv. Adding the SSH user to trusted-users lets the remote nix-build
# driver drive nix-store on the builder side. `mkForce` for the same
# concatenation reason as above.
nix.settings.trusted-users = lib.mkForce [
# driver drive nix-store on the builder side.
#
# `mkForce` on both lists because the NixOS module base-config sets a
# non-empty default; without force the lists would concatenate, and the
# WSL would *still* advertise kvm.
nix.settings = {
system-features = lib.mkForce [
"benchmark"
"big-parallel"
];
trusted-users = lib.mkForce [
"root"
"oqyude"
];
};
# The local daemon already parallelises across all 24 logical cores
# (max-jobs = 24 is what we measured). When acting as a builder, we