at 25.11-pre 2.5 kB view raw
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 3 4import ./make-test-python.nix ( 5 let 6 common = 7 { lib, ... }: 8 { 9 # override the `false` value from the qemu-vm base profile 10 services.timesyncd.enable = lib.mkForce true; 11 }; 12 mkVM = conf: { 13 imports = [ 14 conf 15 common 16 ]; 17 }; 18 in 19 { 20 name = "systemd-timesyncd"; 21 nodes = { 22 current = mkVM { }; 23 pre1909 = mkVM ( 24 { lib, ... }: 25 { 26 # create the path that should be migrated by our activation script when 27 # upgrading to a newer nixos version 28 system.stateVersion = "19.03"; 29 systemd.services.old-timesync-state-dir = { 30 requiredBy = [ "sysinit.target" ]; 31 before = [ "systemd-timesyncd.service" ]; 32 after = [ "local-fs.target" ]; 33 unitConfig.DefaultDependencies = false; 34 serviceConfig.Type = "oneshot"; 35 script = '' 36 rm -rf /var/lib/systemd/timesync 37 mkdir -p /var/lib/systemd /var/lib/private/systemd/timesync 38 ln -s /var/lib/private/systemd/timesync /var/lib/systemd/timesync 39 chown systemd-timesync: /var/lib/private/systemd/timesync 40 ''; 41 }; 42 } 43 ); 44 }; 45 46 testScript = '' 47 start_all() 48 current.succeed("systemctl status systemd-timesyncd.service") 49 # on a new install with a recent systemd there should not be any 50 # leftovers from the dynamic user mess 51 current.succeed("test -e /var/lib/systemd/timesync") 52 current.succeed("test ! -L /var/lib/systemd/timesync") 53 54 # timesyncd should be running on the upgrading system since we fixed the 55 # file bits in the activation script 56 pre1909.succeed("systemctl status systemd-timesyncd.service") 57 58 # the path should be gone after the migration 59 pre1909.succeed("test ! -e /var/lib/private/systemd/timesync") 60 61 # and the new path should no longer be a symlink 62 pre1909.succeed("test -e /var/lib/systemd/timesync") 63 pre1909.succeed("test ! -L /var/lib/systemd/timesync") 64 65 # after a restart things should still work and not fail in the activation 66 # scripts and cause the boot to fail.. 67 pre1909.shutdown() 68 pre1909.start() 69 pre1909.succeed("systemctl status systemd-timesyncd.service") 70 ''; 71 } 72)