at 25.11-pre 1.5 kB view raw
1{ 2 config, 3 lib, 4 pkgs, 5 ... 6}: 7 8with lib; 9 10{ 11 ###### interface 12 13 options = { 14 services.tinydns = { 15 enable = mkOption { 16 default = false; 17 type = types.bool; 18 description = "Whether to run the tinydns dns server"; 19 }; 20 21 data = mkOption { 22 type = types.lines; 23 default = ""; 24 description = "The DNS data to serve, in the format described by {manpage}`tinydns-data(8)`"; 25 }; 26 27 ip = mkOption { 28 default = "0.0.0.0"; 29 type = types.str; 30 description = "IP address on which to listen for connections"; 31 }; 32 }; 33 }; 34 35 ###### implementation 36 37 config = mkIf config.services.tinydns.enable { 38 environment.systemPackages = [ pkgs.djbdns ]; 39 40 users.users.tinydns = { 41 isSystemUser = true; 42 group = "tinydns"; 43 }; 44 users.groups.tinydns = { }; 45 46 systemd.services.tinydns = { 47 description = "djbdns tinydns server"; 48 wantedBy = [ "multi-user.target" ]; 49 after = [ "network.target" ]; 50 path = with pkgs; [ 51 daemontools 52 djbdns 53 ]; 54 preStart = '' 55 rm -rf /var/lib/tinydns 56 tinydns-conf tinydns tinydns /var/lib/tinydns ${config.services.tinydns.ip} 57 cd /var/lib/tinydns/root/ 58 ln -sf ${pkgs.writeText "tinydns-data" config.services.tinydns.data} data 59 tinydns-data 60 ''; 61 script = '' 62 cd /var/lib/tinydns 63 exec ./run 64 ''; 65 }; 66 }; 67}