From 17b5921d8da9756d0f0ee7bd2776722e883eeb06 Mon Sep 17 00:00:00 2001 From: Christoffer Martinsson Date: Sat, 25 Oct 2025 14:45:26 +0200 Subject: [PATCH] Fix dashboard -V to show cm-dashboard package hash not system hash Make dashboard -V show the same hash as the agent by extracting the hash from the dashboard binary's nix store path instead of the system configuration path. Now both will show identical hashes since they're from the same cm-dashboard package. --- dashboard/src/main.rs | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/dashboard/src/main.rs b/dashboard/src/main.rs index ec9de87..c055e10 100644 --- a/dashboard/src/main.rs +++ b/dashboard/src/main.rs @@ -11,19 +11,14 @@ mod ui; use app::Dashboard; -/// Get version showing current system config hash for easy rebuild verification +/// Get version showing cm-dashboard package hash for easy rebuild verification fn get_version() -> &'static str { - use std::process::Command; + // Get the path of the current executable + let exe_path = std::env::current_exe().expect("Failed to get executable path"); + let exe_str = exe_path.to_string_lossy(); - // 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"); + // Extract Nix store hash from path like /nix/store/HASH-cm-dashboard-0.1.0/bin/cm-dashboard + let hash_part = exe_str.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");