Use lib.sourceByRegex to filter source files

This commit is contained in:
Bobbe
2026-03-27 19:11:15 +01:00
parent db6c334e94
commit 7adda9b685

View File

@@ -1,13 +1,23 @@
{ {
lib,
runCommandLocal, runCommandLocal,
}: }:
let let
toUnboundConf = ''awk 'NF == 2 && $1 == "0.0.0.0" && $2 != "0.0.0.0" { printf "local-zone: \"%s\" always_nxdomain\n", $2 }'\''; toUnboundConf = ''awk 'NF == 2 && $1 == "0.0.0.0" && $2 != "0.0.0.0" { printf "local-zone: \"%s\" always_nxdomain\n", $2 }'\'';
in in
runCommandLocal "stevenblack-hosts-unbound" { src = ./.; } '' runCommandLocal "stevenblack-hosts-unbound"
mkdir $out {
${toUnboundConf} < $src/hosts > $out/hosts src = lib.sourceByRegex ./. [
for file in $src/alternates/*/hosts; do "^hosts$"
${toUnboundConf} < $file > $out/$(basename $(dirname $file)) "^alternates$"
done "^alternates/[^/]+$"
'' "^alternates/[^/]+/hosts$"
];
}
''
mkdir $out
${toUnboundConf} < $src/hosts > $out/hosts
for file in $src/alternates/*/hosts; do
${toUnboundConf} < $file > $out/$(basename $(dirname $file))
done
''