Skip to content

Commit

Permalink
add COMMA_NIXPKGS_FLAKE to allow changing the flake used by nix shell
Browse files Browse the repository at this point in the history
this won't affect the picker choices as those are determinted by the
index
  • Loading branch information
Artturin committed Apr 5, 2023
1 parent e27a636 commit 17a4f33
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/main.rs
Expand Up @@ -35,7 +35,7 @@ fn pick(picker: &str, derivations: &[&str]) -> Option<String> {
)
}

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([
Expand All @@ -47,7 +47,7 @@ fn run_command(use_channel: bool, choice: &str, command: &str, trail: &[String])
if use_channel {
run_cmd.args(["-f", "<nixpkgs>", choice]);
} else {
run_cmd.args([format!("nixpkgs#{}", choice)]);
run_cmd.args([format!("{}#{}", nixpkgs_flake, choice)]);
}

run_cmd.args(["--command", command]);
Expand Down Expand Up @@ -129,7 +129,7 @@ fn main() -> ExitCode {
.args(["-f", "<nixpkgs>", "-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
Expand All @@ -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,
Expand Down

0 comments on commit 17a4f33

Please sign in to comment.