From cd050f0bdfea14f031e4a671a366c77d4f62b19d Mon Sep 17 00:00:00 2001 From: sommerfeld Date: Fri, 5 Jun 2026 11:06:00 +0100 Subject: fix(systemd): use absolute %h/.nix-profile/bin paths in user units MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The previous environment.d fix was insufficient: even with the nix profile on the --user manager's PATH (confirmed via `systemctl --user show-environment`), bare-name ExecStart= still fails 203/EXEC. systemd's --user manager does not resolve a bare ExecStart binary against the imported/environment.d PATH. Invoke each unit's main binary by absolute path %h/.nix-profile/bin/ (waybar, swayidle, swayrd, inhibridge, wl-paste, wob). %h expands to $HOME at unit load. Secondary lookups those binaries/scripts perform (cliphist, swaymsg, playerctl) still rely on PATH, which environment.d provides — so that file stays, with its comment corrected to reflect this split. --- dot_config/environment.d/10-nix-profile-path.conf | 32 +++++++++++------------ 1 file changed, 15 insertions(+), 17 deletions(-) (limited to 'dot_config/environment.d/10-nix-profile-path.conf') diff --git a/dot_config/environment.d/10-nix-profile-path.conf b/dot_config/environment.d/10-nix-profile-path.conf index 2e396d7..61d6402 100644 --- a/dot_config/environment.d/10-nix-profile-path.conf +++ b/dot_config/environment.d/10-nix-profile-path.conf @@ -1,22 +1,20 @@ # Prepend the Nix home-profile (and ~/.local/bin) to the systemd *user* -# manager's PATH at manager startup, before any unit in sway-session.target -# launches. +# manager's environment PATH, so it is inherited by every service process. # -# Why this exists: most user-leaf tools (waybar, swayidle, swayr, mako, -# cliphist, inhibridge, wob, …) were migrated from pacman (/usr/bin) to the -# Nix home profile (~/.nix-profile/bin) and their .service units reference -# them by *bare* name, relying on $PATH resolution (see nix/host.nix). The -# systemd user manager does NOT source ~/.zprofile, so without this its PATH -# is only /usr/local/bin:/usr/bin:/bin and every bare-name ExecStart fails -# with status=203/EXEC. +# Scope of this file: it fixes PATH for *child-process* lookups made BY the +# services — e.g. wl-paste spawning `cliphist store`, swayidle running +# `swaymsg`/`playerctl`, and helper scripts (display-watcher.sh, +# on-battery-suspend) that call nix tools by bare name. The systemd user +# manager does NOT source ~/.zprofile, so without this its PATH is only +# /usr/local/bin:/usr/bin:/bin and those bare-name lookups fail. # -# The sway config also runs `systemctl --user import-environment PATH`, but -# that is a fire-and-forget `exec` that races with -# `systemctl --user start sway-session.target`; if the start wins, the units -# launch with the default PATH. environment.d is read deterministically at -# manager start (before any unit), so it closes that race independently of -# the live session. +# It does NOT fix systemd's own ExecStart= binary resolution: systemd's +# --user manager does not resolve a bare ExecStart name against this +# (imported/environment.d) PATH, so those would still fail 203/EXEC. For +# that reason the units under dot_config/systemd/user/ invoke their main +# binary by absolute path (%h/.nix-profile/bin/); this file only +# covers the secondary PATH lookups those binaries/scripts perform. # -# Note: environment.d is only re-read on a fresh user manager (login/boot) or -# after `systemctl --user daemon-reexec`; it is not picked up mid-session. +# Note: environment.d is only re-read on a fresh user manager (login/boot) +# or after `systemctl --user daemon-reexec`; it is not picked up mid-session. PATH=${HOME}/.nix-profile/bin:${HOME}/.local/bin:${PATH} -- cgit v1.3.1