From e2bd052f85b7f81f12eca9450d99627e2a7bee90 Mon Sep 17 00:00:00 2001 From: technofab Date: Mon, 7 Jul 2025 15:52:16 +0200 Subject: [PATCH] fix(nix): use nix shell -c and improve nix-index usage --- core/src/system.rs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/core/src/system.rs b/core/src/system.rs index e9fb7f2..d6d5962 100644 --- a/core/src/system.rs +++ b/core/src/system.rs @@ -139,7 +139,13 @@ pub fn get_packages( return None; } let result = - command_output(shell, &format!("nix-locate --regex 'bin/{}$'", executable)); + command_output( + shell, + &format!( + "nix-locate --minimal --no-group --top-level --type x --type s --whole-name --at-root '/bin/{}'", + executable, + ), + ); if result.is_empty() { return None; } @@ -149,9 +155,7 @@ pub fn get_packages( line.split_whitespace() .next() .unwrap() - .rsplit_once('.') - .unwrap() - .0 + .trim_end_matches(".out") // remove .out, keep the rest as is .to_string() }) .collect(); @@ -258,10 +262,7 @@ pub fn shell_package(data: &Data, package_manager: &str, package: &str) -> Strin match package_manager { "guix" => format!("guix shell {} -- {}", package, command), - "nix" => format!( - r#"nix-shell -p {} --command "{};return""#, - package, command - ), + "nix" => format!(r#"nix shell nixpkgs#{} -c {}"#, package, command), _ => unreachable!("Only `nix` and `guix` are supported for shell installation"), } }