- health-check.py: model health watchdog (silent when healthy, alert on 2+ consecutive failures) — catches stale-key/model-breakage like 2026-08-04 - sync-key.py: systemd ExecStartPre syncs 9router key from BWS to disk, prevents silent 401s after key rotation - run_server.py: CONFIG__ANALYTICS_FOLDER + /api/metrics (Prometheus) + /api/analytics (JSON) + /api/v1/notify_review (Discord webhook) - trivial_merge.py: trivial-PR fast-path (docs/deps/tiny diffs) approve+merge - auto_merge_bot.py: Discord notifications on merge, trivial integration - flake.nix: ship pr-agent-sync-key + pr-agent-health-check binaries
73 lines
2.5 KiB
Nix
73 lines
2.5 KiB
Nix
{
|
|
description = "PR-Agent Server — GitHub App webhook server (Nix build)";
|
|
|
|
inputs = {
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
|
flake-utils.url = "github:numtide/flake-utils";
|
|
};
|
|
|
|
outputs = { self, nixpkgs, flake-utils }:
|
|
flake-utils.lib.eachSystem [ "x86_64-linux" ] (system:
|
|
let
|
|
pkgs = import nixpkgs { inherit system; };
|
|
python = pkgs.python312;
|
|
in {
|
|
packages.default = pkgs.stdenv.mkDerivation {
|
|
pname = "pr-agent-server";
|
|
version = "1.0.0";
|
|
src = ./.;
|
|
|
|
nativeBuildInputs = [ python pkgs.git pkgs.cacert ];
|
|
buildInputs = [ pkgs.stdenv.cc.cc.lib ];
|
|
|
|
buildPhase = ''
|
|
export HOME=$TMPDIR/home
|
|
mkdir -p "$HOME"
|
|
export SSL_CERT_FILE=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt
|
|
export NODE_EXTRA_CA_CERTS=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt
|
|
|
|
echo "=== Creating venv ==="
|
|
python -m venv $out/venv
|
|
$out/venv/bin/pip install --no-cache-dir --upgrade pip 2>&1
|
|
|
|
echo "=== pip install deps ==="
|
|
$out/venv/bin/pip install --no-cache-dir \
|
|
pr-agent fastapi uvicorn httpx pyjwt 2>&1
|
|
echo "=== Build complete ==="
|
|
'';
|
|
|
|
installPhase = ''
|
|
mkdir -p $out/bin $out/lib/pr-agent-server
|
|
cp run_server.py $out/lib/pr-agent-server/
|
|
cp sync-key.py $out/lib/pr-agent-server/
|
|
cp health-check.py $out/lib/pr-agent-server/
|
|
cp trivial_merge.py $out/lib/pr-agent-server/
|
|
cp auto_merge_bot.py $out/lib/pr-agent-server/
|
|
|
|
cat > $out/bin/pr-agent-server << WRAPPER
|
|
#!${pkgs.runtimeShell}
|
|
export PATH=${pkgs.git}/bin:\$PATH
|
|
export LD_LIBRARY_PATH=${pkgs.stdenv.cc.cc.lib}/lib:\$LD_LIBRARY_PATH
|
|
cd $out/lib/pr-agent-server
|
|
exec $out/venv/bin/python run_server.py
|
|
WRAPPER
|
|
chmod +x $out/bin/pr-agent-server
|
|
|
|
cat > $out/bin/pr-agent-sync-key << WRAPPER2
|
|
#!${pkgs.runtimeShell}
|
|
export LD_LIBRARY_PATH=${pkgs.stdenv.cc.cc.lib}/lib:\$LD_LIBRARY_PATH
|
|
exec $out/venv/bin/python $out/lib/pr-agent-server/sync-key.py
|
|
WRAPPER2
|
|
chmod +x $out/bin/pr-agent-sync-key
|
|
|
|
cat > $out/bin/pr-agent-health-check << WRAPPER3
|
|
#!${pkgs.runtimeShell}
|
|
export LD_LIBRARY_PATH=${pkgs.stdenv.cc.cc.lib}/lib:\$LD_LIBRARY_PATH
|
|
exec $out/venv/bin/python $out/lib/pr-agent-server/health-check.py
|
|
WRAPPER3
|
|
chmod +x $out/bin/pr-agent-health-check
|
|
'';
|
|
};
|
|
});
|
|
}
|