Add configuration hash display to system panel

- Collect config hash from cloned nixos-config git repository
- Display "Config: xxxxx" after "Build: xxxxx" in NixOS section
- Uses /var/lib/cm-dashboard/nixos-config directory
- Shows actual configuration hash vs nixpkgs build hash
This commit is contained in:
2025-10-25 01:30:46 +02:00
parent 996a199050
commit 2d3844b5dd
2 changed files with 60 additions and 0 deletions

View File

@@ -14,6 +14,7 @@ use crate::ui::theme::{StatusIcons, Typography};
pub struct SystemWidget {
// NixOS information
nixos_build: Option<String>,
config_hash: Option<String>,
active_users: Option<String>,
agent_hash: Option<String>,
@@ -64,6 +65,7 @@ impl SystemWidget {
pub fn new() -> Self {
Self {
nixos_build: None,
config_hash: None,
active_users: None,
agent_hash: None,
cpu_load_1min: None,
@@ -322,6 +324,11 @@ impl Widget for SystemWidget {
self.nixos_build = Some(build.clone());
}
}
"system_config_hash" => {
if let MetricValue::String(hash) = &metric.value {
self.config_hash = Some(hash.clone());
}
}
"system_active_users" => {
if let MetricValue::String(users) = &metric.value {
self.active_users = Some(users.clone());
@@ -418,6 +425,11 @@ impl SystemWidget {
Span::styled(format!("Build: {}", build_text), Typography::secondary())
]));
let config_text = self.config_hash.as_deref().unwrap_or("unknown");
lines.push(Line::from(vec![
Span::styled(format!("Config: {}", config_text), Typography::secondary())
]));
let agent_hash_text = self.agent_hash.as_deref().unwrap_or("unknown");
let short_hash = if agent_hash_text.len() > 8 && agent_hash_text != "unknown" {
&agent_hash_text[..8]