···
wantedBy = [ "sysinit.target" ];
aliases = [ "dbus-org.freedesktop.timesync1.service" ];
restartTriggers = [ config.environment.etc."systemd/timesyncd.conf".source ];
51
+
# Ensure that we have some stored time to prevent
52
+
# systemd-timesyncd to resort back to the fallback time. If
53
+
# the file doesn't exist we assume that our current system
54
+
# clock is good enough to provide an initial value.
56
+
if ! [ -f /var/lib/systemd/timesync/clock ]; then
57
+
test -d /var/lib/systemd/timesync || mkdir -p /var/lib/systemd/timesync
58
+
touch /var/lib/systemd/timesync/clock
61
+
# workaround an issue of systemd-timesyncd not starting due to upstream systemd reverting their dynamic users changes
62
+
# - https://github.com/NixOS/nixpkgs/pull/61321#issuecomment-492423742
63
+
# - https://github.com/systemd/systemd/issues/12131
64
+
(lib.optionalString (versionOlder config.system.stateVersion "19.09") ''
65
+
if [ -L /var/lib/systemd/timesync ]; then
66
+
rm /var/lib/systemd/timesync
67
+
mv /var/lib/private/systemd/timesync /var/lib/systemd/timesync
environment.etc."systemd/timesyncd.conf".text = ''
···
group = "systemd-timesync";
users.groups.systemd-timesync.gid = config.ids.gids.systemd-timesync;
63
-
system.activationScripts.systemd-timesyncd-migration =
64
-
# workaround an issue of systemd-timesyncd not starting due to upstream systemd reverting their dynamic users changes
65
-
# - https://github.com/NixOS/nixpkgs/pull/61321#issuecomment-492423742
66
-
# - https://github.com/systemd/systemd/issues/12131
67
-
mkIf (versionOlder config.system.stateVersion "19.09") ''
68
-
if [ -L /var/lib/systemd/timesync ]; then
69
-
rm /var/lib/systemd/timesync
70
-
mv /var/lib/private/systemd/timesync /var/lib/systemd/timesync
73
-
system.activationScripts.systemd-timesyncd-init-clock =
74
-
# Ensure that we have some stored time to prevent systemd-timesyncd to
75
-
# resort back to the fallback time.
76
-
# If the file doesn't exist we assume that our current system clock is
77
-
# good enough to provide an initial value.
79
-
if ! [ -f /var/lib/systemd/timesync/clock ]; then
80
-
test -d /var/lib/systemd/timesync || mkdir -p /var/lib/systemd/timesync
81
-
touch /var/lib/systemd/timesync/clock