liminix

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

default.nix (2951B)


      1 ## Dnsmasq
      2 ## =======
      3 ##
      4 ## This module includes a service to provide DNS, DHCP, and IPv6
      5 ## router advertisement for the local network.
      6 
      7 
      8 { lib, pkgs, config, ...}:
      9 let
     10   inherit (lib) mkOption types;
     11   inherit (pkgs) liminix;
     12 in {
     13   options = {
     14     system.service.dnsmasq = mkOption {
     15       type = liminix.lib.types.serviceDefn;
     16     };
     17   };
     18   config = {
     19     system.service.dnsmasq = liminix.callService ./service.nix {
     20       user = mkOption {
     21         type = types.str;
     22         default = "dnsmasq";
     23         description = "Specifies the unix user which dnsmasq will run as" ;
     24       };
     25       group = mkOption {
     26         type = types.str;
     27         default = "dnsmasq";
     28         description = "Specifies the unix group which dnsmasq will run as" ;
     29       };
     30       resolvconf = mkOption {
     31         type = types.nullOr liminix.lib.types.service;
     32         default = null;
     33       };
     34       interface = mkOption {
     35         type = liminix.lib.types.service;
     36         default = null;
     37       };
     38       upstreams = mkOption {
     39         type = types.listOf types.str;
     40         default = [];
     41       };
     42       ranges = mkOption {
     43         type = types.listOf types.str;
     44       };
     45       hosts = mkOption {
     46         default = {};
     47         type = types.attrsOf (types.submodule {
     48           options = {
     49             mac = mkOption {
     50               description = ''
     51                 MAC or other hardware address to match on. For Ethernet
     52                 this is a 48 bit address represented as colon-separated
     53                 hex bytes, or "id:clientid" to match a presented
     54                 client id (IPv6 DUID)
     55               '';
     56               type = types.str;
     57               example = "01:20:31:4a:50";
     58             };
     59             v4 = mkOption  {
     60               description = "IPv4 address to assign to this client";
     61               example = "192.0.2.1";
     62               type = types.str;
     63             };
     64             v6 = mkOption  {
     65               type = types.listOf types.str;
     66               description = "IPv6 addresses or interface-ids to assign to this client";
     67               default = [];
     68               example = [ "fe80::42:1eff:fefd:b341" "::1234"];
     69             };
     70             leasetime = mkOption {
     71               type = types.int;
     72               default = 86400;
     73             };
     74           };
     75         });
     76       };
     77       domain = mkOption {
     78         # this can be given multiple times so probably should be
     79         # domains plural and list of string
     80         description = "Domain name for DHCP service: causes the DHCP server to return the domain to any hosts which request it, and sets the domain which it is legal for DHCP-configured hosts to claim";
     81         type = types.str;
     82         example = "example.com";
     83       };
     84     };
     85     users.dnsmasq = {
     86       uid = 51; gid= 51; gecos = "DNS/DHCP service user";
     87       dir = "/run/dnsmasq";
     88       shell = "/bin/false";
     89     };
     90     groups.dnsmasq = {
     91       gid = 51; usernames = ["dnsmasq"];
     92     };
     93     groups.system.usernames = ["dnsmasq"];
     94   };
     95 }