From ccf090b84162e1171cf83dea4e253628a0d76aeb Mon Sep 17 00:00:00 2001 From: Brendan Golden Date: Sat, 27 Jan 2024 18:53:49 +0000 Subject: [PATCH 1/6] feat: Added functionality to have dns for non nixos servers Closes #52 --- applications/dns.nix | 88 +++++++++++++++++++++++--------------------- config/dns.nix | 46 +++++++++++++++++++++++ 2 files changed, 92 insertions(+), 42 deletions(-) create mode 100644 config/dns.nix diff --git a/applications/dns.nix b/applications/dns.nix index 973b956..b912991 100644 --- a/applications/dns.nix +++ b/applications/dns.nix @@ -240,47 +240,49 @@ old = ""; }; - records = builtins.concatLists ( - lib.attrsets.mapAttrsToList ( - key: value: let - details_server = value.config.skynet_dns.server; - details_records = value.config.skynet_dns.records; - in - if builtins.hasAttr "skynet_dns" value.config - then - ( - # got to handle habing a dns record for the dns serves themselves. - if details_server.enable - then - ( - if details_server.primary - then - details_records - ++ [ - { - record = "ns1"; - r_type = "A"; - value = details_server.ip; - server = false; - } - ] - else - details_records - ++ [ - { - record = "ns2"; - r_type = "A"; - value = details_server.ip; - server = false; - } - ] - ) - else details_records - ) - else [] - ) - nodes - ); + records = + config.skynet.records + ++ builtins.concatLists ( + lib.attrsets.mapAttrsToList ( + key: value: let + details_server = value.config.skynet_dns.server; + details_records = value.config.skynet_dns.records; + in + if builtins.hasAttr "skynet_dns" value.config + then + ( + # got to handle habing a dns record for the dns serves themselves. + if details_server.enable + then + ( + if details_server.primary + then + details_records + ++ [ + { + record = "ns1"; + r_type = "A"; + value = details_server.ip; + server = false; + } + ] + else + details_records + ++ [ + { + record = "ns2"; + r_type = "A"; + value = details_server.ip; + server = false; + } + ] + ) + else details_records + ) + else [] + ) + nodes + ); nameserver = if cfg.server.primary @@ -288,7 +290,8 @@ else "ns2"; in { imports = [ - ../applications/firewall.nix + ./firewall.nix + ../config/dns.nix ]; options = { @@ -313,6 +316,7 @@ in { }; }; + # mirrorred in ../config/dns.nix records = lib.mkOption { description = "Records, sorted based on therir type"; type = with lib.types; diff --git a/config/dns.nix b/config/dns.nix new file mode 100644 index 0000000..24e45d3 --- /dev/null +++ b/config/dns.nix @@ -0,0 +1,46 @@ +{lib, ...}: { + imports = [ + # Paths to other modules. + # Compose this module out of smaller ones. + ]; + + # this needs to mirror ../applications/dns.nix + options.skynet.records = lib.mkOption { + description = "Records, sorted based on therir type"; + type = with lib.types; + listOf (submodule { + options = { + record = lib.mkOption { + type = str; + }; + r_type = lib.mkOption { + type = enum ["A" "CNAME" "TXT" "PTR" "SRV" "MX"]; + }; + value = lib.mkOption { + type = str; + }; + server = lib.mkOption { + description = "Core record for a server"; + type = bool; + default = false; + }; + }; + }); + }; + + config = { + skynet.records = [ + #{ + # record = "bumblebee"; + # r_type = "A"; + # value = "193.1.99.91"; + # server = true; + #} + #{ + # record = "testing"; + # r_type = "CNAME"; + # value = "bumblebee"; + #} + ]; + }; +} From c8260ad05e0084acefa843a41ff915e41adaecb6 Mon Sep 17 00:00:00 2001 From: Eliza Macovei Date: Sat, 27 Jan 2024 20:42:19 +0000 Subject: [PATCH 2/6] Update file dns.nix --- config/dns.nix | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/config/dns.nix b/config/dns.nix index 24e45d3..14a3401 100644 --- a/config/dns.nix +++ b/config/dns.nix @@ -30,6 +30,17 @@ config = { skynet.records = [ + { + record = "optimus"; + r_type = "A"; + value = "193.1.99.90"; + server = true; + }, + { + record = "panel.games"; + r_type = "CNAME"; + value = "panel.games"; + } #{ # record = "bumblebee"; # r_type = "A"; From 215ba411fbb084c50f68e46e4b63c31878b0dd26 Mon Sep 17 00:00:00 2001 From: Eliza Macovei Date: Sat, 27 Jan 2024 20:43:02 +0000 Subject: [PATCH 3/6] Update file dns.nix --- config/dns.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/dns.nix b/config/dns.nix index 14a3401..109a242 100644 --- a/config/dns.nix +++ b/config/dns.nix @@ -31,7 +31,7 @@ config = { skynet.records = [ { - record = "optimus"; + record = "optimus-reborn"; r_type = "A"; value = "193.1.99.90"; server = true; From e7d47fa8732643e40be213620d721958eff4b11f Mon Sep 17 00:00:00 2001 From: Eliza Macovei Date: Sat, 27 Jan 2024 20:44:36 +0000 Subject: [PATCH 4/6] Update file dns.nix --- config/dns.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/dns.nix b/config/dns.nix index 109a242..75b772e 100644 --- a/config/dns.nix +++ b/config/dns.nix @@ -39,7 +39,7 @@ { record = "panel.games"; r_type = "CNAME"; - value = "panel.games"; + value = "optimus-reborn"; } #{ # record = "bumblebee"; From 16bae0bf8f256961f955622688329216bd4b9f0d Mon Sep 17 00:00:00 2001 From: Eliza Macovei Date: Sat, 27 Jan 2024 20:49:18 +0000 Subject: [PATCH 5/6] Added config folder to changes --- .gitlab-ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f9d6ad4..4d7684a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -78,6 +78,7 @@ sync_repos: - secrets/**/* - flake.* - .gitlab-ci.yml + - config/**/* # deploy items only run on main .deploy_template: &deployment @@ -92,6 +93,7 @@ sync_repos: - applications/**/* - machines/**/* - secrets/**/* + - config/**/* linter: <<: *builder @@ -152,4 +154,4 @@ deploy_gitlab: stage: deploy_gitlab script: - colmena apply -v --on @active-gitlab - when: manual \ No newline at end of file + when: manual From a7231e0d6df0511d60ff86d85b10bbbe79fc6ff3 Mon Sep 17 00:00:00 2001 From: Eliza Macovei Date: Sat, 27 Jan 2024 20:57:58 +0000 Subject: [PATCH 6/6] Fix error --- config/dns.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/dns.nix b/config/dns.nix index 75b772e..b64c2c3 100644 --- a/config/dns.nix +++ b/config/dns.nix @@ -35,7 +35,7 @@ r_type = "A"; value = "193.1.99.90"; server = true; - }, + } { record = "panel.games"; r_type = "CNAME";