From ed43da872c2fd1603a367fd2a2763d06795ceb7a Mon Sep 17 00:00:00 2001 From: Brendan Golden Date: Mon, 11 Mar 2024 23:14:29 +0000 Subject: [PATCH] feat: figured out how to share types across files --- _types/dns_object.nix | 19 +++++++++++++++++++ applications/dns.nix | 23 +++-------------------- config/dns.nix | 28 +++++++--------------------- 3 files changed, 29 insertions(+), 41 deletions(-) create mode 100644 _types/dns_object.nix diff --git a/_types/dns_object.nix b/_types/dns_object.nix new file mode 100644 index 0000000..6b7523e --- /dev/null +++ b/_types/dns_object.nix @@ -0,0 +1,19 @@ +{lib, ...}: +with lib; { + options = { + record = mkOption { + type = types.str; + }; + r_type = mkOption { + type = types.enum ["A" "CNAME" "TXT" "PTR" "SRV" "MX"]; + }; + value = mkOption { + type = types.str; + }; + server = mkOption { + description = "Core record for a server"; + type = types.bool; + default = false; + }; + }; +} diff --git a/applications/dns.nix b/applications/dns.nix index 6b7bc6b..2ac25a5 100644 --- a/applications/dns.nix +++ b/applications/dns.nix @@ -316,28 +316,11 @@ in { }; }; - # mirrorred in ../config/dns.nix 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; - }; - }; - }); + type = lib.types.listOf (lib.types.submodule (import ../_types/dns_object.nix { + inherit lib; + })); }; }; }; diff --git a/config/dns.nix b/config/dns.nix index 991f058..c2306a7 100644 --- a/config/dns.nix +++ b/config/dns.nix @@ -5,27 +5,13 @@ ]; # 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; - }; - }; - }); + options.skynet = { + records = lib.mkOption { + description = "Records, sorted based on therir type"; + type = lib.types.listOf (lib.types.submodule (import ../_types/dns_object.nix { + inherit lib; + })); + }; }; config = {