1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-23 11:39:46 +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 home.activation.reloadSystemd = hm.dag.entryAfter [ "linkGeneration" ] (let
cmd = { cmd = {
suggest = '' suggest = ''
PATH=${dirOf cfg.systemctlPath}:$PATH \
bash ${./systemd-activate.sh} "''${oldGenPath=}" "$newGenPath" bash ${./systemd-activate.sh} "''${oldGenPath=}" "$newGenPath"
''; '';
legacy = '' legacy = ''
PATH=${dirOf cfg.systemctlPath}:$PATH \
${pkgs.ruby}/bin/ruby ${./systemd-activate.rb} \ ${pkgs.ruby}/bin/ruby ${./systemd-activate.rb} \
"''${oldGenPath=}" "$newGenPath" "${servicesStartTimeoutMs}" "''${oldGenPath=}" "$newGenPath" "${servicesStartTimeoutMs}"
''; '';
@ -346,10 +344,14 @@ in {
''; '';
}; };
ensureRuntimeDir = # Make sure that we have an environment where we are likely to
"XDG_RUNTIME_DIR=\${XDG_RUNTIME_DIR:-/run/user/$(id -u)}"; # 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 '' in ''
systemdStatus=$(${systemctl} --user is-system-running 2>&1 || true) systemdStatus=$(${systemctl} --user is-system-running 2>&1 || true)
@ -372,8 +374,7 @@ in {
newUnitsDir=${pkgs.emptyDirectory} newUnitsDir=${pkgs.emptyDirectory}
fi fi
${ensureRuntimeDir} \ ${ensureSystemd} ${getAttr cfg.startServices cmd}
${getAttr cfg.startServices cmd}
unset newUnitsDir oldUnitsDir unset newUnitsDir oldUnitsDir
else else