From 65c76f5a6ac8fc04f70e7bba1e0f7d1a863e3692 Mon Sep 17 00:00:00 2001 From: Giulio De Pasquale Date: Fri, 12 May 2023 12:50:20 +0200 Subject: [PATCH] architect: Moved tailscale config to new network attribute set --- hosts/architect/tailscale.nix | 36 ++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/hosts/architect/tailscale.nix b/hosts/architect/tailscale.nix index 43dcab0..aaa5b14 100644 --- a/hosts/architect/tailscale.nix +++ b/hosts/architect/tailscale.nix @@ -1,24 +1,38 @@ { config, lib, ... }: let - network = import ./network.nix; - - ifname = "ts0"; + domain = "devs.giugl.io"; + # device.address device.hostname + generateDeviceStrings = devices: lib.concatStringsSep "\n" + (lib.mapAttrsToList (name: device: "${device.address} ${device.hostname}") devices); in { - architect.firewall.openUDP = [ config.services.tailscale.port ]; + architect = { + firewall.openUDP = [ config.services.tailscale.port ]; + + networks.tailscale = { + interface = "ts0"; + net = "100.64.0.0/10"; + + devices = { + architect = { address = "100.64.0.1"; hostname = "architect.${domain}"; }; + kmerr = { address = "100.64.0.2"; hostname = "kmerr.${domain}"; }; + chuck = { address = "100.64.0.4"; hostname = "chuck.${domain}"; }; + dodino = { address = "100.64.0.5"; hostname = "dodino.${domain}"; }; + manduria = { address = "100.64.0.6"; hostname = "manduria.${domain}"; }; + tommy = { address = "100.64.0.7"; hostname = "tommy.${domain}"; }; + ucsb-workstation = { address = "100.64.0.8"; hostname = "ucsb-workstation.${domain}"; }; + alfredo = { address = "100.64.0.9"; hostname = "alfredo.${domain}"; }; + }; + }; + }; services = { tailscale = { enable = true; - interfaceName = ifname; + interfaceName = config.architect.networks.tailscale.interface; }; }; - networking.extraHosts = '' - ${network.architect-ts} architect.devs.giugl.io - ${network.giuliopc-ts} kmerr.devs.giugl.io - ${network.dodino-ts} dodino.devs.giugl.io - ${network.giuliophone-ts} chuck.devs.giugl.io - ''; + networking.extraHosts = generateDeviceStrings config.architect.networks.tailscale.devices; }