Release NixOS 23.11
[NixPkgs.git] / nixos / tests / systemd-timesyncd.nix
blobf38d06be1516e6b6f6371fe01a65d2db2ab8afaa
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;
8   };
9   mkVM = conf: { imports = [ conf common ]; };
10 in {
11   name = "systemd-timesyncd";
12   nodes = {
13     current = mkVM {};
14     pre1909 = mkVM ({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       systemd.tmpfiles.rules = [
19         "r /var/lib/systemd/timesync -"
20         "d /var/lib/systemd -"
21         "d /var/lib/private/systemd/timesync -"
22         "L /var/lib/systemd/timesync - - - - /var/lib/private/systemd/timesync"
23         "d /var/lib/private/systemd/timesync - systemd-timesync systemd-timesync -"
24       ];
25     });
26   };
28   testScript = ''
29     start_all()
30     current.succeed("systemctl status systemd-timesyncd.service")
31     # on a new install with a recent systemd there should not be any
32     # leftovers from the dynamic user mess
33     current.succeed("test -e /var/lib/systemd/timesync")
34     current.succeed("test ! -L /var/lib/systemd/timesync")
36     # timesyncd should be running on the upgrading system since we fixed the
37     # file bits in the activation script
38     pre1909.succeed("systemctl status systemd-timesyncd.service")
40     # the path should be gone after the migration
41     pre1909.succeed("test ! -e /var/lib/private/systemd/timesync")
43     # and the new path should no longer be a symlink
44     pre1909.succeed("test -e /var/lib/systemd/timesync")
45     pre1909.succeed("test ! -L /var/lib/systemd/timesync")
47     # after a restart things should still work and not fail in the activation
48     # scripts and cause the boot to fail..
49     pre1909.shutdown()
50     pre1909.start()
51     pre1909.succeed("systemctl status systemd-timesyncd.service")
52   '';