Reputation: 16089
I’m using Nix on macOS and on (non-NixOS) Linux. I’d like to give Nix a package or attribute name and have it show me
I’m essentially looking for the Nix equivalent of Homebrew’s brew info packagename
.
How can I get Nix to give me these pieces of information?
Upvotes: 3
Views: 1236
Reputation: 6632
With nix-env
on the CLI, I think the best we can currently and (relatively) conveniently do is JSON or XML:
$ nix-env --query --available --attr nixpkgs.hello --meta --json
# Or in terse form:
$ nix-env -qaA nixpkgs.hello --json
Neither output nor input are especially human-friendly, typical Nix usability…
The path to the .nix
file is listed as position
, also in the REPL as in Robert's neat answer it's hello.meta.position
. It is worth mentioning nix edit nixpkgs.hello
, for opening the file.
Upvotes: 3
Reputation: 7389
Perhaps there's a better way, like with nix-env
, but I usually use nix repl
for this purpose.
$ nix repl '<nixpkgs>'
Welcome to Nix version 2.2.2. Type :? for help.
Loading '<nixpkgs>'...
Added 10069 variables.
nix-repl> docker-c[TAB]
docker-compose docker-credential-gcr
nix-repl> docker-compose.version
"1.23.1"
Upvotes: 2