feat(infra): full Nix migration — all 6 services + CI/CD
- flake.nix: 6 derivations (hub, scraper, tools-gateway, tools-workers, tools-frontend, llm-api) - Fetch submodule source via builtins.fetchGit with pinned revs - Fix cargo HOME/TMPDIR for Nix sandbox permission issues - Fix llm-api: CMake/Clang deps for llama.cpp-sys2 bindgen - Add LIBCLANG_PATH, LD_LIBRARY_PATH for Rust bindgen builds - Systemd units: tools-gateway (3501), tools-frontend (3500), tools-workers, llm-api (8080) - tools.target for grouped management - Env configs: /etc/tools/env, /etc/llm-api/env - GitHub Actions: nix-build.yml — matrix build + nix copy + deploy - Update Traefik apps.yaml: tools/host.docker.internal:3500, llm-api/host.docker.internal:8080 - iptables: allow Docker→host on 3099, 4091, 3500, 3501, 8080 - Add scripts/nix-deploy.sh for CI/CD deploy step
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env bash
|
||||
# ── Nix Deploy — VPS-side script ──
|
||||
# Runs after `nix copy --to ssh://VPS ./result` from CI
|
||||
# Usage: sudo ./deploy.sh <service-name>
|
||||
set -euo pipefail
|
||||
|
||||
SERVICE="$1"
|
||||
PROFILE="/nix/var/nix/profiles/${SERVICE}"
|
||||
|
||||
# Find the latest store path for this service
|
||||
LATEST=$(ls -1d /nix/store/*-"${SERVICE}"-* 2>/dev/null | tail -1)
|
||||
if [ -z "$LATEST" ]; then
|
||||
echo "ERROR: No store path found for ${SERVICE}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Update profile
|
||||
/nix/var/nix/profiles/default/bin/nix-env --profile "$PROFILE" --set "$LATEST"
|
||||
|
||||
# Restart service
|
||||
systemctl daemon-reload
|
||||
systemctl enable --now "${SERVICE}" 2>/dev/null || systemctl restart "${SERVICE}"
|
||||
|
||||
echo "Deployed ${SERVICE}: ${LATEST}"
|
||||
systemctl is-active "${SERVICE}"
|
||||
|
||||
# Collect garbage (safe: only removes unreachable paths)
|
||||
# nix-collect-garbage -d 2>/dev/null || true
|
||||
Reference in New Issue
Block a user