mirror of
https://github.com/oddlama/nix-config.git
synced 2025-10-11 07:10:39 +02:00
feat: modularize link renaming
This commit is contained in:
parent
e8f50ab906
commit
14ef8ef877
10 changed files with 98 additions and 70 deletions
|
@ -10,8 +10,9 @@
|
|||
./system.nix
|
||||
./xdg.nix
|
||||
|
||||
../../../modules/wireguard.nix
|
||||
../../../modules/interface-naming.nix
|
||||
../../../modules/microvms.nix
|
||||
../../../modules/wireguard.nix
|
||||
];
|
||||
|
||||
home-manager = {
|
||||
|
|
|
@ -80,16 +80,5 @@ in {
|
|||
};
|
||||
|
||||
# Rename known network interfaces
|
||||
services.udev.packages =
|
||||
lib.mkIf ((nodeSecrets.networking.interfaces or {}) != {})
|
||||
(let
|
||||
interfaceNamesUdevRules = pkgs.writeTextFile {
|
||||
name = "interface-names-udev-rules";
|
||||
text = concatStringsSep "\n" (mapAttrsToList (
|
||||
interface: attrs: ''SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="${attrs.mac}", NAME:="${interface}"''
|
||||
)
|
||||
nodeSecrets.networking.interfaces);
|
||||
destination = "/etc/udev/rules.d/01-interface-names.rules";
|
||||
};
|
||||
in [interfaceNamesUdevRules]);
|
||||
extra.networking.renameInterfacesByMac = lib.mapAttrs (_: v: v.mac) (nodeSecrets.networking.interfaces or {});
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
optimise.automatic = true;
|
||||
gc = {
|
||||
automatic = true;
|
||||
dates = "biweekly";
|
||||
dates = "monthly";
|
||||
options = "--delete-older-than 90d";
|
||||
};
|
||||
# Define global flakes for this system
|
||||
|
|
|
@ -27,12 +27,12 @@
|
|||
boot.initrd.availableKernelModules = ["xhci_pci" "ahci" "nvme" "usbhid" "usb_storage" "sd_mod" "sdhci_pci" "r8169"];
|
||||
|
||||
extra.microvms = let
|
||||
macOffset = config.lib.net.mac.addPrivate nodeSecrets.networking.interfaces."wan-nic".mac;
|
||||
macOffset = config.lib.net.mac.addPrivate nodeSecrets.networking.interfaces.lan.mac;
|
||||
in {
|
||||
test = {
|
||||
autostart = true;
|
||||
mac = macOffset "00:00:00:00:00:01";
|
||||
macvtap = "wan";
|
||||
mac = macOffset "00:00:00:00:00:11";
|
||||
macvtap = "lan";
|
||||
system = "x86_64-linux";
|
||||
};
|
||||
};
|
||||
|
|
|
@ -1,12 +1,4 @@
|
|||
{
|
||||
config,
|
||||
inputs,
|
||||
lib,
|
||||
microvm,
|
||||
nixos-hardware,
|
||||
pkgs,
|
||||
...
|
||||
}: {
|
||||
imports = [
|
||||
../../../common/core
|
||||
|
||||
|
@ -14,15 +6,4 @@
|
|||
];
|
||||
|
||||
home-manager.users.root.home.minimal = true;
|
||||
|
||||
systemd.network.networks = {
|
||||
"10-wan" = {
|
||||
# TODO
|
||||
matchConfig.Name = "en*";
|
||||
DHCP = "yes";
|
||||
networkConfig.IPv6PrivacyExtensions = "kernel";
|
||||
dhcpV4Config.RouteMetric = 20;
|
||||
dhcpV6Config.RouteMetric = 20;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -13,24 +13,12 @@ in {
|
|||
|
||||
boot.initrd.systemd.network = {
|
||||
enable = true;
|
||||
networks."10-wan" = {
|
||||
DHCP = "yes";
|
||||
#address = [
|
||||
# "192.168.178.2/24"
|
||||
# "fd00::1/64"
|
||||
#];
|
||||
#gateway = [
|
||||
#];
|
||||
matchConfig.MACAddress = nodeSecrets.networking.interfaces."wan-nic".mac;
|
||||
networkConfig.IPv6PrivacyExtensions = "kernel";
|
||||
dhcpV4Config.RouteMetric = 20;
|
||||
dhcpV6Config.RouteMetric = 20;
|
||||
};
|
||||
networks = {inherit (config.systemd.network.networks) "10-wan";};
|
||||
};
|
||||
|
||||
systemd.network.netdevs."10-wan" = {
|
||||
systemd.network.netdevs."10-lan-self" = {
|
||||
netdevConfig = {
|
||||
Name = "wan";
|
||||
Name = "lan-self";
|
||||
Kind = "macvtap";
|
||||
};
|
||||
extraConfig = ''
|
||||
|
@ -41,23 +29,13 @@ in {
|
|||
|
||||
systemd.network.networks = {
|
||||
"10-lan" = {
|
||||
address = [net.lan.ipv4cidr net.lan.ipv6cidr];
|
||||
matchConfig.MACAddress = nodeSecrets.networking.interfaces.lan.mac;
|
||||
networkConfig = {
|
||||
IPForward = "yes";
|
||||
IPv6PrivacyExtensions = "kernel";
|
||||
};
|
||||
dhcpV4Config.RouteMetric = 10;
|
||||
dhcpV6Config.RouteMetric = 10;
|
||||
};
|
||||
"10-wan-nic" = {
|
||||
matchConfig.MACAddress = nodeSecrets.networking.interfaces."wan-nic".mac;
|
||||
extraConfig = ''
|
||||
[Network]
|
||||
MACVTAP=wan
|
||||
MACVTAP=lan-self
|
||||
'';
|
||||
};
|
||||
"11-wan" = {
|
||||
"10-wan" = {
|
||||
DHCP = "yes";
|
||||
#address = [
|
||||
# "192.168.178.2/24"
|
||||
|
@ -65,11 +43,22 @@ in {
|
|||
#];
|
||||
#gateway = [
|
||||
#];
|
||||
matchConfig.Name = "wan";
|
||||
matchConfig.MACAddress = nodeSecrets.networking.interfaces.wan.mac;
|
||||
networkConfig.IPv6PrivacyExtensions = "kernel";
|
||||
dhcpV4Config.RouteMetric = 20;
|
||||
dhcpV6Config.RouteMetric = 20;
|
||||
};
|
||||
"11-lan-self" = {
|
||||
address = [net.lan.ipv4cidr net.lan.ipv6cidr];
|
||||
matchConfig.Name = "lan-self";
|
||||
networkConfig = {
|
||||
IPForward = "yes";
|
||||
IPv6PrivacyExtensions = "kernel";
|
||||
ConfigureWithoutCarrier = true;
|
||||
};
|
||||
dhcpV4Config.RouteMetric = 10;
|
||||
dhcpV6Config.RouteMetric = 10;
|
||||
};
|
||||
};
|
||||
|
||||
networking.nftables.firewall = {
|
||||
|
|
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue