From 048174619831d15d9b85107c6514ef084b3fa3ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Wed, 6 Mar 2024 09:43:50 +0100 Subject: [PATCH] drop meshnamed from repository It's not super useful and we can always add it back later if we need it. --- checks/flake-module.nix | 1 - checks/meshnamed/default.nix | 21 ----- clanModules/deltachat.nix | 4 +- nixosModules/clanCore/default.nix | 1 - nixosModules/clanCore/meshnamed/default.nix | 84 -------------------- nixosModules/clanCore/zerotier/default.nix | 8 -- nixosModules/clanCore/zerotier/generate.py | 8 -- pkgs/clan-cli/tests/test_secrets_generate.py | 2 - pkgs/flake-module.nix | 1 - pkgs/installer/flake-module.nix | 24 ++++-- pkgs/meshname/default.nix | 30 ------- 11 files changed, 19 insertions(+), 165 deletions(-) delete mode 100644 checks/meshnamed/default.nix delete mode 100644 nixosModules/clanCore/meshnamed/default.nix delete mode 100644 pkgs/meshname/default.nix diff --git a/checks/flake-module.nix b/checks/flake-module.nix index af78f7ac..22a5e66d 100644 --- a/checks/flake-module.nix +++ b/checks/flake-module.nix @@ -18,7 +18,6 @@ secrets = import ./secrets nixosTestArgs; container = import ./container nixosTestArgs; deltachat = import ./deltachat nixosTestArgs; - meshnamed = import ./meshnamed nixosTestArgs; zt-tcp-relay = import ./zt-tcp-relay nixosTestArgs; borgbackup = import ./borgbackup nixosTestArgs; syncthing = import ./syncthing nixosTestArgs; diff --git a/checks/meshnamed/default.nix b/checks/meshnamed/default.nix deleted file mode 100644 index fa62b4e1..00000000 --- a/checks/meshnamed/default.nix +++ /dev/null @@ -1,21 +0,0 @@ -(import ../lib/container-test.nix) ({ pkgs, ... }: { - name = "meshnamed"; - - nodes.machine = { self, ... }: { - imports = [ - self.nixosModules.clanCore - { - clanCore.machineName = "machine"; - clan.networking.meshnamed.networks.vpn.subnet = "fd43:7def:4b50:28d0:4e99:9347:3035:17ef/88"; - clanCore.clanDir = ./.; - } - ]; - }; - testScript = '' - start_all() - machine.wait_for_unit("meshnamed") - out = machine.succeed("${pkgs.dnsutils}/bin/dig AAAA foo.7vbx332lkaunatuzsndtanix54.vpn @meshnamed +short") - print(out) - assert out.strip() == "fd43:7def:4b50:28d0:4e99:9347:3035:17ef" - ''; -}) diff --git a/clanModules/deltachat.nix b/clanModules/deltachat.nix index fe519ec3..771068a1 100644 --- a/clanModules/deltachat.nix +++ b/clanModules/deltachat.nix @@ -4,9 +4,7 @@ services.maddy = let - # FIXME move this to public setting - meshname = config.clanCore.secrets.zerotier.facts.zerotier-meshname.value or null; - domain = if meshname == null then "${config.clanCore.machineName}.local" else "${meshname}.vpn"; + domain = "${config.clanCore.machineName}.local"; in { enable = true; diff --git a/nixosModules/clanCore/default.nix b/nixosModules/clanCore/default.nix index c0158de4..a8c3e304 100644 --- a/nixosModules/clanCore/default.nix +++ b/nixosModules/clanCore/default.nix @@ -3,7 +3,6 @@ ./backups.nix ./manual.nix ./imports.nix - ./meshnamed ./metadata.nix ./networking.nix ./nix-settings.nix diff --git a/nixosModules/clanCore/meshnamed/default.nix b/nixosModules/clanCore/meshnamed/default.nix deleted file mode 100644 index 2d6eff78..00000000 --- a/nixosModules/clanCore/meshnamed/default.nix +++ /dev/null @@ -1,84 +0,0 @@ -{ config, lib, pkgs, ... }: -let - cfg = config.clan.networking.meshnamed; -in -{ - options.clan.networking.meshnamed = { - enable = (lib.mkEnableOption "meshnamed") // { - default = config.clan.networking.meshnamed.networks != { }; - }; - listenAddress = lib.mkOption { - type = lib.types.str; - default = "fd66:29e9:f422:8dfe:beba:68ec:bd09:7876"; - description = lib.mdDoc '' - The address to listen on. - ''; - }; - networks = lib.mkOption { - default = { }; - type = lib.types.attrsOf (lib.types.submodule ({ name, ... }: { - options = { - name = lib.mkOption { - default = name; - type = lib.types.str; - example = "my-network"; - description = lib.mdDoc '' - The name of the network. - ''; - }; - subnet = lib.mkOption { - type = lib.types.str; - example = "fd43:7def:4b50:28d0:4e99:9347:3035:17ef/88"; - description = lib.mdDoc '' - The subnet to use for the mesh network. - ''; - }; - }; - })); - }; - }; - config = lib.mkIf config.clan.networking.meshnamed.enable { - # we assign this random source address to bind meshnamed to. - systemd.network.netdevs."08-meshnamed" = { - netdevConfig = { - Name = "meshnamed"; - Kind = "dummy"; - }; - }; - systemd.network.networks."08-meshnamed" = { - matchConfig.Name = "meshnamed"; - networkConfig = { - Address = [ "${cfg.listenAddress}/128" ]; - DNS = [ config.clan.networking.meshnamed.listenAddress ]; - Domains = [ "~${lib.concatMapStringsSep "," (network: network.name) (builtins.attrValues config.clan.networking.meshnamed.networks)}" ]; - }; - }; - - # for convenience, so we can debug with dig - networking.extraHosts = '' - ${cfg.listenAddress} meshnamed - ''; - - networking.networkmanager.unmanaged = [ "interface-name:meshnamed" ]; - - systemd.services.meshnamed = - let - networks = lib.concatMapStringsSep "," (network: "${network.name}=${network.subnet}") - (builtins.attrValues config.clan.networking.meshnamed.networks); - in - { - # fix container test - after = [ "network.target" ] ++ lib.optional config.boot.isContainer "sys-devices-virtual-net-meshnamed.device"; - bindsTo = lib.optional (!config.boot.isContainer) "sys-devices-virtual-net-meshnamed.device"; - wantedBy = [ "multi-user.target" ]; - serviceConfig = { - Type = "simple"; - ExecStart = "${pkgs.callPackage ../../../pkgs/meshname/default.nix { }}/bin/meshnamed -networks ${networks} -listenaddr [${cfg.listenAddress}]:53"; - - # to bind port 53 - AmbientCapabilities = [ "CAP_NET_BIND_SERVICE" ]; - DynamicUser = true; - }; - }; - }; -} diff --git a/nixosModules/clanCore/zerotier/default.nix b/nixosModules/clanCore/zerotier/default.nix index 90d5f53e..719635aa 100644 --- a/nixosModules/clanCore/zerotier/default.nix +++ b/nixosModules/clanCore/zerotier/default.nix @@ -87,14 +87,10 @@ in # having to re-import nixpkgs. services.zerotierone.package = lib.mkDefault (pkgs.zerotierone.overrideAttrs (_old: { meta = { }; })); }) - (lib.mkIf ((facts.zerotier-meshname.value or null) != null) { - environment.etc."zerotier/hostname".text = "${facts.zerotier-meshname.value}.vpn"; - }) (lib.mkIf ((facts.zerotier-ip.value or null) != null) { environment.etc."zerotier/ip".text = facts.zerotier-ip.value; }) (lib.mkIf (cfg.networkId != null) { - clan.networking.meshnamed.networks.vpn.subnet = cfg.subnet; systemd.network.networks."09-zerotier" = { matchConfig.Name = "zt*"; @@ -174,14 +170,12 @@ in # we generate the zerotier code manually for the controller, since it's part of the bootstrap command clanCore.secrets.zerotier = { facts.zerotier-ip = { }; - facts.zerotier-meshname = { }; facts.zerotier-network-id = { }; secrets.zerotier-identity-secret = { }; generator.path = [ config.services.zerotierone.package pkgs.fakeroot pkgs.python3 ]; generator.script = '' python3 ${./generate.py} --mode network \ --ip "$facts/zerotier-ip" \ - --meshname "$facts/zerotier-meshname" \ --identity-secret "$secrets/zerotier-identity-secret" \ --network-id "$facts/zerotier-network-id" ''; @@ -193,13 +187,11 @@ in (lib.mkIf (!cfg.controller.enable && cfg.networkId != null) { clanCore.secrets.zerotier = { facts.zerotier-ip = { }; - facts.zerotier-meshname = { }; secrets.zerotier-identity-secret = { }; generator.path = [ config.services.zerotierone.package pkgs.python3 ]; generator.script = '' python3 ${./generate.py} --mode identity \ --ip "$facts/zerotier-ip" \ - --meshname "$facts/zerotier-meshname" \ --identity-secret "$secrets/zerotier-identity-secret" \ --network-id ${cfg.networkId} ''; diff --git a/nixosModules/clanCore/zerotier/generate.py b/nixosModules/clanCore/zerotier/generate.py index 027ed78b..d6b587ff 100644 --- a/nixosModules/clanCore/zerotier/generate.py +++ b/nixosModules/clanCore/zerotier/generate.py @@ -1,5 +1,4 @@ import argparse -import base64 import contextlib import ipaddress import json @@ -198,17 +197,12 @@ def compute_zerotier_ip(network_id: str, identity: Identity) -> ipaddress.IPv6Ad return ipaddress.IPv6Address(bytes(addr_parts)) -def compute_zerotier_meshname(ip: ipaddress.IPv6Address) -> str: - return base64.b32encode(ip.packed)[0:26].decode("ascii").lower() - - def main() -> None: parser = argparse.ArgumentParser() parser.add_argument( "--mode", choices=["network", "identity"], required=True, type=str ) parser.add_argument("--ip", type=Path, required=True) - parser.add_argument("--meshname", type=Path, required=True) parser.add_argument("--identity-secret", type=Path, required=True) parser.add_argument("--network-id", type=str, required=False) args = parser.parse_args() @@ -227,11 +221,9 @@ def main() -> None: case _: raise ValueError(f"unknown mode {args.mode}") ip = compute_zerotier_ip(network_id, identity) - meshname = compute_zerotier_meshname(ip) args.identity_secret.write_text(identity.private) args.ip.write_text(ip.compressed) - args.meshname.write_text(meshname) if __name__ == "__main__": diff --git a/pkgs/clan-cli/tests/test_secrets_generate.py b/pkgs/clan-cli/tests/test_secrets_generate.py index fc4b21ca..4dd7f9a6 100644 --- a/pkgs/clan-cli/tests/test_secrets_generate.py +++ b/pkgs/clan-cli/tests/test_secrets_generate.py @@ -73,5 +73,3 @@ def test_generate_secret( assert has_secret(test_flake_with_core.path, "vm2-zerotier-identity-secret") ip = machine_get_fact(test_flake_with_core.path, "vm1", "zerotier-ip") assert ipaddress.IPv6Address(ip).is_private - meshname = machine_get_fact(test_flake_with_core.path, "vm1", "zerotier-meshname") - assert len(meshname) == 26 diff --git a/pkgs/flake-module.nix b/pkgs/flake-module.nix index 8624aab0..771b4ee2 100644 --- a/pkgs/flake-module.nix +++ b/pkgs/flake-module.nix @@ -14,7 +14,6 @@ inherit (config.packages) tea-create-pr; }; pending-reviews = pkgs.callPackage ./pending-reviews { }; - meshname = pkgs.callPackage ./meshname { }; } // lib.optionalAttrs pkgs.stdenv.isLinux { wayland-proxy-virtwl = pkgs.callPackage ./wayland-proxy-virtwl { }; waypipe = pkgs.waypipe.overrideAttrs diff --git a/pkgs/installer/flake-module.nix b/pkgs/installer/flake-module.nix index b4a3564d..0e985378 100644 --- a/pkgs/installer/flake-module.nix +++ b/pkgs/installer/flake-module.nix @@ -1,19 +1,31 @@ { self, lib, ... }: let - installer = lib.nixosSystem { - pkgs = self.inputs.nixpkgs.legacyPackages.x86_64-linux; - system = "x86_64-linux"; - modules = [ + installerModule = { config, pkgs, ... }: { + imports = [ self.nixosModules.installer self.nixosModules.hidden-ssh-announce self.inputs.nixos-generators.nixosModules.all-formats self.inputs.disko.nixosModules.disko - ({ config, ... }: { system.stateVersion = config.system.nixos.version; }) ]; + + system.stateVersion = config.system.nixos.version; + nixpkgs.pkgs = self.inputs.nixpkgs.legacyPackages.x86_64-linux; + }; + + installer = lib.nixosSystem { modules = [ installerModule ]; }; + + clan = self.lib.buildClan { + clanName = "clan-core"; + directory = self; + machines.installer = installerModule; }; in { - flake.packages.x86_64-linux.install-iso = self.inputs.disko.lib.makeDiskImages { nixosConfig = installer; }; + flake.packages.x86_64-linux.install-iso = self.inputs.disko.lib.makeDiskImages { + nixosConfig = installer; + }; + flake.nixosConfigurations = clan.nixosConfigurations; + flake.clanInternals = clan.clanInternals; flake.apps.x86_64-linux.install-vm.program = installer.config.formats.vm.outPath; flake.apps.x86_64-linux.install-vm-nogui.program = installer.config.formats.vm-nogui.outPath; } diff --git a/pkgs/meshname/default.nix b/pkgs/meshname/default.nix deleted file mode 100644 index 6520b79f..00000000 --- a/pkgs/meshname/default.nix +++ /dev/null @@ -1,30 +0,0 @@ -{ lib -, buildGoModule -, fetchFromGitHub -}: - -buildGoModule { - pname = "meshname"; - version = "unstable-2023-11-08"; - - src = fetchFromGitHub { - owner = "Mic92"; - repo = "meshname"; - rev = "9b11879d63ac02b0df59960f47063aefc1baf176"; - hash = "sha256-oK2fKxCSonWs87s7BRdLO8GRm5MCfQNaJE7AoaH6K/c="; - }; - - subPackages = [ "cmd/meshnamed" ]; - - vendorHash = "sha256-kiNxB2R3Z6Z/Resr3r4jKCImVhyoOY55dEiV+JRUjDk="; - - ldflags = [ "-s" "-w" ]; - - meta = with lib; { - description = "Meshname, a universal naming system for all IPv6-based mesh networks, including CJDNS and Yggdrasil"; - homepage = "https://github.com/Mic92/meshname"; - license = licenses.mit; - maintainers = with maintainers; [ mic92 ]; - mainProgram = "meshnamed"; - }; -}