From ab851b63daa9dcbc7f24fb5e9713825e01da21a5 Mon Sep 17 00:00:00 2001 From: Matt McHenry Date: Wed, 20 Apr 2016 22:10:52 -0400 Subject: [PATCH] nixos/tinydns: add module MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit with improvements suggested by Jörg Thalheim --- nixos/modules/module-list.nix | 1 + nixos/modules/services/networking/tinydns.nix | 53 +++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 nixos/modules/services/networking/tinydns.nix diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 918d0f3b245..9c61ac6fb5c 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -518,6 +518,7 @@ ./services/networking/tcpcrypt.nix ./services/networking/teamspeak3.nix ./services/networking/tinc.nix + ./services/networking/tinydns.nix ./services/networking/tftpd.nix ./services/networking/tox-bootstrapd.nix ./services/networking/toxvpn.nix diff --git a/nixos/modules/services/networking/tinydns.nix b/nixos/modules/services/networking/tinydns.nix new file mode 100644 index 00000000000..a60a820a09e --- /dev/null +++ b/nixos/modules/services/networking/tinydns.nix @@ -0,0 +1,53 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + ###### interface + + options = { + services.tinydns = { + enable = mkOption { + default = false; + type = types.bool; + description = "Whether to run the tinydns dns server"; + }; + + data = mkOption { + type = types.lines; + description = "The DNS data to serve, in the format described by tinydns-data(8)"; + }; + + ip = mkOption { + default = "0.0.0.0"; + type = types.str; + description = "IP address on which to listen for connections"; + }; + }; + }; + + ###### implementation + + config = mkIf config.services.tinydns.enable { + environment.systemPackages = [ pkgs.djbdns ]; + + users.extraUsers.tinydns = {}; + + systemd.services.tinydns = { + description = "djbdns tinydns server"; + wantedBy = [ "multi-user.target" ]; + path = with pkgs; [ daemontools djbdns ]; + preStart = '' + rm -rf /var/lib/tinydns + tinydns-conf tinydns tinydns /var/lib/tinydns ${config.services.tinydns.ip} + cd /var/lib/tinydns/root/ + ln -sf ${pkgs.writeText "tinydns-data" config.services.tinydns.data} data + tinydns-data + ''; + script = '' + cd /var/lib/tinydns + exec ./run + ''; + }; + }; +}