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