… and vice versa: what executables are provided by a given package? (E.g., coreutils
)
Is there already an issue or a general discussion thread about this? There are plenty of examples of users having a hard time finding the right package that provides the needed program / executable:
- (NixOS discourse) How to find the package name for executable
- (unix stackexchange) Which nix-package provides a given file/binary/command?
- (unix stackexchange) How to find out which (not installed) package a file belongs to on NixOS?
- (stackoverflow) Which package provides the “make” executable?
There is probably more; couldn’t even find one of my own questions from a couple years back…
The common suggestion for these questions is to use nix-index
and then nix-locate
commands, but (1) these are not official, (2) still hard to find what the package names are, and (3) it doesn’t always work (or, most likely, I’m doing something wrong). (@bennofs Thank you for these! Without your tools, it would be a nigh hopeless task to find stuff.)
$ nix-locate bin/ffplay
jellyfin-ffmpeg.out 176,320 x /nix/store/46dz6jx9mk8fhc3brfka8iigjk66lssc-jellyfin-ffmpeg-5.1.2-2/bin/ffplay
arcanPackages.ffmpeg.out 176,064 x /nix/store/f7j7jmjqsig1xcff4ypcw8bnr0lj3ha2-ffmpeg-full-4.4.2/bin/ffplay
ffmpeg_5-full.out 176,320 x /nix/store/d12zpv3j48v7ykslf3l0q9q8jf59h225-ffmpeg-full-5.1.2/bin/ffplay
$ nix-locate bin/aplay
$
Needed to include the bin/
prefix to make sure only executables are found. Tried aplay
without bin/
, but there were no aplay
executables listed. (Maybe because it automatically excludes packages that won’t evaluate on a given architecture?)
My scenario that prompted this question:
I wanted to play a WAV file from the terminal, looked online, and remembered that I used aplay
on Linux out of the box. I’m on Mac at the moment, so this wasn’t available.
Steps trying to find aplay
:
-
First instinct was to look in NixOS package, but none the packages seemed relevant (obviously, they only had the string “aplay”)
-
Did a google search for
nix nixos aplay
, the most relevant (and seemingly only) result was the ALSA NixOS Wiki page; it didn’t help much either, but the name “ALSA” gave me some pointers. -
Did a NixOS package search on
alsa
next, andalsa-lib
&alsa-utils
seemed generic enough so I gave them a try withnix-shell -p
. -
They didn’t evaluate as ALSA is not supported on Mac M1 (at least, that’s what the output said).
Went back to the askubuntu threa above, and ffmpeg
’s ffplay
was my next candidate.
-
nix-shell -p ffmpeg
ran, noffplay
… -
Google search for
nix nixos ffplay
yielded the Nixpkgs issue ffmpeg-full: ffplay is missing #24783 at the very top, which itself is a duplicate of ffmpeg + SDL #24658 that hinted of using theffmpeg-full
package -
nix-shell -p ffmpeg-full
did haveffplay
, yay!