From dfaf0ff2e7e536e404a260845e436bd888c4bb5f Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Mon, 8 Jul 2024 22:33:29 +0200 Subject: [PATCH] systemd: only set old units directory when available --- modules/systemd.nix | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/modules/systemd.nix b/modules/systemd.nix index 1d96ec8d..d480a1e4 100644 --- a/modules/systemd.nix +++ b/modules/systemd.nix @@ -335,7 +335,7 @@ in { in '' ${pkgs.sd-switch}/bin/sd-switch \ ''${DRY_RUN:+--dry-run} $VERBOSE_ARG ${timeoutArg} \ - ''${oldGenPath:+--old-units $oldGenPath/home-files/.config/systemd/user} \ + ''${oldUnitsDir:+--old-units $oldUnitsDir} \ --new-units "$newUnitsDir" ''; }; @@ -354,6 +354,13 @@ in { warnEcho "Attempting to reload services anyway..." fi + if [[ -v oldGenPath ]]; then + oldUnitsDir="$oldGenPath/home-files/.config/systemd/user" + if [[ ! -e $oldUnitsDir ]]; then + oldUnitsDir= + fi + fi + newUnitsDir="$newGenPath/home-files/.config/systemd/user" if [[ ! -e $newUnitsDir ]]; then newUnitsDir=${pkgs.emptyDirectory} @@ -362,7 +369,7 @@ in { ${ensureRuntimeDir} \ ${getAttr cfg.startServices cmd} - unset newUnitsDir + unset newUnitsDir oldUnitsDir else echo "User systemd daemon not running. Skipping reload." fi