Skip to content

Commit

Permalink
nixos/yggdrasil: rename "config" option to "settings"
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmry committed Aug 11, 2022
1 parent 3a11db5 commit 30df5b3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
19 changes: 13 additions & 6 deletions nixos/modules/services/networking/yggdrasil.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions nixos/tests/yggdrasil.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [ ];
};
Expand Down Expand Up @@ -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" ];
Expand Down

0 comments on commit 30df5b3

Please sign in to comment.