2016-04-21 04:10:52 +02:00
|
|
|
{ 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;
|
2017-09-24 16:38:25 +02:00
|
|
|
default = "";
|
2016-04-21 04:10:52 +02:00
|
|
|
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 ];
|
|
|
|
|
2019-10-12 22:25:28 +02:00
|
|
|
users.users.tinydns.isSystemUser = true;
|
2016-04-21 04:10:52 +02:00
|
|
|
|
|
|
|
systemd.services.tinydns = {
|
|
|
|
description = "djbdns tinydns server";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
2019-11-08 17:25:31 +01:00
|
|
|
after = [ "network.target" ];
|
2016-04-21 04:10:52 +02:00
|
|
|
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
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|