diff --git a/modules/nixos/yggdrasil/hosts.nix b/modules/nixos/yggdrasil/hosts.nix index ad59165..420a15b 100644 --- a/modules/nixos/yggdrasil/hosts.nix +++ b/modules/nixos/yggdrasil/hosts.nix @@ -21,7 +21,7 @@ let }; in { - flake.modules.nixos.core = + flake.modules.nixos.base = { config, ... }: { options.local = { @@ -29,7 +29,7 @@ in default = hosts.${config.networking.hostName}.address; }; prefix = lib.mkOption { - default = "3${builtins.substring 1 17 hosts."${config.networking.hostName}".address}"; + default = "3${builtins.substring 1 17 config.local.ip}"; }; }; }; diff --git a/modules/nixos/yggdrasil/network.nix b/modules/nixos/yggdrasil/network.nix index 3ced637..db6d686 100644 --- a/modules/nixos/yggdrasil/network.nix +++ b/modules/nixos/yggdrasil/network.nix @@ -45,14 +45,24 @@ in flake.modules.nixos.test = { pkgs, ... }: let - ygg = lib.getExe pkgs.yggdrasil; + yggdrasil = lib.getExe pkgs.yggdrasil; + config = pkgs.runCommandLocal "ygg-test-config" { } '' + ${yggdrasil} -genconf > $out + ''; + key = pkgs.runCommandLocal "ygg-test-key" { } '' + cat ${config} | ${yggdrasil} -useconf -exportkey > $out + ''; + address = pkgs.runCommandLocal "ygg-test-address-module" { } '' + mkdir $out + address=$(cat ${config} | ${yggdrasil} -useconf -address) + printf '"%s"' $address > $out/default.nix + ''; in { + local.ip = import "${address}"; services.yggdrasil.settings = { Peers = lib.mkForce [ ]; - PrivateKeyPath = lib.mkForce ( - pkgs.runCommandLocal "export-test-key" { } "${ygg} -genconf | ${ygg} -useconf -exportkey > $out" - ); + PrivateKeyPath = lib.mkForce key; }; }; }