How do i find out why a package is installed?

With this command i see every package that is part of the current system:

nix path-info -r /run/current-system

Then we have nix why-depends to show why a package depends on another one.

So when i want to know why curl is installed on my system, i use:

[root@nas:~]# nix why-depends /run/current-system nixpkgs.curl
/nix/store/5fm43m8kv7p2xi9f4ickhsd1h44jkbyj-nixos-system-nas-18.03.132229.7cbf6ca1c84
╚═══activate: …rapped..WRAPPER_PATH=/nix/store/rpb2wl5n1qh6fmvyp01fjyf4h0jykgpk-system-path/bin:/nix/store/rpb2…
    => /nix/store/rpb2wl5n1qh6fmvyp01fjyf4h0jykgpk-system-path
    ╚═══bin/curl -> /nix/store/sc56lngngp80fpnqwj9c93ik9i418lfm-curl-7.59.0-bin/bin/curl
        => /nix/store/sc56lngngp80fpnqwj9c93ik9i418lfm-curl-7.59.0-bin

I know i have curl in environment.systemPackages, so that looks like this.

Now with dbus:

[root@nas:~]# nix why-depends /run/current-system nixpkgs.dbus
/nix/store/5fm43m8kv7p2xi9f4ickhsd1h44jkbyj-nixos-system-nas-18.03.132229.7cbf6ca1c84
╚═══activate: …unch-helper.echo -n "/nix/store/rcd0p87dkwilr9693xcqp0j66nwic276-dbus-1.10.24/libexec/dbus-daemo…
    => /nix/store/rcd0p87dkwilr9693xcqp0j66nwic276-dbus-1.10.24

What does that mean?

And now the interesting part, why is i3lock installed on my headless server?

[root@nas:~]# nix why-depends /run/current-system nixpkgs.i3lock
'/nix/store/5fm43m8kv7p2xi9f4ickhsd1h44jkbyj-nixos-system-nas-18.03.132229.7cbf6ca1c84' does not depend on 'nixpkgs.i3lock'

I would interpret that as it isn’t, but it is listed in the output of nix path-info -r /run/current-system.

Maybe i’m using this tools wrong, interpret the results incorrect or the usabillity is just very bad (or everything together).

5 Likes

I think that is just a pam file from https://github.com/NixOS/nixpkgs/blob/cc083fa9070cdef426457142a2b38c2708547d51/nixos/modules/security/pam.nix#L563.

1 Like

right

/nix/store/izalhhls06y8kcznclswqqnkkb9d0vs2-i3lock.pam

# Most of these should be moved to specific modules.

also right :smiley:

1 Like

exactly the same question i had.

For anyone looking, what worked for me is to specify the actual file path, not the expression name.

3 Likes

Or if you’re on flakes, nixpkgs#curl.

2 Likes