From ac7e6dab4dacce015ea6d99c78164478564cdbbc Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Giraudeau Date: Thu, 13 Mar 2025 17:16:52 +0100 Subject: [PATCH] Pass dns as arg to zone submodules allowing less verbose usage like `dns.lib.toString "example.com" ./example.com.nix;` instead of `dns.lib.toString "example.com" (import ./example.com.nix { inherit dns; });` with `example.nix` now starting with ```nix { dns, ... }: with dns.combinators; { ``` --- dns/default.nix | 2 +- dns/types/record.nix | 1 + dns/types/zone.nix | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/dns/default.nix b/dns/default.nix index ef14c67..0194c86 100644 --- a/dns/default.nix +++ b/dns/default.nix @@ -9,7 +9,7 @@ let dnslib = { util = import ./util { inherit lib; }; - inherit types; + inherit types combinators; }; types = import ./types { lib = lib'; }; lib' = lib // { dns = dnslib; }; diff --git a/dns/types/record.nix b/dns/types/record.nix index 60af9d4..67f48cf 100644 --- a/dns/types/record.nix +++ b/dns/types/record.nix @@ -27,6 +27,7 @@ let description = "Record caching duration (in seconds)"; }; } // rsubt.options; + config._module.args = { inherit (lib) dns; }; }; in (if rsubt ? fromString then types.either types.str else lib.id) submodule; diff --git a/dns/types/zone.nix b/dns/types/zone.nix index e740548..7592ffa 100644 --- a/dns/types/zone.nix +++ b/dns/types/zone.nix @@ -42,6 +42,7 @@ let subzone = types.submodule { options = subzoneOptions; + config._module.args = { inherit (lib) dns; }; }; writeSubzone = name: zone: @@ -84,6 +85,7 @@ let } // subzoneOptions; config = { + _module.args = { inherit (lib) dns; }; __toString = zone@{ useOrigin, TTL, SOA, ... }: if useOrigin then ''