2023-07-23 00:22:45 +02:00
|
|
|
{
|
|
|
|
liminix
|
|
|
|
, chrony
|
|
|
|
, serviceFns
|
|
|
|
, lib
|
|
|
|
, writeText
|
|
|
|
}:
|
2023-08-05 15:16:54 +02:00
|
|
|
params:
|
2023-07-23 00:22:45 +02:00
|
|
|
let
|
|
|
|
inherit (liminix.services) longrun;
|
|
|
|
inherit (lib) concatStringsSep mapAttrsToList;
|
|
|
|
inherit (liminix.lib) typeChecked;
|
|
|
|
inherit (lib) mkOption types;
|
|
|
|
|
|
|
|
serverOpts = types.listOf types.str;
|
|
|
|
configFile = p:
|
|
|
|
(mapAttrsToList (name: opts: "server ${name} ${concatStringsSep "" opts}")
|
|
|
|
p.servers)
|
|
|
|
++
|
|
|
|
(mapAttrsToList (name: opts: "pool ${name} ${concatStringsSep "" opts}")
|
|
|
|
p.pools)
|
|
|
|
++
|
|
|
|
(mapAttrsToList (name: opts: "peer ${name} ${concatStringsSep "" opts}")
|
|
|
|
p.peers)
|
2023-08-27 23:05:22 +02:00
|
|
|
++ [ "user ${p.user}" ]
|
2023-07-23 00:22:45 +02:00
|
|
|
++ (lib.optional (p.makestep != null) "makestep ${toString p.makestep.threshold} ${toString p.makestep.limit}")
|
|
|
|
++ (map (n: "allow ${n}") p.allow)
|
|
|
|
++ (lib.optional (p.bindaddress != null) "bindaddress ${p.bindaddress}")
|
|
|
|
++ (lib.optional (p.binddevice != null) "binddevice ${p.binddevice}")
|
|
|
|
++ (lib.optional (p.dumpdir != null) "dumpdir ${p.dumpdir}")
|
|
|
|
++ [p.extraConfig];
|
2023-08-05 15:16:54 +02:00
|
|
|
|
2023-07-23 00:22:45 +02:00
|
|
|
config = writeText "chrony.conf"
|
2023-08-05 15:16:54 +02:00
|
|
|
(concatStringsSep "\n" (configFile params));
|
2023-07-23 00:22:45 +02:00
|
|
|
in longrun {
|
|
|
|
name = "ntp"; # bad name, needs to be unique
|
|
|
|
run = "${chrony}/bin/chronyd -f ${config} -d";
|
|
|
|
}
|