From 01e6204a96356d4128951921b55e93d36d46ffe7 Mon Sep 17 00:00:00 2001 From: a-kenji Date: Wed, 19 Feb 2025 14:05:12 +0700 Subject: [PATCH] clanModules/mycelium: Remove certain options for compatibility reasons Remove certain options for compatibility reasons We want to reintroduce them once we pass in `vars` through the inventory. --- clanModules/mycelium/README.md | 7 ---- clanModules/mycelium/roles/peer.nix | 55 ----------------------------- 2 files changed, 62 deletions(-) diff --git a/clanModules/mycelium/README.md b/clanModules/mycelium/README.md index c8039892a..989ac9d0f 100644 --- a/clanModules/mycelium/README.md +++ b/clanModules/mycelium/README.md @@ -24,14 +24,7 @@ mycelium.default = { "berlin" "munich" ]; - config = { - topLevelDomain = "m"; - openFirewall = true; - addHostedPublicNodes = true; - }; }; ``` This will add the machines named `berlin` and `munich` to the `mycelium` vpn. -And will also set the toplevel domain of the mycelium vpn to `m`, meaning the -machines are now reachable via `berlin.m` and `munich.m`. diff --git a/clanModules/mycelium/roles/peer.nix b/clanModules/mycelium/roles/peer.nix index 3e5de5b25..0fb890ac3 100644 --- a/clanModules/mycelium/roles/peer.nix +++ b/clanModules/mycelium/roles/peer.nix @@ -4,55 +4,10 @@ lib, ... }: -let - flake = config.clan.core.settings.directory; - machineName = config.clan.core.settings.machine.name; - - # Instances might be empty, if the module is not used via the inventory - # - # Type: { ${instanceName} :: { roles :: Roles } } - # Roles :: { ${role_name} :: { machines :: [string] } } - instances = config.clan.inventory.services.mycelium or { }; - - allPeers = lib.foldlAttrs ( - acc: _instanceName: instanceConfig: - acc - ++ ( - if (builtins.elem machineName instanceConfig.roles.peer.machines) then - instanceConfig.roles.peer.machines - else - [ ] - ) - ) [ ] instances; - allPeerConfigurations = lib.filterAttrs (n: _: builtins.elem n allPeers) flake.nixosConfigurations; - allPeersWithIp = - builtins.mapAttrs - (_: x: lib.removeSuffix "\n" x.config.clan.core.vars.generators.mycelium.files.ip.value) - ( - lib.filterAttrs ( - _: x: (builtins.tryEval x.config.clan.core.vars.generators.mycelium.files.ip.value).success - ) allPeerConfigurations - ); - - ips = lib.attrValues allPeersWithIp; - peers = lib.concatMap (ip: [ - "tcp://[${ip}]:9651" - "quic://[${ip}]:9651" - ]) ips; -in { options = { - clan.mycelium.topLevelDomain = lib.mkOption { - type = lib.types.str; - default = ""; - description = "Top level domain to reach hosts"; - }; clan.mycelium.openFirewall = lib.mkEnableOption "Open the firewall for mycelium"; clan.mycelium.addHostedPublicNodes = lib.mkEnableOption "Add hosted Public nodes"; - clan.mycelium.addHosts = lib.mkOption { - default = true; - description = "Add mycelium ip's to the host file"; - }; }; config.services.mycelium = { @@ -60,18 +15,8 @@ in addHostedPublicNodes = lib.mkDefault config.clan.mycelium.addHostedPublicNodes; openFirewall = lib.mkDefault config.clan.mycelium.openFirewall; keyFile = config.clan.core.vars.generators.mycelium.files.key.path; - inherit peers; }; - config.networking.hosts = lib.mkIf (config.clan.mycelium.addHosts) ( - lib.mapAttrs' ( - host: ip: - lib.nameValuePair ip ( - if (config.clan.mycelium.topLevelDomain == "") then [ host ] else [ "${host}.m" ] - ) - ) allPeersWithIp - ); - config.clan.core.vars.generators.mycelium = { files."key" = { }; files."ip".secret = false;