nixpkgs/nixos/modules/services/networking/ntp/ntpd-rs.nix
stuebinm 6afb255d97 nixos: remove all uses of lib.mdDoc
these changes were generated with nixq 0.0.2, by running

  nixq ">> lib.mdDoc[remove] Argument[keep]" --batchmode nixos/**.nix
  nixq ">> mdDoc[remove] Argument[keep]" --batchmode nixos/**.nix
  nixq ">> Inherit >> mdDoc[remove]" --batchmode nixos/**.nix

two mentions of the mdDoc function remain in nixos/, both of which
are inside of comments.

Since lib.mdDoc is already defined as just id, this commit is a no-op as
far as Nix (and the built manual) is concerned.
2024-04-13 10:07:35 -07:00

90 lines
2.4 KiB
Nix

{ lib, config, pkgs, ... }:
let
cfg = config.services.ntpd-rs;
format = pkgs.formats.toml { };
configFile = format.generate "ntpd-rs.toml" cfg.settings;
in
{
options.services.ntpd-rs = {
enable = lib.mkEnableOption "Network Time Service (ntpd-rs)";
metrics.enable = lib.mkEnableOption "ntpd-rs Prometheus Metrics Exporter";
package = lib.mkPackageOption pkgs "ntpd-rs" { };
useNetworkingTimeServers = lib.mkOption {
type = lib.types.bool;
default = true;
description = ''
Use source time servers from {var}`networking.timeServers` in config.
'';
};
settings = lib.mkOption {
type = lib.types.submodule {
freeformType = format.type;
};
default = { };
description = ''
Settings to write to {file}`ntp.toml`
See <https://docs.ntpd-rs.pendulum-project.org/man/ntp.toml.5>
for more information about available options.
'';
};
};
config = lib.mkIf cfg.enable {
assertions = [
{
assertion = !config.services.timesyncd.enable;
message = ''
`ntpd-rs` is not compatible with `services.timesyncd`. Please disable one of them.
'';
}
];
environment.systemPackages = [ cfg.package ];
systemd.packages = [ cfg.package ];
services.timesyncd.enable = false;
systemd.services.systemd-timedated.environment = {
SYSTEMD_TIMEDATED_NTP_SERVICES = "ntpd-rs.service";
};
services.ntpd-rs.settings = {
observability = {
observation-path = lib.mkDefault "/var/run/ntpd-rs/observe";
};
source = lib.mkIf cfg.useNetworkingTimeServers (map
(ts: {
mode = "server";
address = ts;
})
config.networking.timeServers);
};
systemd.services.ntpd-rs = {
wantedBy = [ "multi-user.target" ];
serviceConfig = {
User = "";
Group = "";
DynamicUser = true;
ExecStart = [ "" "${lib.makeBinPath [ cfg.package ]}/ntp-daemon --config=${configFile}" ];
};
};
systemd.services.ntpd-rs-metrics = lib.mkIf cfg.metrics.enable {
wantedBy = [ "multi-user.target" ];
serviceConfig = {
User = "";
Group = "";
DynamicUser = true;
ExecStart = [ "" "${lib.makeBinPath [ cfg.package ]}/ntp-metrics-exporter --config=${configFile}" ];
};
};
};
meta.maintainers = with lib.maintainers; [ fpletz ];
}