liminix

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

default.nix (2126B)


      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 {
     10   lib,
     11   pkgs,
     12   config,
     13   ...
     14 }:
     15 let
     16   inherit (lib) mkOption types;
     17   inherit (pkgs) liminix;
     18   serverOpts = types.listOf types.str;
     19 in
     20 {
     21   options = {
     22     system.service.ntp = mkOption {
     23       type = liminix.lib.types.serviceDefn;
     24     };
     25   };
     26   config = {
     27     system.service.ntp = config.system.callService ./service.nix {
     28       user = mkOption {
     29         type = types.str;
     30         default = "ntp";
     31       };
     32       servers = mkOption {
     33         type = types.attrsOf serverOpts;
     34         default = { };
     35       };
     36       pools = mkOption {
     37         type = types.attrsOf serverOpts;
     38         default = { };
     39       };
     40       peers = mkOption {
     41         type = types.attrsOf serverOpts;
     42         default = { };
     43       };
     44       makestep = mkOption {
     45         default = null;
     46         type = types.nullOr (
     47           types.submodule {
     48             options = {
     49               threshold = mkOption {
     50                 type = types.number;
     51                 default = null;
     52               };
     53               limit = mkOption { type = types.number; };
     54             };
     55           }
     56         );
     57       };
     58       allow = mkOption {
     59         description = "subnets from which NTP clients are allowed to access the server";
     60         type = types.listOf types.str;
     61         default = [ ];
     62       };
     63       bindaddress = mkOption {
     64         type = types.nullOr types.str;
     65         default = null;
     66       };
     67       binddevice = mkOption {
     68         type = types.nullOr types.str;
     69         default = null;
     70       };
     71       dumpdir = mkOption {
     72         internal = true;
     73         type = types.path;
     74         default = "/run/chrony";
     75       };
     76       extraConfig = mkOption {
     77         type = types.lines;
     78         default = "";
     79       };
     80     };
     81     users.ntp = {
     82       uid = 52;
     83       gid = 52;
     84       gecos = "Unprivileged NTP user";
     85       dir = "/run/ntp";
     86       shell = "/bin/false";
     87     };
     88     # groups.system.usernames = ["ntp"];
     89   };
     90 }