liminix-fork/modules/ntp/default.nix

70 lines
1.9 KiB
Nix
Raw Permalink Normal View History

## NTP
## ===
##
## A network time protocol implementation so that your Liminix device
## may synchronize its clock with an accurate time source, and
## optionally also provide time service to its peers. The
## implementation used in Liminix is Chrony
2023-07-23 00:22:45 +02:00
{ lib, pkgs, config, ...}:
let
inherit (lib) mkOption types;
2023-08-05 15:16:54 +02:00
inherit (pkgs) liminix;
serverOpts = types.listOf types.str;
2023-07-23 00:22:45 +02:00
in {
options = {
system.service.ntp = mkOption {
2023-08-05 15:16:54 +02:00
type = liminix.lib.types.serviceDefn;
2023-07-23 00:22:45 +02:00
};
};
config = {
2023-08-05 15:16:54 +02:00
system.service.ntp = liminix.callService ./service.nix {
user = mkOption {
type = types.str;
default = "ntp";
};
servers = mkOption { type = types.attrsOf serverOpts; default = {}; };
pools = mkOption { type = types.attrsOf serverOpts; default = {}; };
peers = mkOption { type = types.attrsOf serverOpts; default = {}; };
makestep = mkOption {
default = null;
type = types.nullOr
(types.submodule {
options = {
threshold = mkOption { type = types.number; default = null;};
limit = mkOption { type = types.number; };
};
});
};
allow = mkOption {
description = "subnets from which NTP clients are allowed to access the server";
type = types.listOf types.str;
default = [];
};
bindaddress = mkOption {
type = types.nullOr types.str;
default = null;
};
binddevice = mkOption {
type = types.nullOr types.str;
default = null;
};
dumpdir = mkOption {
internal = true;
type = types.path;
default = "/run/chrony";
};
extraConfig = mkOption {
type = types.lines;
default = "";
};
};
2023-07-23 00:22:45 +02:00
users.ntp = {
uid = 52; gid= 52; gecos = "Unprivileged NTP user";
dir = "/run/ntp";
shell = "/bin/false";
};
# groups.system.usernames = ["ntp"];
};
}