Skip to content

Commit

Permalink
systemd: only set old units directory when available
Browse files Browse the repository at this point in the history
  • Loading branch information
rycee committed Jul 8, 2024
1 parent 6b7ce96 commit dfaf0ff
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions modules/systemd.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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"
'';
};
Expand All @@ -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}
Expand All @@ -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
Expand Down

0 comments on commit dfaf0ff

Please sign in to comment.