diff --git a/nix/vm-tests/wg-hive.nix b/nix/vm-tests/wg-hive.nix index a5dfcbfc3..44b3c44d4 100644 --- a/nix/vm-tests/wg-hive.nix +++ b/nix/vm-tests/wg-hive.nix @@ -2,10 +2,10 @@ # Unlike ../module-eval, which only reads the rendered `networking.wireguard` # options, this boots both hosts and sends packets. # -# Keys are minted by a throwaway derivation at build time and nothing is -# committed. The module takes peer public keys as eval-time strings -# (`swarm.hives..wireguardPublicKey`), so they are read back from -# the derivation's output. +# Keys are derived from a fixed per-host seed, so every store builds the +# same bytes and nothing is committed. The module takes peer public keys +# as eval-time strings (`swarm.hives..wireguardPublicKey`), so they +# are read back from the derivation's output. { pkgs, self, @@ -13,11 +13,19 @@ let mkKey = name: - pkgs.runCommand "wg-hive-test-key-${name}" { nativeBuildInputs = [ pkgs.wireguard-tools ]; } '' - mkdir $out - wg genkey > $out/private - wg pubkey < $out/private > $out/public - ''; + pkgs.runCommand "wg-hive-test-key-${name}" + { + nativeBuildInputs = [ + pkgs.wireguard-tools + pkgs.openssl + ]; + } + '' + # Test-only key: base64 of sha256(seed); wg clamps the scalar itself. + mkdir $out + printf '%s' 'hyperhive-wg-hive-test-${name}' | openssl dgst -sha256 -binary | base64 > $out/private + wg pubkey < $out/private > $out/public + ''; keys = { h1 = mkKey "h1"; h2 = mkKey "h2";