diff --git a/nixos/modules/services/networking/ntp/ntpd.nix b/nixos/modules/services/networking/ntp/ntpd.nix index bdc5adb394c2b..84f79df52b0e9 100644 --- a/nixos/modules/services/networking/ntp/ntpd.nix +++ b/nixos/modules/services/networking/ntp/ntpd.nix @@ -142,6 +142,7 @@ in group = "ntp"; description = "NTP daemon user"; home = "/var/lib/ntp"; + createHome = true; }; users.groups.ntp = { }; @@ -155,7 +156,6 @@ in serviceConfig = { ExecStart = "@${ntp}/bin/ntpd ntpd -g ${builtins.toString ntpFlags}"; Type = "forking"; - StateDirectory = "ntp"; # Hardening options PrivateDevices = true; diff --git a/nixos/tests/ntpd.nix b/nixos/tests/ntpd.nix index 1864044b64d4c..67a5a95e6fe59 100644 --- a/nixos/tests/ntpd.nix +++ b/nixos/tests/ntpd.nix @@ -20,6 +20,8 @@ import ./make-test-python.nix ( machine.wait_for_console_text('Listen normally on 10 eth*') machine.succeed('systemctl is-active ntpd.service') machine.succeed('ntpq -p') + # ntp user must be able to create drift files + machine.succeed('su -s /bin/sh -c "touch /var/lib/ntp/ntp.drift" ntp') ''; } )