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)]