From 864cafd61f97aec8301e1a4c12ebc72f5a25da3f Mon Sep 17 00:00:00 2001 From: Christoffer Martinsson Date: Fri, 24 Oct 2025 18:52:51 +0200 Subject: [PATCH] Fix nixos-rebuild agent execution: run as cm user Change sudo command to use '-u cm' to run nixos-rebuild as the cm user instead of root, allowing access to /home/cm/nixosbox directory. --- agent/src/agent.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/agent/src/agent.rs b/agent/src/agent.rs index b5d957a..c061d88 100644 --- a/agent/src/agent.rs +++ b/agent/src/agent.rs @@ -293,8 +293,10 @@ impl Agent { info!("Maintenance mode enabled"); } - // Change to nixos directory and execute rebuild + // Change to nixos directory and execute rebuild as cm user let output = tokio::process::Command::new("sudo") + .arg("-u") + .arg("cm") .arg("nixos-rebuild") .arg("switch") .current_dir(nixos_path)