about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2025-04-01 15:00:03 +0200
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2025-04-01 15:00:03 +0200
commit68fd599dee4cd39ffd0f12f5ec468694307af668 (patch)
tree432264a3a4d21d614d11332a925cb111d2cacd8f
parenttests/dns: Avoid tracing the name-server interfaces (diff)
downloadnixos-server-68fd599dee4cd39ffd0f12f5ec468694307af668.zip
zones/vhack.eu: Make it obvious, that the serial number must be changed
The comment alone would probably suffice, but having a convenient function
that makes it obvious *what* part of the serial number you are actually
supposed to change seems quite useful, when trying to reduce the
possibilities of forgetting it.
-rw-r--r--hosts/by-name/server2/configuration.nix4
-rw-r--r--hosts/by-name/server3/configuration.nix4
-rw-r--r--zones/default.nix4
-rw-r--r--zones/vhack.eu/zone.nix40
4 files changed, 44 insertions, 8 deletions
diff --git a/hosts/by-name/server2/configuration.nix b/hosts/by-name/server2/configuration.nix
index 7f0502d..10bbb71 100644
--- a/hosts/by-name/server2/configuration.nix
+++ b/hosts/by-name/server2/configuration.nix
@@ -1,4 +1,4 @@
-{config, ...}: {
+{config, lib, ...}: {
   imports = [
     ./networking.nix # network configuration that just works
     ./hardware.nix
@@ -33,7 +33,7 @@
         "185.16.61.132"
         "2a03:4000:a:106::1"
       ];
-      zones = import ../../../zones {};
+      zones = import ../../../zones {inherit lib;};
     };
     etesync = {
       enable = true;
diff --git a/hosts/by-name/server3/configuration.nix b/hosts/by-name/server3/configuration.nix
index 9ad73ea..a89e047 100644
--- a/hosts/by-name/server3/configuration.nix
+++ b/hosts/by-name/server3/configuration.nix
@@ -1,4 +1,4 @@
-{...}: {
+{lib, ...}: {
   imports = [
     ./networking.nix # network configuration that just works
     ./hardware.nix
@@ -18,7 +18,7 @@
         "92.60.38.179"
         "2a03:4000:33:25b::4f4e"
       ];
-      zones = import ../../../zones {};
+      zones = import ../../../zones {inherit lib;};
     };
     fail2ban.enable = true;
     nix-sync = {
diff --git a/zones/default.nix b/zones/default.nix
index cde6def..babb531 100644
--- a/zones/default.nix
+++ b/zones/default.nix
@@ -1,3 +1,3 @@
-{...}: {
-  "vhack.eu" = import ./vhack.eu/zone.nix {};
+{lib, ...}: {
+  "vhack.eu" = import ./vhack.eu/zone.nix {inherit lib;};
 }
diff --git a/zones/vhack.eu/zone.nix b/zones/vhack.eu/zone.nix
index 4897f53..ad4f728 100644
--- a/zones/vhack.eu/zone.nix
+++ b/zones/vhack.eu/zone.nix
@@ -1,8 +1,44 @@
-{...}: {
+{lib, ...}: let
+  /*
+  Computes a reasonable value for the DNS serial number from the date of last change
+  and the iteration of that day.
+
+  # Type
+
+  mkSerial :: Number -> Number -> Number -> Number -> Number
+
+  # Arguments
+
+  year
+  : The year of the last change in the format YYYY.
+
+  month
+  : The month of the last change in the format MM.
+
+  day
+  : The day of the last change in the format DD.
+
+  iteration
+  : The number of change on that day. The format should be CC (assuming there are less
+    than 100 changes happening on a day) .
+
+  # Examples
+
+  mkSerial 2025 04 01 01
+  => 2025040101
+  */
+  mkSerial = year: month: day: iteration: let
+    n2 = lib.strings.fixedWidthNumber 2;
+    n4 = lib.strings.fixedWidthNumber 4;
+  in
+    lib.strings.toIntBase10 "${n4 year}${n2 month}${n2 day}${n2 iteration}";
+in {
   SOA = {
     nameServer = "name-server.foss-syndicate.org.";
     adminEmail = "dns-admin@foss-syndicate.org";
-    serial = 2025031001;
+    # NOTE(@bpeetz): ALWAYS change the serial number, when you change something in the
+    # zone file! <2025-04-01>
+    serial = mkSerial 2025 04 01 01;
   };
   useOrigin = false;