fix timezone refresh

This commit is contained in:
RingOfStorms (Joshua Bell) 2026-01-06 23:32:20 -06:00
parent 20128c80ef
commit de0a6add72

View file

@ -20,4 +20,45 @@
after = [ "dbus.socket" ]; after = [ "dbus.socket" ];
wants = [ "dbus.socket" ]; wants = [ "dbus.socket" ];
}; };
systemd.services.fix-localtime-symlink = {
description = "Fix /etc/localtime symlink to be absolute";
wantedBy = [ "multi-user.target" ];
after = [ "automatic-timezoned.service" ];
wants = [ "automatic-timezoned.service" ];
serviceConfig = {
Type = "oneshot";
RemainAfterExit = true;
ExecStart = pkgs.writeShellScript "fix-localtime-symlink" ''
target=$(${pkgs.coreutils}/bin/readlink /etc/localtime 2>/dev/null || true)
if [ -z "$target" ]; then
exit 0
fi
if [[ "$target" == /* ]]; then
exit 0
fi
abs_target="/etc/$target"
if [ -e "$abs_target" ]; then
${pkgs.coreutils}/bin/ln -sf "$abs_target" /etc/localtime
fi
'';
};
unitConfig = {
ConditionPathIsSymbolicLink = "/etc/localtime";
};
};
systemd.paths.fix-localtime-symlink = {
description = "Watch /etc/localtime for changes";
wantedBy = [ "multi-user.target" ];
pathConfig = {
PathChanged = "/etc/localtime";
Unit = "fix-localtime-symlink.service";
};
};
} }