nixos/applications/dns.nix

120 lines
3.1 KiB
Nix
Raw Normal View History

2023-01-17 22:56:05 +00:00
{ lib, pkgs, config, ... }:
let
cfg = config.skynet_dns;
in {
options = {
skynet_dns = {
enable = lib.mkEnableOption {
default = false;
example = true;
description = "Skynet DNS";
type = lib.types.bool;
2023-01-17 22:40:04 +00:00
};
2023-01-17 22:56:05 +00:00
records = {
external = lib.mkOption {
default = [ ];
type = lib.types.listOf lib.types.str;
description = ''
External records like: agentjones A 193.1.99.72
'';
};
cname = lib.mkOption {
default = [ ];
type = lib.types.listOf lib.types.str;
description = ''
External records like: ns1 CNAME ns1
'';
};
};
};
2023-01-17 22:40:04 +00:00
};
2023-01-17 22:56:05 +00:00
config = lib.mkIf cfg.enable {
services.bind = {
enable = true;
forwarders = [
# these were in old config file
"193.1.100.130"
"193.1.100.131"
];
2023-01-17 23:37:07 +00:00
zones = {
/*
put any other zones above skynet and link to their files like so:
example.ie = {
extraConfig = "";
file = ./dns/example;
master = true;
masters = [];
slaves = [ ];
};
Skynet is handled a bit more dynamically since it is the key one we should focus on
*/
"skynet.ie" = {
2023-01-17 23:02:12 +00:00
extraConfig = "";
2023-01-17 23:37:07 +00:00
# really wish teh nixos config didnt use master/slave
2023-01-17 23:02:12 +00:00
master = true;
2023-01-17 23:37:07 +00:00
masters = [ ];
2023-01-17 23:02:12 +00:00
slaves = [ ];
2023-01-17 23:37:07 +00:00
file = ''
$TTL 60 ; 1 minute
; hostmaster@skynet.ie is an email address that recieves stuff related to dns
@ IN SOA ns1.skynet.ie. hostmaster.skynet.ie. (
2023011701 ; Serial (YYYYMMDDCC)
600 ; Refresh (10 minutes)
300 ; Retry (5 minutes)
2419200 ; Expire (4 weeks)
3600 ; Minimum (1 hour)
)
NS ns1.skynet.ie.
NS ns2.skynet.ie.
; @ stands for teh root domain so teh A record below is where skynet.ie points to
A 193.1.99.76
MX 5 mail.skynet.ie.
2023-01-17 23:21:35 +00:00
2023-01-17 23:37:07 +00:00
; can have multiple mailserves
;MX 20 mail2.skynet.ie.
2023-01-17 23:21:35 +00:00
2023-01-17 23:37:07 +00:00
; ------------------------------------------
; Server Names
; ------------------------------------------
2023-01-17 23:21:35 +00:00
2023-01-17 23:37:07 +00:00
; External addresses
; ------------------------------------------
${lib.strings.concatMapStrings (x: x + "\n") cfg.records.external}
2023-01-17 23:21:35 +00:00
2023-01-17 23:37:07 +00:00
; this is fixed for now
wintermute A 193.1.101.148
2023-01-17 23:21:35 +00:00
2023-01-17 23:37:07 +00:00
; internal addresses
; ------------------------------------------
; May come back to this idea in teh future
; agentjones.int A 172.20.20.1
2023-01-17 23:21:35 +00:00
2023-01-17 23:37:07 +00:00
; cname's
; ------------------------------------------
${lib.strings.concatMapStrings (x: x + "\n") cfg.records.cname}
2023-01-17 23:21:35 +00:00
2023-01-17 23:37:07 +00:00
'';
};
2023-01-17 23:21:35 +00:00
};
2023-01-17 22:56:05 +00:00
};
};
2023-01-17 22:40:04 +00:00
}