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.
This commit is contained in:
a-kenji
2025-02-19 14:05:12 +07:00
committed by clan-bot
parent f102e17633
commit 01e6204a96
2 changed files with 0 additions and 62 deletions

View File

@@ -24,14 +24,7 @@ mycelium.default = {
"berlin" "berlin"
"munich" "munich"
]; ];
config = {
topLevelDomain = "m";
openFirewall = true;
addHostedPublicNodes = true;
};
}; };
``` ```
This will add the machines named `berlin` and `munich` to the `mycelium` vpn. 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`.

View File

@@ -4,55 +4,10 @@
lib, 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 = { 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.openFirewall = lib.mkEnableOption "Open the firewall for mycelium";
clan.mycelium.addHostedPublicNodes = lib.mkEnableOption "Add hosted Public nodes"; 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 = { config.services.mycelium = {
@@ -60,18 +15,8 @@ in
addHostedPublicNodes = lib.mkDefault config.clan.mycelium.addHostedPublicNodes; addHostedPublicNodes = lib.mkDefault config.clan.mycelium.addHostedPublicNodes;
openFirewall = lib.mkDefault config.clan.mycelium.openFirewall; openFirewall = lib.mkDefault config.clan.mycelium.openFirewall;
keyFile = config.clan.core.vars.generators.mycelium.files.key.path; 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 = { config.clan.core.vars.generators.mycelium = {
files."key" = { }; files."key" = { };
files."ip".secret = false; files."ip".secret = false;