openntpd: make -s flag work
after seeing `adjtime failed: Invalid argument` in my syslog, I tried using `ntpd -s` but it would trigger `/etc/ntpd.conf: No such file or directory` see https://github.com/NixOS/nixpkgs/issues/31885 Instead of running the daemon with a specific config file, use the standard file so that user are able to use the ntp executable without having to look for the current config file.
This commit is contained in:
parent
1d9330d63a
commit
f5e169c608
@ -7,7 +7,7 @@ let
|
|||||||
|
|
||||||
package = pkgs.openntpd_nixos;
|
package = pkgs.openntpd_nixos;
|
||||||
|
|
||||||
cfgFile = pkgs.writeText "openntpd.conf" ''
|
configFile = ''
|
||||||
${concatStringsSep "\n" (map (s: "server ${s}") cfg.servers)}
|
${concatStringsSep "\n" (map (s: "server ${s}") cfg.servers)}
|
||||||
${cfg.extraConfig}
|
${cfg.extraConfig}
|
||||||
'';
|
'';
|
||||||
@ -31,8 +31,8 @@ in
|
|||||||
type = with types; lines;
|
type = with types; lines;
|
||||||
default = "";
|
default = "";
|
||||||
example = ''
|
example = ''
|
||||||
listen on 127.0.0.1
|
listen on 127.0.0.1
|
||||||
listen on ::1
|
listen on ::1
|
||||||
'';
|
'';
|
||||||
description = ''
|
description = ''
|
||||||
Additional text appended to <filename>openntpd.conf</filename>.
|
Additional text appended to <filename>openntpd.conf</filename>.
|
||||||
@ -57,6 +57,8 @@ in
|
|||||||
# Add ntpctl to the environment for status checking
|
# Add ntpctl to the environment for status checking
|
||||||
environment.systemPackages = [ package ];
|
environment.systemPackages = [ package ];
|
||||||
|
|
||||||
|
environment.etc."ntpd.conf".text = configFile;
|
||||||
|
|
||||||
users.extraUsers = singleton {
|
users.extraUsers = singleton {
|
||||||
name = "ntp";
|
name = "ntp";
|
||||||
uid = config.ids.uids.ntp;
|
uid = config.ids.uids.ntp;
|
||||||
@ -71,7 +73,7 @@ in
|
|||||||
before = [ "time-sync.target" ];
|
before = [ "time-sync.target" ];
|
||||||
after = [ "dnsmasq.service" "bind.service" "network-online.target" ];
|
after = [ "dnsmasq.service" "bind.service" "network-online.target" ];
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
ExecStart = "${package}/sbin/ntpd -f ${cfgFile} -p ${pidFile} ${cfg.extraOptions}";
|
ExecStart = "${package}/sbin/ntpd -p ${pidFile} ${cfg.extraOptions}";
|
||||||
Type = "forking";
|
Type = "forking";
|
||||||
PIDFile = pidFile;
|
PIDFile = pidFile;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user