Use lib.sourceByRegex to filter source files
authorBobbe <redacted>
Fri, 27 Mar 2026 18:11:15 +0000 (19:11 +0100)
committerBobbe <redacted>
Mon, 27 Apr 2026 12:11:42 +0000 (14:11 +0200)
unbound.nix

index 0727edb4a87f7401362752e2fefe828f5ca85bde..c34b50fa11facc9dff1ead30abd61b5cc5786443 100644 (file)
@@ -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
+  ''
git clone https://git.99rst.org/PROJECT