From: Yethal Date: Tue, 11 Mar 2025 17:44:50 +0000 (+0100) Subject: Add unbound config nix package X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=44d7516aeb81bc1f7d6282f6baff99c57305a289;p=stevenblack-hosts.git Add unbound config nix package --- diff --git a/flake.nix b/flake.nix index 27abbe1f3..342068f6b 100644 --- a/flake.nix +++ b/flake.nix @@ -52,6 +52,11 @@ python3Packages.requests ]; }; - }); + } + ); + + packages = forAllSystems (system: { + unbound = nixpkgsFor.${system}.callPackage ./unbound.nix { }; + }); }; } diff --git a/unbound.nix b/unbound.nix new file mode 100644 index 000000000..72551f221 --- /dev/null +++ b/unbound.nix @@ -0,0 +1,19 @@ +{ + stdenvNoCC, +}: +stdenvNoCC.mkDerivation { + name = "stevenblack-hosts-unbound"; + src = ./.; + + installPhase = + let + toUnboundConf = ''awk 'NF == 2 && $1 == "0.0.0.0" && $2 != "0.0.0.0" { printf "local-zone: \"%s\" always_nxdomain\n", $2 }'\''; + in + '' + mkdir $out + cat $src/hosts | ${toUnboundConf} > $out/hosts + for file in alternates/*/hosts; do + cat $file | ${toUnboundConf} > $out/$(basename $(dirname $file)) + done + ''; +}