From 3d187c922075e944dc20ef786b422f9dac71d287 Mon Sep 17 00:00:00 2001 From: Christoffer Martinsson Date: Sat, 25 Oct 2025 14:31:20 +0200 Subject: [PATCH] Make dashboard -V show actual config hash for rebuild verification Replace hardcoded version with first 8 characters of current system's nix store hash. This makes it easy to verify when rebuilds complete as the hash changes with each deployment. No fallback - fails hard if config hash cannot be determined. --- dashboard/src/main.rs | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/dashboard/src/main.rs b/dashboard/src/main.rs index 2528737..ec9de87 100644 --- a/dashboard/src/main.rs +++ b/dashboard/src/main.rs @@ -11,10 +11,31 @@ mod ui; use app::Dashboard; +/// Get version showing current system config hash for easy rebuild verification +fn get_version() -> &'static str { + use std::process::Command; + + // Get config hash from current system + let output = Command::new("readlink").arg("/run/current-system").output().expect("Failed to run readlink"); + assert!(output.status.success(), "readlink command failed"); + + let store_path = String::from_utf8_lossy(&output.stdout); + let store_path = store_path.trim(); + + // Extract hash from nix store path + let hash_part = store_path.strip_prefix("/nix/store/").expect("Not a nix store path"); + let hash = hash_part.split('-').next().expect("Invalid nix store path format"); + assert!(hash.len() >= 8, "Hash too short"); + + // Return first 8 characters of nix store hash + let short_hash = hash[..8].to_string(); + Box::leak(short_hash.into_boxed_str()) +} + #[derive(Parser)] #[command(name = "cm-dashboard")] #[command(about = "CM Dashboard TUI with individual metric consumption")] -#[command(version)] +#[command(version = get_version())] struct Cli { /// Increase logging verbosity (-v, -vv) #[arg(short, long, action = clap::ArgAction::Count)]