nixos.chrony: pass config file directly to daemon

This fixes an issue where `nixops deploy` wouldn't restart the chrony
service when the chrony configuration changed, because it wouldn't
detect that `/etc/chrony.conf` was a dependency of the chrony service.
This commit is contained in:
Ricardo M. Correia 2017-02-07 13:16:17 +01:00
parent 83865b2c6c
commit af4e6f155e

View File

@ -12,6 +12,24 @@ let
cfg = config.services.chrony;
configFile = pkgs.writeText "chrony.conf" ''
${concatMapStringsSep "\n" (server: "server " + server) cfg.servers}
${optionalString
cfg.initstepslew.enabled
"initstepslew ${toString cfg.initstepslew.threshold} ${concatStringsSep " " cfg.initstepslew.servers}"
}
driftfile ${stateDir}/chrony.drift
keyfile ${keyFile}
generatecommandkey
${optionalString (!config.time.hardwareClockInLocalTime) "rtconutc"}
${cfg.extraConfig}
'';
in
{
@ -70,25 +88,6 @@ in
# Make chronyc available in the system path
environment.systemPackages = [ pkgs.chrony ];
environment.etc."chrony.conf".text =
''
${concatMapStringsSep "\n" (server: "server " + server) cfg.servers}
${optionalString
cfg.initstepslew.enabled
"initstepslew ${toString cfg.initstepslew.threshold} ${concatStringsSep " " cfg.initstepslew.servers}"
}
driftfile ${stateDir}/chrony.drift
keyfile ${keyFile}
generatecommandkey
${optionalString (!config.time.hardwareClockInLocalTime) "rtconutc"}
${cfg.extraConfig}
'';
users.extraGroups = singleton
{ name = "chrony";
gid = config.ids.gids.chrony;
@ -124,7 +123,7 @@ in
'';
serviceConfig =
{ ExecStart = "${pkgs.chrony}/bin/chronyd -n -m -u chrony";
{ ExecStart = "${pkgs.chrony}/bin/chronyd -n -m -u chrony -f ${configFile}";
};
};