refactor(#2363): single source of truth for DHCP pool size

Move the DHCP pool size constant out of the two separate definitions
(Nix literal + Rust const) into a shared data file: nix/dhcp-pool-size.

- nix/dhcp-pool-size: new file, contains '14'
- hive-gateway.nix: reads via builtins.readFile + toIntBase10
- lifecycle/mod.rs: parses via include_bytes! const block at compile time

Cargo automatically tracks include_bytes! as a file dependency so a
change to nix/dhcp-pool-size triggers recompilation without build.rs.
This commit is contained in:
atlas 2026-07-13 10:56:00 +02:00 committed by mara
commit 3068034463
3 changed files with 24 additions and 6 deletions

View file

@ -15,9 +15,11 @@ let
# Occupies the last dhcpPoolSize usable addresses of the subnet
# (e.g. .241-.254 on a /24). Agent containers use deterministic static
# IPs (lifecycle::agent_network_ip) and are excluded from this range
# by a remap in the Rust code. Must stay in sync with DHCP_POOL_SIZE
# in hive-c0re/src/lifecycle/mod.rs.
dhcpPoolSize = 14;
# by a remap in the Rust code.
#
# Single source of truth: `nix/dhcp-pool-size` (one integer).
# Rust reads it at compile time via `include_bytes!` in lifecycle/mod.rs.
dhcpPoolSize = lib.strings.toIntBase10 (lib.strings.trim (builtins.readFile ../dhcp-pool-size));
# IPv4 helpers — nix integers are 64-bit so all /0-/32 values are safe.
ipToInt =
ip: