From 17a4f3384954a43cec0f91361f153cda908fe3d3 Mon Sep 17 00:00:00 2001 From: Artturin Date: Thu, 6 Apr 2023 01:00:41 +0300 Subject: [PATCH] add COMMA_NIXPKGS_FLAKE to allow changing the flake used by nix shell this won't affect the picker choices as those are determinted by the index --- src/main.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index be9b89b..1b7e12d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -35,7 +35,7 @@ fn pick(picker: &str, derivations: &[&str]) -> Option { ) } -fn run_command(use_channel: bool, choice: &str, command: &str, trail: &[String]) { +fn run_command(use_channel: bool, choice: &str, command: &str, trail: &[String], nixpkgs_flake: &str) { let mut run_cmd = Command::new("nix"); run_cmd.args([ @@ -47,7 +47,7 @@ fn run_command(use_channel: bool, choice: &str, command: &str, trail: &[String]) if use_channel { run_cmd.args(["-f", "", choice]); } else { - run_cmd.args([format!("nixpkgs#{}", choice)]); + run_cmd.args([format!("{}#{}", nixpkgs_flake, choice)]); } run_cmd.args(["--command", command]); @@ -129,7 +129,7 @@ fn main() -> ExitCode { .args(["-f", "", "-iA", choice.rsplit('.').last().unwrap()]) .exec(); } else { - run_command(use_channel, &choice, command, trail); + run_command(use_channel, &choice, command, trail, &args.nixpkgs_flake); } ExitCode::SUCCESS @@ -146,6 +146,9 @@ struct Opt { #[clap(long, env = "COMMA_PICKER", default_value = "fzy")] picker: String, + #[clap(long, env = "COMMA_NIXPKGS_FLAKE", default_value = "nixpkgs")] + nixpkgs_flake: String, + /// DEPRECATED Update nix-index database #[clap(short, long)] update: bool,