Seeing dependents of a package, as the leaf-level human-readable package names

tl;dr maybe terribly misunderstanding things (xy-problem?), or maybe just need help translating nix-store values (see 2 questions at the bottom). Ultimately hunting down an insecure package, but separately I’m generally curious about nix-store paths vs. packages and how to see the dependents.


I’m seeing an error that freeimage-unstable-2021-11-01 has been marked insecure (and then the expected mesasge about my options, like using NIXPKGS_ALLOW_INSECURE=1 etc).

My first question is: “what is that package? I don’t recognize that” (because maybe I’ll find a replacement for whatever the problematic package is). So searching the web for “find dependents of nix package” I came across this stackexchange post suggesting:

nix-store \
    --query \
    --referrers \
    /nix/store/kda2wbkcirc8s8ip7hkb2k5jy4hqshgq-nixos/nixos/pkgs/development/libraries/freeimage/default.nix

I ran that in a loop recursively, hoping I’d get to “leaf” level dependents that I’d personally installed like “gimp” or something, but I only have this to show as output:

referrers to "/nix/store/kda2wbkcirc8s8ip7hkb2k5jy4hqshgq-nixos/nixos/pkgs/development/libraries/freeimage/default.nix":

/nix/store/hszf0mhd97vl9yvaqpjrs7k3rvrllkk7-env-manifest.nix
/nix/store/x0k06h09wxxp97066s26idn91fjpnbsc-user-environment
referrers to "/nix/store/hszf0mhd97vl9yvaqpjrs7k3rvrllkk7-env-manifest.nix":

/nix/store/r1pq3g7mdp2h4yn2z1wzpzzy4m50m630-user-environment.drv
/nix/store/x0k06h09wxxp97066s26idn91fjpnbsc-user-environment

The problem is that I don’t recognize those paths and they don’t contain something like /freeimage/ I can go search for (the way that first nixstore path has in it).


so two questions I think I have

  • a) is there a different command I can run if I don’t know the path? (eg: the nix-store query above requires a path, but say I only know freeimage-unstable-2021-11-01)
  • b) inverse of (a): is there a command I can run to turn those paths back into the human-readable package names they represent?

Try nix-tree. It does exactly that.
Use ? for help, and / for search

nix shell nixpkgs#nix-tree

# For everything (NixOS, Home Manager)
nix-tree

# Or a specific path (that points to the nix store)
nix-tree /run/current-system
nix-tree ~/.local/state/nix/profiles/home-manager
1 Like

whoa neat UI in nix-tree. So that helped me get my ultimate answer: what depends on “freeimage”? answer: nixos, maybe?

I see nix-tree handles both answers to (a) and (b) entirely in its GUI:

  • a) search (/) followed by yank gets you a path.
  • b) pass a path in as the first arg of nix-tree and you get the package.

But I just tried both with gimp and I’m pretty sure that’s only installed because I installed it, and I’m not sure if that’s what the why-depends feature is trying to show me or not. This got me to search the forums again and I found this interesting: “there is no solution” discussion


separately: I’d still be interested if there was a single command (not a gui) that could give these answers!

I found a previous post about this that dumps all data, so I guess I could scrape that (the later commands in that thread don’t work for me even with all the --extra-experimental-features flags passed in). I’m just surprised there’s not a single command that will do this… I’ll keep hunting.