Self-host your own digital island

bind remove journal file if zone has changed

Changed files
+11 -2
modules
services
dns
+11 -2
modules/services/dns/bind.nix
···
systemd.services.bind.preStart =
let ops =
let mapZones = zonename: zone:
-
"cp ${import ./zonefile.nix { inherit pkgs config lib zonename zone; }}/${zonename}" +
-
" ${config.services.bind.directory}/${zonename}";
+
let
+
zonefile = "${import ./zonefile.nix { inherit pkgs config lib zonename zone; }}/${zonename}";
+
path = "${config.services.bind.directory}/${zonename}";
+
in ''
+
if ! diff ${zonefile} ${path} > /dev/null; then
+
cp ${zonefile} ${path}
+
# remove journal file to avoid 'journal out of sync with zone'
+
# NB this will reset dynamic updates
+
rm -f ${path}.signed.jnl
+
fi
+
'';
in lib.attrsets.mapAttrsToList mapZones cfg.zones;
in builtins.concatStringsSep "\n" ops;
}