diff --git a/flake.nix b/flake.nix index 14a3826..e01f6e9 100644 --- a/flake.nix +++ b/flake.nix @@ -73,6 +73,12 @@ inputs.darwin.follows = "nix-darwin"; }; + dns = { + url = github:kirelagin/dns.nix; + inputs.nixpkgs.follows = "nixpkgs"; + inputs.flake-utils.follows = "flake-utils"; + }; + # Dependcies flake-compat = { url = github:edolstra/flake-compat; diff --git a/modules/system/dns/default.nix b/modules/system/dns/default.nix index 7527772..e11baec 100644 --- a/modules/system/dns/default.nix +++ b/modules/system/dns/default.nix @@ -2,7 +2,12 @@ with lib; #with lib.internal; -let cfg = config.custom.system.dns; +let + cfg = config.custom.system.dns; + zones = { + "geek" = import ./geek.nix pkgs; + "glue" = import ./glue.nix pkgs; + }; in { options.custom.system.dns = with types; { @@ -17,12 +22,12 @@ in "geek" = { master = false; masters = [ "202.83.95.229" ]; - file = "/etc/bind/zones/slaves/geek.zone"; + file = "${pkgs.openic-dns-root-data}/geek.zone"; }; "glue" = { master = false; masters = [ "195.201.99.61" "168.119.153.26" ]; - file = "/etc/bind/zones/slaves/glue.zone"; + file = "${pkgs.openic-dns-root-data}/glue.zone"; }; }; }; diff --git a/packages/opennic-dns-root-data/default.nix b/packages/opennic-dns-root-data/default.nix new file mode 100644 index 0000000..529f385 --- /dev/null +++ b/packages/opennic-dns-root-data/default.nix @@ -0,0 +1,15 @@ +{ stdenv, lib, dns }: + +stdenv.mkDerivation { + pname = "openic-dns-root-data"; + + buildCommand = '' + mkdir $out + echo "${dns.lib.toString "example.com" (import ./geek.nix { inherit dns; })}" > $out/geek.zone + echo "${dns.lib.toString "example.com" (import ./geek.nix { inherit dns; })}" > $out/glue.zone + ''; + + meta = with lib; { + description = "DNS root data including root zone for openic"; + }; +} diff --git a/packages/opennic-dns-root-data/geek.nix b/packages/opennic-dns-root-data/geek.nix new file mode 100644 index 0000000..5c2e7ba --- /dev/null +++ b/packages/opennic-dns-root-data/geek.nix @@ -0,0 +1,15 @@ +{ dns }: + +with dns.lib.combinators; + +{ + SOA = { + nameServer = "ns2"; + adminEmail = "shdwdrgn@sourpuss.net"; + serial = 2019030800; + }; + + NS = [ + "ns2.opennic.glue." + ]; +} diff --git a/packages/opennic-dns-root-data/glue.nix b/packages/opennic-dns-root-data/glue.nix new file mode 100644 index 0000000..52a7029 --- /dev/null +++ b/packages/opennic-dns-root-data/glue.nix @@ -0,0 +1,20 @@ +{ dns }: + +with dns.lib.combinators; + +{ + SOA = { + nameServer = "ns0"; + adminEmail = "shdwdrgn@sourpuss.net"; + serial = 2019030800; + }; + + NS = [ + "ns0.opennic.glue." + ]; + + subdomains = { + "ns0.opennic".A = [ "195.201.99.61" "168.119.153.26" ]; + }; +} +