Add unbound config nix package

This commit is contained in:
Yethal
2025-03-11 18:44:50 +01:00
committed by Bobbe
parent 46c0aa9d8b
commit 44d7516aeb
2 changed files with 25 additions and 1 deletions

View File

@@ -52,6 +52,11 @@
python3Packages.requests
];
};
}
);
packages = forAllSystems (system: {
unbound = nixpkgsFor.${system}.callPackage ./unbound.nix { };
});
};
}

19
unbound.nix Normal file
View File

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