diff options
author | Emery Hemingway <ehmry@posteo.net> | 2022-08-07 13:21:22 -0500 |
---|---|---|
committer | ehmry <ehmry@posteo.net> | 2022-08-11 16:09:42 -0500 |
commit | 300c5c98c6e1558ec977c0f6f0b8a8af71fbd0e8 (patch) | |
tree | 433e4270487ac0d1d5571f5d709daa4d33d938b8 | |
parent | 2e7384b7dff4418bb800531190cc642313aa1c23 (diff) |
nixos/yggdrasil: rename "config" option to "settings"
Make this service consistent with rfc42.
https://github.com/NixOS/rfcs/blob/master/rfcs/0042-config-option.md
-rw-r--r-- | nixos/modules/services/networking/yggdrasil.nix | 19 | ||||
-rw-r--r-- | nixos/tests/yggdrasil.nix | 4 |
2 files changed, 15 insertions, 8 deletions
diff --git a/nixos/modules/services/networking/yggdrasil.nix b/nixos/modules/services/networking/yggdrasil.nix index 7a0b5b4d3d4c..81ed6d1dd566 100644 --- a/nixos/modules/services/networking/yggdrasil.nix +++ b/nixos/modules/services/networking/yggdrasil.nix @@ -4,16 +4,23 @@ let keysPath = "/var/lib/yggdrasil/keys.json"; cfg = config.services.yggdrasil; - configProvided = cfg.config != { }; + settingsProvided = cfg.settings != { }; configFileProvided = cfg.configFile != null; + format = pkgs.formats.json { }; in { + imports = [ + (mkRenamedOptionModule + [ "services" "yggdrasil" "config" ] + [ "services" "yggdrasil" "settings" ]) + ]; + options = with types; { services.yggdrasil = { enable = mkEnableOption "the yggdrasil system service"; - config = mkOption { - type = attrs; + settings = mkOption { + type = format.type; default = {}; example = { Peers = [ @@ -138,11 +145,11 @@ in { wantedBy = [ "multi-user.target" ]; preStart = - (if configProvided || configFileProvided || cfg.persistentKeys then + (if settingsProvided || configFileProvided || cfg.persistentKeys then "echo " - + (lib.optionalString configProvided - "'${builtins.toJSON cfg.config}'") + + (lib.optionalString settingsProvided + "'${builtins.toJSON cfg.settings}'") + (lib.optionalString configFileProvided "$(cat ${cfg.configFile})") + (lib.optionalString cfg.persistentKeys "$(cat ${keysPath})") + " | ${pkgs.jq}/bin/jq -s add | ${binYggdrasil} -normaliseconf -useconf" diff --git a/nixos/tests/yggdrasil.nix b/nixos/tests/yggdrasil.nix index b409d9ed7853..b60a0e6b06cc 100644 --- a/nixos/tests/yggdrasil.nix +++ b/nixos/tests/yggdrasil.nix @@ -42,7 +42,7 @@ in import ./make-test-python.nix ({ pkgs, ...} : { services.yggdrasil = { enable = true; - config = { + settings = { Listen = ["tcp://0.0.0.0:12345"]; MulticastInterfaces = [ ]; }; @@ -112,7 +112,7 @@ in import ./make-test-python.nix ({ pkgs, ...} : { services.yggdrasil = { enable = true; denyDhcpcdInterfaces = [ "ygg0" ]; - config = { + settings = { IfTAPMode = true; IfName = "ygg0"; MulticastInterfaces = [ "eth1" ]; |