From 291bc39a7affb0782a309c2b78a40880381d141f Mon Sep 17 00:00:00 2001 From: orangc Date: Sat, 21 Mar 2026 16:52:05 +0300 Subject: [PATCH] feat(nix): recursively import domain files via mapping --- flake.nix | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/flake.nix b/flake.nix index e5b61ba..c35e986 100644 --- a/flake.nix +++ b/flake.nix @@ -13,6 +13,21 @@ "fattouche.ns.cloudflare.com" ]; }; + + domains = builtins.readDir ./domains; + domainFiles = builtins.filterAttrs ( + name: type: type == "regular" && builtins.match ".*\\.nix" name != null + ) domains; + subdomains = builtins.mapAttrs' ( + name: _: + let + key = builtins.replaceStrings [ ".nix" ] [ "" ] name; + in + { + name = key; + value = import (./domains + "/${name}") { inherit dns; }; + } + ) domainFiles; in { packages.x86_64-linux = builtins.mapAttrs ( @@ -29,8 +44,7 @@ # note: Cloudflare ignores SOA and NS records uploaded via Zone File, they are included just so that dns.nix builds a valid zone file. - #subdomains = ; - # ^^ todo: implement file imports from ./domains + inherit subdomains; } ) ) domains;