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 + ''; +}