From 300c5c98c6e1558ec977c0f6f0b8a8af71fbd0e8 Mon Sep 17 00:00:00 2001 From: Emery Hemingway Date: Sun, 7 Aug 2022 13:21:22 -0500 Subject: [PATCH] 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 --- .../modules/services/networking/yggdrasil.nix | 19 +++++++++++++------ 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" ];