How to get a package path in /nix/store which not containing a bin dir

I want to get a path for a package which not containing a bin dir(which cannot be used for it) in current generation on NixOS.

I know nix-store -r $(which some-program) and use nix-store -q to get more info about it. But now which cannot be used because this package doesn’t have outputs with bin.

I can use ls /nix/store | grep package-name, but this will list the package in some old generations without doing a garbage collection. I only want to find the one or ones in current generation.

I find nix-env -q --out-path can print a path by only using package name or attribute but I cannot find the system-wide profiles. For example, nix-env -q print nothing. Then I try to pass something to -p option such as /etc/profiles, /nix/var/nix/profiles/system and nix/var/nix/profiles/default, but it also prints nothing.


nix-store -q --graph /run/current-system can find this.

I usually use fd package-name /nix/store. Fd comes from and is pacakged in nixpkgs.

1 Like

I have used it for some months, but it cannot solve my problem here.

nix eval <channel>.<package>.outPath
$ nix eval nixpkgs.python37.outPath

NOTE: this will evalulate an outPath, given the channel (or file with --file), and may not actually exist in your store…


noticed your question was more about find the “system” package, in that case you could do:

$ sudo nix eval nixos.firefox.outPath

This may seem weird to need to do sudo, but it’s on purpose. By default, sudo/nixos subscribes to a different channel:

$ nix-channel --list
$ sudo !!
sudo nix-channel --list

so you have to change the channel to match what channel the system is using, and then use sudo to evaluate it as root, otherwise you’ll just see your own personal/user channel.


Thank you! You can also add the --raw flag to avoid having to do any string munging. It excludes the surrounding quotes and the terminating newline.

1 Like

@jonringer I think the API changed, at least when I have flakes enabled, it gets confused. I ended up doing ls -1 /nix/store | grep <package-name>.

Now it would be closer to:

nix eval nixpkgs#firefox.outPath

But this assumes that nixpkgs points to the same pin of nixpkgs as what you used with your system.