From 44d7516aeb81bc1f7d6282f6baff99c57305a289 Mon Sep 17 00:00:00 2001 From: Yethal <26117918+Yethal@users.noreply.github.com> Date: Tue, 11 Mar 2025 18:44:50 +0100 Subject: [PATCH] Add unbound config nix package --- flake.nix | 7 ++++++- unbound.nix | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 unbound.nix 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 + ''; +}