home.packages
makes stuff available in your regular environment. Shells and most application drawers will find the things installed there.
Most services, windowmanagers, or otherwise auxiliary programs get a limited environment which does not get the ~/.nix-profile/bin
into their PATH
, as that would make it easy for them to have undocumented or unrecognized runtime dependencies to slip in. Basically: avoid the mess that all the other distros have to maintain.
You have to configure/wrap/write configuration for such programs in a way, that they either get wrapped with some extended PATH
in the environment or such that corresponding configuration does have the absolute storepath to the binary in question in it.
Lets take a look at my config (which I see right now I really should fix for amixer
!)
Here I map the media buttons on my keyboard to run certain commands. This module is far from being perfect, but it serves an example for the purpose.
The generated configuration looks like this:
,awful.key({ }, "XF86AudioLowerVolume", function () awful.util.spawn("amixer set Master 4%-") end),
awful.key({ }, "XF86AudioMute", function () awful.util.spawn("amixer set Master 1+ toggle") end),
awful.key({ }, "XF86AudioNext", function () awful.util.spawn("/nix/store/1xh8bjjvw1vik42fyvxh5xsrqxr8n5wj-playerctl-2.4.1/bin/playerctl next") end),
awful.key({ }, "XF86AudioPlay", function () awful.util.spawn("/nix/store/1xh8bjjvw1vik42fyvxh5xsrqxr8n5wj-playerctl-2.4.1/bin/playerctl play-pause") end),
awful.key({ }, "XF86AudioPrev", function () awful.util.spawn("/nix/store/1xh8bjjvw1vik42fyvxh5xsrqxr8n5wj-playerctl-2.4.1/bin/playerctl previous") end),
awful.key({ }, "XF86AudioRaiseVolume", function () awful.util.spawn("amixer set Master 4%+") end)
Here you see the playerctl
s being properly expanded into absolute program paths. The configuration will probably change with every other update, but I do not care, as nix and HM regenerate it for me whenever necessary.
This is how we deal with runtime dependencies in nix. We make them explicit whenever possible.