at 21.11-pre 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.isSystemUser = true; 36 37 systemd.services.tinydns = { 38 description = "djbdns tinydns server"; 39 wantedBy = [ "multi-user.target" ]; 40 after = [ "network.target" ]; 41 path = with pkgs; [ daemontools djbdns ]; 42 preStart = '' 43 rm -rf /var/lib/tinydns 44 tinydns-conf tinydns tinydns /var/lib/tinydns ${config.services.tinydns.ip} 45 cd /var/lib/tinydns/root/ 46 ln -sf ${pkgs.writeText "tinydns-data" config.services.tinydns.data} data 47 tinydns-data 48 ''; 49 script = '' 50 cd /var/lib/tinydns 51 exec ./run 52 ''; 53 }; 54 }; 55}