mirror of
https://github.com/nix-community/home-manager
synced 2024-11-26 21:19:45 +01:00
systemd: unify handling of switch environment
This commit is contained in:
parent
51e4664342
commit
e1c6094075
1 changed files with 8 additions and 7 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue