feat: create shared extraHosts module with Tailscale IPs

- Create modules/network/extraHosts.nix with Tailscale IP mappings
- Replace hardcoded networking.extraHosts in all machine configs
- Add extraHosts module import to all machines
- Enable Tailscale service by default in the module
- Use Tailscale mesh network IPs for reliable connectivity
This commit is contained in:
Geir Okkenhaug Jerstad 2025-06-07 15:07:17 +00:00
parent fa2b84cf65
commit 2d3728f28b
5 changed files with 33 additions and 7 deletions

View file

@ -12,6 +12,9 @@
# Security modules
../../modules/security/ssh-keys.nix
# Network modules
../../modules/network/extraHosts.nix
# Hardware modules
../../modules/hardware/amd-workstation.nix
@ -45,8 +48,7 @@
path = "/boot";
}
];
};
# ZFS services for this machine
}; # ZFS services for this machine
services.zfs = {
autoScrub.enable = true;
trim.enable = true;

View file

@ -8,6 +8,7 @@
# Shared modules
../../modules/common/base.nix
../../modules/network/common.nix
../../modules/network/extraHosts.nix
../../modules/virtualization/podman.nix
../../modules/virtualization/libvirt.nix
../../modules/virtualization/incus.nix
@ -64,11 +65,6 @@
# Networking
networking.hostName = "grey-area";
networking.networkmanager.enable = true;
# Add hostname resolution for sleeper-service NFS server
networking.extraHosts = ''
10.0.0.8 sleeper-service
'';
# Set your time zone.
time.timeZone = "Europe/Oslo";

View file

@ -4,6 +4,7 @@
imports = [
./gandicloud.nix
../../modules/common/base.nix
../../modules/network/extraHosts.nix
../../modules/users/sma.nix
../../modules/security/ssh-keys.nix
];

View file

@ -5,6 +5,7 @@
../../modules/security/ssh-keys.nix
# Network configuration
./network-sleeper-service.nix
../../modules/network/extraHosts.nix
# Services
./nfs.nix
./services/transmission.nix

View file

@ -0,0 +1,26 @@
# Network hostname resolution module
# Provides consistent hostname-to-IP mapping across all home lab machines
# Uses Tailscale IPs for reliable connectivity across the mesh network
{ config, lib, ... }:
{
# Add hostname entries for all home lab machines using Tailscale IPs
networking.extraHosts = ''
# Home Lab Infrastructure (Tailscale mesh network)
100.109.28.53 congenital-optimist
100.81.15.84 sleeper-service
100.119.86.92 grey-area
100.96.189.104 reverse-proxy vps1
# Additional network devices
100.103.143.108 pihole
100.126.202.40 wordpresserver
'';
# Enable Tailscale by default for all machines using this module
services.tailscale = {
enable = true;
useRoutingFeatures = "client";
};
}