1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-23 03:29:45 +01:00

systemd: unify handling of switch environment

This commit is contained in:
Robert Helgesson 2024-09-12 13:42:59 +02:00
parent 51e4664342
commit e1c6094075
No known key found for this signature in database
GPG key ID: 96E745BD17AA17ED

View file

@ -325,11 +325,9 @@ in {
home.activation.reloadSystemd = hm.dag.entryAfter [ "linkGeneration" ] (let
cmd = {
suggest = ''
PATH=${dirOf cfg.systemctlPath}:$PATH \
bash ${./systemd-activate.sh} "''${oldGenPath=}" "$newGenPath"
'';
legacy = ''
PATH=${dirOf cfg.systemctlPath}:$PATH \
${pkgs.ruby}/bin/ruby ${./systemd-activate.rb} \
"''${oldGenPath=}" "$newGenPath" "${servicesStartTimeoutMs}"
'';
@ -346,10 +344,14 @@ in {
'';
};
ensureRuntimeDir =
"XDG_RUNTIME_DIR=\${XDG_RUNTIME_DIR:-/run/user/$(id -u)}";
# Make sure that we have an environment where we are likely to
# successfully talk with systemd.
ensureSystemd = ''
env XDG_RUNTIME_DIR="''${XDG_RUNTIME_DIR:-/run/user/$(id -u)}" \
PATH="${dirOf cfg.systemctlPath}:$PATH" \
'';
systemctl = "${ensureRuntimeDir} ${cfg.systemctlPath}";
systemctl = "${ensureSystemd} systemctl";
in ''
systemdStatus=$(${systemctl} --user is-system-running 2>&1 || true)
@ -372,8 +374,7 @@ in {
newUnitsDir=${pkgs.emptyDirectory}
fi
${ensureRuntimeDir} \
${getAttr cfg.startServices cmd}
${ensureSystemd} ${getAttr cfg.startServices cmd}
unset newUnitsDir oldUnitsDir
else