liminix

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

default.nix (1971B)


      1 ## NTP
      2 ## ===
      3 ##
      4 ## A network time protocol implementation so that your Liminix device
      5 ## may synchronize its clock with an accurate time source, and
      6 ## optionally also provide time service to its peers. The
      7 ## implementation used in Liminix is Chrony
      8 
      9 { lib, pkgs, config, ...}:
     10 let
     11   inherit (lib) mkOption types;
     12   inherit (pkgs) liminix;
     13   serverOpts = types.listOf types.str;
     14 in {
     15   options = {
     16     system.service.ntp = mkOption {
     17       type = liminix.lib.types.serviceDefn;
     18     };
     19   };
     20   config = {
     21     system.service.ntp = liminix.callService ./service.nix {
     22       user = mkOption {
     23         type = types.str;
     24         default = "ntp";
     25       };
     26       servers = mkOption { type = types.attrsOf serverOpts; default = {}; };
     27       pools = mkOption { type = types.attrsOf serverOpts; default = {}; };
     28       peers = mkOption { type = types.attrsOf serverOpts; default = {}; };
     29       makestep = mkOption {
     30         default = null;
     31         type = types.nullOr
     32           (types.submodule {
     33             options = {
     34               threshold = mkOption { type = types.number; default = null;};
     35               limit = mkOption { type = types.number; };
     36             };
     37           });
     38       };
     39       allow = mkOption {
     40         description = "subnets from which NTP clients are allowed to access the server";
     41         type = types.listOf types.str;
     42         default = [];
     43       };
     44       bindaddress = mkOption {
     45         type = types.nullOr types.str;
     46         default = null;
     47       };
     48       binddevice = mkOption {
     49         type = types.nullOr types.str;
     50         default = null;
     51       };
     52       dumpdir = mkOption {
     53         internal = true;
     54         type = types.path;
     55         default = "/run/chrony";
     56       };
     57       extraConfig = mkOption {
     58         type = types.lines;
     59         default = "";
     60       };
     61     };
     62     users.ntp = {
     63       uid = 52; gid= 52; gecos = "Unprivileged NTP user";
     64       dir = "/run/ntp";
     65       shell = "/bin/false";
     66     };
     67     # groups.system.usernames = ["ntp"];
     68   };
     69 }