2016-04-21 03:10:52 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
{
|
|
|
|
###### interface
|
|
|
|
|
|
|
|
options = {
|
|
|
|
services.tinydns = {
|
|
|
|
enable = mkOption {
|
|
|
|
default = false;
|
|
|
|
type = types.bool;
|
2022-07-28 22:19:15 +01:00
|
|
|
description = lib.mdDoc "Whether to run the tinydns dns server";
|
2016-04-21 03:10:52 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
data = mkOption {
|
|
|
|
type = types.lines;
|
2017-09-24 15:38:25 +01:00
|
|
|
default = "";
|
2022-07-28 22:19:15 +01:00
|
|
|
description = lib.mdDoc "The DNS data to serve, in the format described by tinydns-data(8)";
|
2016-04-21 03:10:52 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
ip = mkOption {
|
|
|
|
default = "0.0.0.0";
|
|
|
|
type = types.str;
|
2022-07-28 22:19:15 +01:00
|
|
|
description = lib.mdDoc "IP address on which to listen for connections";
|
2016-04-21 03:10:52 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
|
|
|
config = mkIf config.services.tinydns.enable {
|
|
|
|
environment.systemPackages = [ pkgs.djbdns ];
|
|
|
|
|
2021-08-08 13:00:00 +01:00
|
|
|
users.users.tinydns = {
|
|
|
|
isSystemUser = true;
|
|
|
|
group = "tinydns";
|
|
|
|
};
|
|
|
|
users.groups.tinydns = {};
|
2016-04-21 03:10:52 +01:00
|
|
|
|
|
|
|
systemd.services.tinydns = {
|
|
|
|
description = "djbdns tinydns server";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
2019-11-08 16:25:31 +00:00
|
|
|
after = [ "network.target" ];
|
2016-04-21 03:10:52 +01: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
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|