nix-config/hosts/heather/tuwunel-admin.nix
mikl 6c4f7daf42 heather: tuwunel-admin via nix derivation (fetchurl prebuilt binary)
Replace manually-copied /var/lib/tuwunel-admin/tuwunel-admin binary with a
nix derivation: fetchurl of GitHub release v0.1.0 x86_64-musl static binary
(sha256 verified against checksums.txt). Binary now lives in nix-store,
survives VM recreation. Config stays at /var/lib/tuwunel-admin/config.toml
(outside git, root:root 0644).
2026-07-13 02:49:00 +03:00

68 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.

# heather — tuwunel-admin (web admin UI for tuwunel Matrix homeserver).
#
# https://github.com/knadh/tuwunel-admin (Rust, axum, self-contained static binary).
# Логинится matrix-пользователем на homeserver https://iscg.dev (см. [matrix]
# в config.toml). Чтобы UI мог выполнять admin-команды, залогиненный юзер
# должен быть server admin tuwunel (первый зарегистрированный = admin room member).
#
# Слушает 127.0.0.1:8009 → Caddy admin.iscg.dev терминирует TLS (см. caddy.nix).
# Конфиг: /var/lib/tuwunel-admin/config.toml (вне git, root:root 0644).
#
# Бинарь: публичного docker-образа НЕТ, но есть prebuilt static musl бинарник
# в GitHub releases (v0.1.0, x86_64-unknown-linux-musl). Тащим через fetchurl +
# оборачиваем в nix-деривацию — воспроизводимо, переживает пересоздание VM.
# heather = x86_64-linux, поэтому берём x86_64-musl asset. При появлении aarch64
# хоста — добавить второй fetchurl или собирать из исходников (Cargo.toml + lock).
{ config, pkgs, lib, ... }:
let
tuwunel-admin = pkgs.stdenv.mkDerivation rec {
pname = "tuwunel-admin";
version = "0.1.0";
# Prebuilt static musl binary (x86_64 only). sha256 из checksums.txt релиза.
src = pkgs.fetchurl {
url = "https://github.com/knadh/tuwunel-admin/releases/download/v${version}/tuwunel-admin_${version}_x86_64-unknown-linux-musl.tar.gz";
sha256 = "a22c345f414f9af34d28f7b9166922b736e8774737f67038252d5422f47a2201";
};
# tar.gz с tuwunel-admin (бинарь) + LICENSE + README. Просто копируем бинарь.
dontBuild = true;
dontConfigure = true;
installPhase = ''
runHook preInstall
install -Dm555 tuwunel-admin $out/bin/tuwunel-admin
install -Dm444 LICENSE $out/share/licenses/tuwunel-admin/LICENSE
install -Dm444 README.md $out/share/doc/tuwunel-admin/README.md
runHook postInstall
'';
meta = with lib; {
description = "Web admin UI for tuwunel Matrix homeserver";
homepage = "https://github.com/knadh/tuwunel-admin";
license = licenses.asl20;
mainProgram = "tuwunel-admin";
platforms = [ "x86_64-linux" ];
};
};
in {
systemd.services.tuwunel-admin = {
description = "tuwunel-admin (Matrix admin web UI)";
after = [ "network-online.target" ];
wants = [ "network-online.target" ];
wantedBy = [ "multi-user.target" ];
serviceConfig = {
Type = "simple";
# Бинарь из nix-store (деривация выше), конфиг вне git на хосте.
ExecStart = "${tuwunel-admin}/bin/tuwunel-admin --config /var/lib/tuwunel-admin/config.toml";
WorkingDirectory = "/var/lib/tuwunel-admin";
Restart = "on-failure";
RestartSec = 5;
# Статический бинарь, рут-запуск (биндит 127.0.0.1:8009, читает config.toml).
User = "root";
Environment = [ "HOME=/var/lib/tuwunel-admin" ];
};
};
}