hyprwm / hypridle

Hyprland's idle daemon
BSD 3-Clause "New" or "Revised" License
403 stars 25 forks source link

Nix: systemd service does not inherit $PATH #20

Closed leon-erd closed 9 months ago

leon-erd commented 9 months ago

@fufexan Currently the hypridle systemd service does not inherit the $PATH variable that is available in your terminal. This makes it necessary to define the exact path to every executable in your hypridle.nix (i.e. lockCmd = lib.meta.getExe config.programs.hyprlock.package;) and hyprlock.nix (i.e. labels = [ {text = ''cmd[update:10000] echo "$(${pkgs.coreutils}/bin/date" +'%a %d. %b')"'';} ] ). This is not only inconvenient but might also frustrate new users who do not know why their configuration is not working out of the box.

We could maybe set

[Service]
EnvironmentFile=/path/to/env/file

in the systemd unit? But I do not know where nixos defines the PATH variable and I did not really find anything online (maybe I searched in the wrong places...), hence this issue.

Another option would be to hardcode a PATH variable into the service which seems a bit worse.

fufexan commented 9 months ago

If you also use the Hyprland Home Manager service (or dbus-update-activation-environment --systemd --all) it should work just fine. image

The trick is to use wayland.windowManager.hyprland.systemd.variables = ["--all"];.

leon-erd commented 9 months ago

Ahh this is perfect! I didn't know about this option but this is exactly what I wanted. Works like a charm :) Should we add a nix section to the README? If so I think it would be nice to state this there.

fufexan commented 9 months ago

Sure, we can do that. The part about "--all" should also be added to the HM page on the wiki.