Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nix run with different binary name #4498

Closed
0ihsan opened this issue Jan 31, 2021 · 5 comments
Closed

nix run with different binary name #4498

0ihsan opened this issue Jan 31, 2021 · 5 comments
Assignees
Labels
Milestone

Comments

@0ihsan
Copy link

0ihsan commented Jan 31, 2021

Some programs don't match with their executable names, e.g.

  • ripgrep -> rg
  • neovim -> nvim
$ nix run nixpkgs#ripgrep
unable to execute '/nix/store/flwx9dk03037cfbqhkvlb9dv85k88gbq-ripgrep-12.1.1/bin/ripgrep': No such file or directory

It would be nice to detect their executable names automatically or get the specified name from a user input in arguments. Alternative solution would be to go into a nix shell nixpkgs#ripgrep and run the program in there but that would be a two step procedure. I would really prefer one of these commands instead of a subshell:

nix run nixpkgs#rg

or

nix run nixpkgs#ripgrep --exe rg

Additional context

My nix --version is: nix (Nix) 2.4pre20201201_5a6ddb3

@cole-h
Copy link
Member

cole-h commented Jan 31, 2021

Would also be useful for packages like coreutils that provide many different binaries.

@colemickens
Copy link
Member

Kinda related: I still get confused when choosing between nix run and nix shell. I tend to stick with nix shell because I know it's the more flexible option that can do what I need. (Also nix run doesn't seem to allow specifying args in the flake.nix. If it did, that would be more interesting.)

@Kha
Copy link
Contributor

Kha commented Feb 1, 2021

I've noticed this issue as well. One could claim that this is what the apps flake attribute is for, but I dislike that it is anti-modular, requiring keeping packages and apps in sync (or maybe nixpkgs or flake-utils just needs to introduce a nice convention for deriving apps from packages, outsourcing the issue from Nix itself).

nix run nixpkgs#ripgrep --exe rg

You can use nix shell nixpkgs#ripgrep -c rg.

(Also nix run doesn't seem to allow specifying args in the flake.nix. If it did, that would be more interesting.)

Cmdline args are currently ignored anyway: #3949

@0ihsan
Copy link
Author

0ihsan commented Feb 1, 2021

nix shell nixpkgs#ripgrep -c rg -w hello

Works for me. Thanks!

@edolstra edolstra self-assigned this Feb 12, 2021
@edolstra edolstra added this to the nix-2.4 milestone Feb 12, 2021
@garbas
Copy link
Member

garbas commented Feb 12, 2021

2 solutions to this problem:

  • improve the error message that you should rather run nix shell with a --command flag and also show possible binaries of a package
  • add a meta field to the derivation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants