1 # Regression test for systemd-timesync having moved the state directory without
2 # upstream providing a migration path. https://github.com/systemd/systemd/issues/12131
4 import ./make-test-python.nix (let
5 common = { lib, ... }: {
6 # override the `false` value from the qemu-vm base profile
7 services.timesyncd.enable = lib.mkForce true;
9 mkVM = conf: { imports = [ conf common ]; };
11 name = "systemd-timesyncd";
14 pre1909 = mkVM ({lib, ... }: with lib; {
15 # create the path that should be migrated by our activation script when
16 # upgrading to a newer nixos version
17 system.stateVersion = "19.03";
18 system.activationScripts.simulate-old-timesync-state-dir = mkBefore ''
19 rm -f /var/lib/systemd/timesync
20 mkdir -p /var/lib/systemd /var/lib/private/systemd/timesync
21 ln -s /var/lib/private/systemd/timesync /var/lib/systemd/timesync
22 chown systemd-timesync: /var/lib/private/systemd/timesync
29 current.succeed("systemctl status systemd-timesyncd.service")
30 # on a new install with a recent systemd there should not be any
31 # leftovers from the dynamic user mess
32 current.succeed("test -e /var/lib/systemd/timesync")
33 current.succeed("test ! -L /var/lib/systemd/timesync")
35 # timesyncd should be running on the upgrading system since we fixed the
36 # file bits in the activation script
37 pre1909.succeed("systemctl status systemd-timesyncd.service")
39 # the path should be gone after the migration
40 pre1909.succeed("test ! -e /var/lib/private/systemd/timesync")
42 # and the new path should no longer be a symlink
43 pre1909.succeed("test -e /var/lib/systemd/timesync")
44 pre1909.succeed("test ! -L /var/lib/systemd/timesync")
46 # after a restart things should still work and not fail in the activation
47 # scripts and cause the boot to fail..
50 pre1909.succeed("systemctl status systemd-timesyncd.service")