From 983e081f16825adea835cbc99841a23588fd5ae0 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Thu, 22 Oct 2026 22:26:36 -0400 Subject: [PATCH] Add scripts to check the status of nix_builder. --- nix/configuration/roles/hydra/default.nix | 15 +++++++++++++++ .../roles/hydra/files/cache_status_full.bash | 9 +++++++++ .../roles/hydra/files/cache_status_latest.bash | 9 +++++++++ 3 files changed, 33 insertions(+) create mode 100644 nix/configuration/roles/hydra/files/cache_status_full.bash create mode 100644 nix/configuration/roles/hydra/files/cache_status_latest.bash diff --git a/nix/configuration/roles/hydra/default.nix b/nix/configuration/roles/hydra/default.nix index 13b7d15..9d3ef44 100644 --- a/nix/configuration/roles/hydra/default.nix +++ b/nix/configuration/roles/hydra/default.nix @@ -10,6 +10,19 @@ ... }: +let + patchScriptBin = + filename: contents: + ((pkgs.writeScriptBin filename contents).overrideAttrs (old: { + buildCommand = "${old.buildCommand}\n patchShebangs $out"; + })); + cache_status_full = ( + patchScriptBin "cache_status_full" (builtins.readFile ./files/cache_status_full.bash) + ); + cache_status_latest = ( + patchScriptBin "cache_status_latest" (builtins.readFile ./files/cache_status_latest.bash) + ); +in { imports = [ ]; @@ -26,6 +39,8 @@ environment.systemPackages = with pkgs; [ nix_builder.packages.x86_64-linux.default sqlite # For manually inspecting the database. + cache_status_full + cache_status_latest ]; environment.persistence."/persist" = lib.mkIf (config.me.mountPersistence) { diff --git a/nix/configuration/roles/hydra/files/cache_status_full.bash b/nix/configuration/roles/hydra/files/cache_status_full.bash new file mode 100644 index 0000000..819858b --- /dev/null +++ b/nix/configuration/roles/hydra/files/cache_status_full.bash @@ -0,0 +1,9 @@ +#!/usr/bin/env bash +# +# Shows the status of all builds in nix_builder. +set -euo pipefail +IFS=$'\n\t' +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +doas -u nixworker env NIX_REMOTE='local?root=/.disk/root' RUST_BACKTRACE=1 RUST_LOG=nix_builder=DEBUG sqlite3 -header -box /home/nixworker/persist/nix_builder/nix_builder.sqlite "select * from (select build.id, datetime(build.start_time, 'unixepoch') as start_time, datetime(build.end_time, 'unixepoch') as end_time, build.status, build.target, flake_inputs.rev from build left outer join flake_inputs on build.id=flake_inputs.build_id and flake_inputs.input_name='nixpkgs' order by build.id desc +limit 45) order by id asc;" diff --git a/nix/configuration/roles/hydra/files/cache_status_latest.bash b/nix/configuration/roles/hydra/files/cache_status_latest.bash new file mode 100644 index 0000000..819858b --- /dev/null +++ b/nix/configuration/roles/hydra/files/cache_status_latest.bash @@ -0,0 +1,9 @@ +#!/usr/bin/env bash +# +# Shows the status of all builds in nix_builder. +set -euo pipefail +IFS=$'\n\t' +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +doas -u nixworker env NIX_REMOTE='local?root=/.disk/root' RUST_BACKTRACE=1 RUST_LOG=nix_builder=DEBUG sqlite3 -header -box /home/nixworker/persist/nix_builder/nix_builder.sqlite "select * from (select build.id, datetime(build.start_time, 'unixepoch') as start_time, datetime(build.end_time, 'unixepoch') as end_time, build.status, build.target, flake_inputs.rev from build left outer join flake_inputs on build.id=flake_inputs.build_id and flake_inputs.input_name='nixpkgs' order by build.id desc +limit 45) order by id asc;"