Move all nixos networking config to networking.nix, make networkmanager not configure ethernet if static-ip is set
This commit is contained in:
parent
e8c73318a1
commit
0c641b47ad
|
@ -152,6 +152,7 @@
|
|||
background = "pan-wire-3.png";
|
||||
};
|
||||
networking = mkNixOsNetworking {
|
||||
inherit pkgs;
|
||||
eth-interface = "enp0s31f6";
|
||||
static-ip = "192.168.0.199";
|
||||
};
|
||||
|
|
|
@ -39,7 +39,6 @@
|
|||
grub.devce = grub-device;
|
||||
} else throw "Please use either use-efi or use-grub = true";
|
||||
|
||||
networking.networkmanager.enable = true;
|
||||
|
||||
time.timeZone = "Europe/Stockholm";
|
||||
|
||||
|
@ -86,10 +85,6 @@
|
|||
|
||||
virtualisation.docker.enable = true;
|
||||
|
||||
networking.resolvconf.enable = true;
|
||||
networking.nameservers = [ "8.8.8.8" ];
|
||||
networking.resolvconf.dnsExtensionMechanism = false; # edns seems to be fucky with this enabled
|
||||
|
||||
nix.settings = {
|
||||
experimental-features = [ "nix-command" "flakes" ];
|
||||
auto-optimise-store = true;
|
||||
|
|
|
@ -1,16 +1,22 @@
|
|||
{
|
||||
pkgs,
|
||||
eth-interface ? "eth0",
|
||||
static-ip ? false, # false, or IPv4 address
|
||||
static-ip ? false, # false, or IPv4 address as string
|
||||
default-gateway ? "192.168.1.1",
|
||||
}:
|
||||
{
|
||||
networking = if static-ip != false then {
|
||||
defaultGateway = { address = default-gateway; interface = eth-interface; };
|
||||
useDHCP = false;
|
||||
interfaces.${eth-interface}.ipv4.addresses = [ {
|
||||
let static-ip-conf = if static-ip != false then {
|
||||
networking.defaultGateway = { address = default-gateway; interface = eth-interface; };
|
||||
networking.useDHCP = false;
|
||||
networking.interfaces.${eth-interface}.ipv4.addresses = [ {
|
||||
address = static-ip;
|
||||
prefixLength = 24;
|
||||
} ];
|
||||
} else {
|
||||
};
|
||||
networking.networkmanager.unmanaged = [eth-interface];
|
||||
} else {};
|
||||
in pkgs.lib.attrsets.recursiveUpdate static-ip-conf
|
||||
{
|
||||
networking.networkmanager.enable = true;
|
||||
networking.nameservers = [ "8.8.8.8" ];
|
||||
networking.resolvconf.enable = true;
|
||||
networking.resolvconf.dnsExtensionMechanism = false; # edns seems to be fucky with this enabled
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user