mirror of
https://github.com/nix-community/home-manager
synced 2024-11-27 05:29:46 +01:00
systemd: replace use of who
command
Curiously the `who` command sometimes does not list logged-in users, resulting in systemd not being reloaded. Instead we use systemctl --user is-system-running to more directly detect whether systemd is running.
This commit is contained in:
parent
4745c7a00d
commit
e307ceeee7
1 changed files with 5 additions and 3 deletions
|
@ -159,14 +159,16 @@ in
|
|||
legacyReloadCmd = ''
|
||||
bash ${./systemd-activate.sh} "''${oldGenPath=}" "$newGenPath"
|
||||
'';
|
||||
|
||||
ensureRuntimeDir = "XDG_RUNTIME_DIR=\${XDG_RUNTIME_DIR:-/run/user/$(id -u)}";
|
||||
in
|
||||
''
|
||||
if who | grep -q '^${config.home.username} '; then
|
||||
XDG_RUNTIME_DIR=''${XDG_RUNTIME_DIR:-/run/user/$(id -u)} \
|
||||
if ${ensureRuntimeDir} ${cfg.systemctlPath} --quiet --user is-system-running 2> /dev/null; then
|
||||
${ensureRuntimeDir} \
|
||||
PATH=${dirOf cfg.systemctlPath}:$PATH \
|
||||
${if cfg.startServices then autoReloadCmd else legacyReloadCmd}
|
||||
else
|
||||
echo "User ${config.home.username} not logged in. Skipping."
|
||||
echo "User systemd daemon not running. Skipping reload."
|
||||
fi
|
||||
''
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue