default.nix (3314B)
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, 9 pkgs, 10 config, 11 ... 12 }: 13 let 14 inherit (lib) mkOption mkBooleanOption types; 15 inherit (pkgs) liminix; 16 in 17 { 18 imports = [ ../ipv6-autoconfig ]; 19 options = { 20 system.service.dnsmasq = mkOption { 21 type = liminix.lib.types.serviceDefn; 22 }; 23 }; 24 config = { 25 system.service.dnsmasq = config.system.callService ./service.nix { 26 user = mkOption { 27 type = types.str; 28 default = "dnsmasq"; 29 description = "Specifies the unix user which dnsmasq will run as"; 30 }; 31 group = mkOption { 32 type = types.str; 33 default = "dnsmasq"; 34 description = "Specifies the unix group which dnsmasq will run as"; 35 }; 36 resolvconf = mkOption { 37 type = types.nullOr liminix.lib.types.service; 38 default = null; 39 }; 40 interface = mkOption { 41 type = liminix.lib.types.service; 42 default = null; 43 }; 44 upstreams = mkOption { 45 type = types.listOf types.str; 46 default = [ ]; 47 }; 48 ranges = mkOption { 49 type = types.listOf types.str; 50 }; 51 useHostsFile = mkOption { 52 type = types.bool; 53 description = "serve names from /etc/hosts"; 54 default = false; 55 }; 56 hosts = mkOption { 57 default = { }; 58 type = types.attrsOf ( 59 types.submodule { 60 options = { 61 mac = mkOption { 62 description = '' 63 MAC or other hardware address to match on. For Ethernet 64 this is a 48 bit address represented as colon-separated 65 hex bytes, or "id:clientid" to match a presented 66 client id (IPv6 DUID) 67 ''; 68 type = types.str; 69 example = "01:20:31:4a:50"; 70 }; 71 v4 = mkOption { 72 description = "IPv4 address to assign to this client"; 73 example = "192.0.2.1"; 74 type = types.str; 75 }; 76 v6 = mkOption { 77 type = types.listOf types.str; 78 description = "IPv6 addresses or interface-ids to assign to this client"; 79 default = [ ]; 80 example = [ 81 "fe80::42:1eff:fefd:b341" 82 "::1234" 83 ]; 84 }; 85 leasetime = mkOption { 86 type = types.int; 87 default = 86400; 88 }; 89 }; 90 } 91 ); 92 }; 93 domain = mkOption { 94 # this can be given multiple times so probably should be 95 # domains plural and list of string 96 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"; 97 type = types.str; 98 example = "example.com"; 99 }; 100 }; 101 users.dnsmasq = { 102 uid = 51; 103 gid = 51; 104 gecos = "DNS/DHCP service user"; 105 dir = "/run/dnsmasq"; 106 shell = "/bin/false"; 107 }; 108 groups.dnsmasq = { 109 gid = 51; 110 usernames = [ "dnsmasq" ]; 111 }; 112 groups.system.usernames = [ "dnsmasq" ]; 113 }; 114 }