This commit is contained in:
commit
30ce0dafc2
195 changed files with 8902 additions and 0 deletions
7
services/bind/default.nix
Normal file
7
services/bind/default.nix
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
imports = [
|
||||
./firewall.nix
|
||||
./options.nix
|
||||
./service.nix
|
||||
];
|
||||
}
|
||||
14
services/bind/firewall.nix
Normal file
14
services/bind/firewall.nix
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
let
|
||||
cfg = config.machine.bind;
|
||||
in
|
||||
with lib; mkIf cfg.enable {
|
||||
networking.firewall = {
|
||||
allowedTCPPorts = [ cfg.port ];
|
||||
allowedUDPPorts = [ cfg.port ];
|
||||
};
|
||||
}
|
||||
25
services/bind/options.nix
Normal file
25
services/bind/options.nix
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
dns,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
{
|
||||
options.machine.bind = {
|
||||
enable = mkEnableOption "Bind Server";
|
||||
domain = mkOption {
|
||||
type = types.str;
|
||||
description = "Domain name";
|
||||
};
|
||||
port = mkOption {
|
||||
type = types.port;
|
||||
default = 53;
|
||||
description = "Port to listen on.";
|
||||
};
|
||||
zones = mkOption {
|
||||
type = types.attrsOf dns.lib.types.zone;
|
||||
default = { };
|
||||
description = "DNS zones";
|
||||
};
|
||||
};
|
||||
}
|
||||
21
services/bind/service.nix
Normal file
21
services/bind/service.nix
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
let
|
||||
cfg = config.machine.bind;
|
||||
in
|
||||
with lib; mkIf cfg.enable {
|
||||
services.bind = {
|
||||
enable = cfg.enable;
|
||||
listenOnPort = cfg.port;
|
||||
zones = {
|
||||
${cfg.domain} = {
|
||||
master = true;
|
||||
file = pkgs.writeText "zone-${cfg.domain}" (builtins.toString cfg.zones.${cfg.domain});
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue