From: Bobbe Date: Fri, 27 Mar 2026 18:11:15 +0000 (+0100) Subject: Use lib.sourceByRegex to filter source files X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=7adda9b685cda25038f0a5593c2b942809c86c39;p=stevenblack-hosts.git Use lib.sourceByRegex to filter source files --- diff --git a/unbound.nix b/unbound.nix index 0727edb4a..c34b50fa1 100644 --- a/unbound.nix +++ b/unbound.nix @@ -1,13 +1,23 @@ { + lib, runCommandLocal, }: let toUnboundConf = ''awk 'NF == 2 && $1 == "0.0.0.0" && $2 != "0.0.0.0" { printf "local-zone: \"%s\" always_nxdomain\n", $2 }'\''; in -runCommandLocal "stevenblack-hosts-unbound" { src = ./.; } '' - mkdir $out - ${toUnboundConf} < $src/hosts > $out/hosts - for file in $src/alternates/*/hosts; do - ${toUnboundConf} < $file > $out/$(basename $(dirname $file)) - done -'' +runCommandLocal "stevenblack-hosts-unbound" + { + src = lib.sourceByRegex ./. [ + "^hosts$" + "^alternates$" + "^alternates/[^/]+$" + "^alternates/[^/]+/hosts$" + ]; + } + '' + mkdir $out + ${toUnboundConf} < $src/hosts > $out/hosts + for file in $src/alternates/*/hosts; do + ${toUnboundConf} < $file > $out/$(basename $(dirname $file)) + done + ''