From 7f9364eb884e67341ce0a43df3c07b5f44b93e69 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Fri, 20 Mar 2026 14:47:46 +0300 Subject: [PATCH] eh: add `develop` alias `nd`; prompt before auto-fixing hashes Signed-off-by: NotAShelf Change-Id: I74835b683e247c86e4907d4fe0eccba06a6a6964 --- eh/src/lib.rs | 5 +++++ eh/src/main.rs | 5 ++++- eh/src/util.rs | 16 ++++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/eh/src/lib.rs b/eh/src/lib.rs index f76e705..6cb4f31 100644 --- a/eh/src/lib.rs +++ b/eh/src/lib.rs @@ -31,6 +31,11 @@ pub enum Command { #[arg(trailing_var_arg = true)] args: Vec, }, + /// Enter a Nix development shell + Develop { + #[arg(trailing_var_arg = true)] + args: Vec, + }, /// Update flake inputs interactively Update { #[arg(trailing_var_arg = true)] diff --git a/eh/src/main.rs b/eh/src/main.rs index 074952f..e350510 100644 --- a/eh/src/main.rs +++ b/eh/src/main.rs @@ -32,7 +32,7 @@ fn handle_command(command: &str, args: &[String]) -> error::Result { match command { "update" => commands::update::handle_update(args), - "run" | "shell" | "build" => { + "run" | "shell" | "build" | "develop" => { commands::handle_nix_command( command, args, @@ -55,6 +55,7 @@ fn dispatch_multicall( "nr" => "run", "ns" => "shell", "nb" => "build", + "nd" => "develop", "nu" => "update", _ => return None, }; @@ -104,6 +105,8 @@ fn run_app() -> error::Result { Some(Command::Build { args }) => handle_command("build", &args), + Some(Command::Develop { args }) => handle_command("develop", &args), + Some(Command::Update { args }) => handle_command("update", &args), None => { diff --git a/eh/src/util.rs b/eh/src/util.rs index d29dd67..229e303 100644 --- a/eh/src/util.rs +++ b/eh/src/util.rs @@ -511,6 +511,22 @@ pub fn handle_nix_with_retry( // Check for hash mismatch errors if let Some(new_hash) = hash_extractor.extract_hash(&stderr) { let old_hash = hash_extractor.extract_old_hash(&stderr); + + // Ask for confirmation before fixing hash + let should_fix = dialoguer::Confirm::new() + .with_prompt(format!( + "Hash mismatch detected for {}. Update hash in local .nix files?", + pkg.bold() + )) + .default(true) + .interact() + .map_err(|e| EhError::Io(std::io::Error::other(e)))?; + + if !should_fix { + log_warn!("{}: hash fix cancelled by user", pkg.bold()); + return Err(EhError::ProcessExit { code: 1 }); + } + match fixer.fix_hash_in_files(old_hash.as_deref(), &new_hash) { Ok(true) => { log_info!(