mirror of
https://github.com/nix-community/home-manager
synced 2024-11-23 03:29:45 +01:00
systemd: fix sd-switch error on empty target directory
After update to sd-switch 0.5.0, `home-manager switch` failed with the following error message: > Error: Error switching > > Caused by: > 0: Failed to build switch plan > 1: No such file or directory (os error 2) This was caused by a non-existing target unit directory due to no user services being managed by home-manager. This change makes sd-switch run with pkgs.emptyDirectory as the target in such cases. Closes: https://github.com/nix-community/home-manager/issues/5552
This commit is contained in:
parent
92a26bf6df
commit
7a88ff6ad1
1 changed files with 8 additions and 1 deletions
|
@ -336,7 +336,7 @@ in {
|
|||
${pkgs.sd-switch}/bin/sd-switch \
|
||||
''${DRY_RUN:+--dry-run} $VERBOSE_ARG ${timeoutArg} \
|
||||
''${oldGenPath:+--old-units $oldGenPath/home-files/.config/systemd/user} \
|
||||
--new-units $newGenPath/home-files/.config/systemd/user
|
||||
--new-units "$newUnitsDir"
|
||||
'';
|
||||
};
|
||||
|
||||
|
@ -354,8 +354,15 @@ in {
|
|||
warnEcho "Attempting to reload services anyway..."
|
||||
fi
|
||||
|
||||
newUnitsDir="$newGenPath/home-files/.config/systemd/user"
|
||||
if [[ ! -e $newUnitsDir ]]; then
|
||||
newUnitsDir=${pkgs.emptyDirectory}
|
||||
fi
|
||||
|
||||
${ensureRuntimeDir} \
|
||||
${getAttr cfg.startServices cmd}
|
||||
|
||||
unset newUnitsDir
|
||||
else
|
||||
echo "User systemd daemon not running. Skipping reload."
|
||||
fi
|
||||
|
|
Loading…
Reference in a new issue