How can I find out why imagemagick is in my path?

I’m using Nixos (unstable). Some software I use (passage) started giving me an error some time ago when trying to generate a qr code. When looking at the source for it, I saw that it was caused by it calling display when available. As display only runs on X11 and I’m using wayland, it errored out. Next I found out that display is in my path because of imagemagick:

❯ readlink -f $(which display)
/nix/store/ffqabp6bpfs9c8p96w8cfav3l15h5r09-imagemagick-7.1.1-21/bin/magick

And this is where I’m confused – I have no idea why imagemagick is in my path. Searching through my flake gives me nothing and when I do nix why-depends (which I saw referenced in another post as possibly helping in such situations), it says kitty depends on imagemagick.

❯ nix why-depends .#homeConfigurations.julian@tiny.activationPackage nixpkgs#imagemagick
───────┬───────────────────────────────────────────────────────────────────────────
       │ STDIN
───────┼───────────────────────────────────────────────────────────────────────────
   1   │ /nix/store/wr8gcfd08v9swm19g5vm4bbfs7myy09b-home-manager-generation
   2   │ └───/nix/store/6b8a16kbgnhms1sb9knspsdn4c41ic54-home-manager-path
   3   │     └───/nix/store/lzdldym5shsrqhr9v6xy10wz9mspp1cn-kitty-0.31.0
   4   │         └───/nix/store/ffqabp6bpfs9c8p96w8cfav3l15h5r09-imagemagick-7.1.1-
       │ 21
───────┴───────────────────────────────────────────────────────────────────────────

But why is it in my path? Shouldn’t it be just available to kitty rather than cluttering up my path?

I’m pretty new to Nix and Nixos, so I’m probably missing something. Thanks!

EDIT: I forgot to mention, I also checked my nixos configuration:

❯ nix why-depends .#nixosConfigurations.tiny.config.system.build.toplevel nixpkgs#imagemagick
'git+file:///home/julian/.setup#nixosConfigurations.tiny.config.system.build.toplevel' does not depend on 'flake:nixpkgs#imagemagick'

kitty package wraps the main program to add it to PATH:

It is added because some component of kitty needs it and modifying environment is the easiest way to pass it to it. Unfortunately, environment variables tend to be inherited by child processes, contaminating their environment.

And we actually have an issue about this Kitty leaks packages into system environment · Issue #171972 · NixOS/nixpkgs · GitHub.

The alternative method is hardcoding the paths using a patch but that takes a bit more effort:

3 Likes

Oh, thanks so much! I did have a quick look at the kitty derivation, but my nix isn’t all that great yet. While unfortunate, at least I now know what’s up. I’ll probably just write some workaround to get my qr codes :slight_smile: