mirror of
https://github.com/ryan4yin/nix-config.git
synced 2026-05-22 22:46:56 +02:00
refactor: centrally manage the network configuration of all hosts in homelab
feat: new host - tailscalw-gw
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
#############################################################
|
||||
#
|
||||
# Tailscale Gateway(homelab subnet router) - a NixOS VM running on Proxmox
|
||||
#
|
||||
#############################################################
|
||||
let
|
||||
hostName = "tailscale-gw"; # Define your hostname.
|
||||
vars = import ../vars.nix;
|
||||
hostAddress = vars.networking.hostAddress.${hostName};
|
||||
in {
|
||||
imports = [
|
||||
./tailscale.nix
|
||||
];
|
||||
|
||||
# supported file systems, so we can mount any removable disks with these filesystems
|
||||
boot.supportedFilesystems = [
|
||||
"ext4"
|
||||
"btrfs"
|
||||
"xfs"
|
||||
"fat"
|
||||
"vfat"
|
||||
"exfat"
|
||||
];
|
||||
|
||||
networking = {
|
||||
inherit hostName;
|
||||
inherit (vars.networking) defaultGateway nameservers;
|
||||
|
||||
networkmanager.enable = false;
|
||||
interfaces.ens18 = {
|
||||
useDHCP = false;
|
||||
ipv4.addresses = [hostAddress];
|
||||
};
|
||||
};
|
||||
|
||||
# This value determines the NixOS release from which the default
|
||||
# settings for stateful data, like file locations and database versions
|
||||
# on your system were taken. It‘s perfectly fine and recommended to leave
|
||||
# this value at the release version of the first install of this system.
|
||||
# Before changing this value read the documentation for this option
|
||||
# (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
|
||||
system.stateVersion = "23.11"; # Did you read the comment?
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
{
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
# =============================================================
|
||||
#
|
||||
# Tailscale - your own private network(VPN) that uses WireGuard
|
||||
#
|
||||
# It's open souce and free for personal use,
|
||||
# and it's really easy to setup and use.
|
||||
# Tailscale has great client coverage for Linux, windows, Mac, android, and iOS.
|
||||
# Tailscale is more mature and stable compared to other alternatives such as netbird/netmaker.
|
||||
# Maybe I'll give netbird/netmaker a try when they are more mature, but for now, I'm sticking with Tailscale.
|
||||
#
|
||||
# How to use:
|
||||
# 1. Create a Tailscale account at https://login.tailscale.com
|
||||
# 2. Login via `tailscale login`
|
||||
# 3. join into your Tailscale network via `tailscale up --advertise-routes 192.168.5.0/24`
|
||||
# 4. If you prefer automatic connection to Tailscale, use the `authKeyFile` option` in the config below.
|
||||
#
|
||||
# Status Data:
|
||||
# `journalctl -u tailscaled` shows tailscaled's logs
|
||||
# logs indicate that tailscale store its data in /var/lib/tailscale
|
||||
# which is already persistent across reboots(via impermanence.nix)
|
||||
#
|
||||
# References:
|
||||
# https://github.com/NixOS/nixpkgs/blob/nixos-23.11/nixos/modules/services/networking/tailscale.nix
|
||||
#
|
||||
# =============================================================
|
||||
{
|
||||
# make the tailscale command usable to users
|
||||
environment.systemPackages = [pkgs.tailscale];
|
||||
|
||||
# enable the tailscale service
|
||||
services.tailscale = {
|
||||
enable = true;
|
||||
port = 41641;
|
||||
interfaceName = "tailscale0";
|
||||
# allow the Tailscale UDP port through the firewall
|
||||
openFirewall = true;
|
||||
useRoutingFeatures = "server";
|
||||
extraUpFlags = "--advertise-routes 192.168.5.0/24";
|
||||
# authKeyFile = "/var/lib/tailscale/authkey";
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user