From d298a3c3c7e30dbcced5646df87e5df096437351 Mon Sep 17 00:00:00 2001 From: elwrcl Date: Sat, 3 Oct 2026 03:46:08 +0300 Subject: [PATCH] fix: __check-config runs quietly without a home directory --- nix/checks.ulu.nix | 5 +++++ src/main.rs | 11 +++++++++++ 2 files changed, 16 insertions(+) diff --git a/nix/checks.ulu.nix b/nix/checks.ulu.nix index e0f6f72..b657943 100644 --- a/nix/checks.ulu.nix +++ b/nix/checks.ulu.nix @@ -67,6 +67,11 @@ pkgs.runCommand "valw-home-module" { } '' grep -qx 'timeout_secs = 3' ${set.xdg.configFile."valw/config.toml".source} grep -qx 'volume = 0.4' ${set.xdg.configFile."valw/config.toml".source} + # Quiet, and no home directory needed. + HOME=/nonexistent ${valw}/bin/valw __check-config ${ + set.xdg.configFile."valw/config.toml".source + } 2> err + test ! -s err touch $out ''; diff --git a/src/main.rs b/src/main.rs index 411c741..3ea0c88 100644 --- a/src/main.rs +++ b/src/main.rs @@ -160,6 +160,16 @@ enum Mode { fn main() -> ExitCode { let cli = Cli::parse(); + // home-manager runs this in the build sandbox: no home, no logs, quiet. + if let Command::CheckConfig { file } = &cli.command { + return match config::check(file) { + Ok(()) => ExitCode::SUCCESS, + Err(e) => { + eprint!("{}", error::render(&e, None)); + ExitCode::FAILURE + } + }; + } let log = log::init(&log::default_dir(), Local::now()); log::install_panic_hook(log.clone()); tracing::info!( @@ -191,6 +201,7 @@ fn run(cli: Cli) -> Result<()> { Command::Window { common } => capture(Mode::Window, common), Command::Zoom { common } => capture(Mode::Zoom, common), Command::Edit { file } => editor::run(&file), + // Handled in main, before logging starts. Command::CheckConfig { file } => config::check(&file), Command::ComboDemo => sound::demo(&config::load(&config::default_path())?.sound), Command::Toolbar => {