Use runCommandLocal instead of mkDerivation, pipe instead of cat

This commit is contained in:
Bobbe
2026-03-24 15:59:11 +01:00
parent 44d7516aeb
commit f924014d99

View File

@@ -1,19 +1,13 @@
{
stdenvNoCC,
runCommandLocal,
}:
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
'';
}
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 alternates/*/hosts; do
${toUnboundConf} < $file > $out/$(basename $(dirname $file))
done
''