image/base-config: modernize with systemd.network

This commit is contained in:
Felix Buehler 2023-11-12 23:09:53 +01:00
parent b8a3f000ac
commit 2a3f606557

View file

@ -1,3 +1,4 @@
# based on: https://github.com/Mic92/dotfiles/blob/main/nixos/images/base-config.nix
{ lib { lib
, pkgs , pkgs
, config , config
@ -5,39 +6,40 @@
}: { }: {
system.stateVersion = config.system.nixos.version; system.stateVersion = config.system.nixos.version;
networking.firewall.enable = false; networking = {
firewall.enable = false;
services.resolved.enable = false; nameservers = [
networking.nameservers = [
# digital courage # digital courage
"46.182.19.48" "46.182.19.48"
"2a02:2970:1002::18" "2a02:2970:1002::18"
]; ];
networking.usePredictableInterfaceNames = false; usePredictableInterfaceNames = false;
systemd.network.enable = true; useNetworkd = true;
systemd.network.networks = };
systemd = {
network.enable = true;
network.networks =
lib.mapAttrs' lib.mapAttrs'
(num: _: (num: _:
lib.nameValuePair "eth${num}" { lib.nameValuePair "eth${num}" {
extraConfig = '' matchConfig.Name = "eth${num}";
[Match] networkConfig = {
Name = eth${num} DHCP = "yes";
LLMNR = true;
[Network] IPv4LLRoute = true;
DHCP = both LLDP = true;
LLMNR = true IPv6AcceptRA = true;
IPv4LL = true
LLDP = true
IPv6AcceptRA = true
IPv6Token = ::521a:c5ff:fefe:65d9
# used to have a stable address for zfs send # used to have a stable address for zfs send
Address = fd42:4492:6a6d:43:1::${num}/64 Address = "fd42:4492:6a6d:43:1::${num}/64";
};
[DHCP] dhcpConfig = {
UseHostname = false UseHostname = false;
RouteMetric = 512 RouteMetric = 512;
''; };
ipv6AcceptRAConfig.Token = "::521a:c5ff:fefe:65d9";
}) })
{ {
"0" = { }; "0" = { };
@ -45,17 +47,20 @@
"2" = { }; "2" = { };
"3" = { }; "3" = { };
}; };
};
imports = [ imports = [
../machines/core/core.nix ../machines/core/core.nix
../machines/core/nix.nix ../machines/core/nix.nix
]; ];
documentation.enable = lib.mkDefault false; documentation = {
documentation.doc.enable = lib.mkDefault false; enable = lib.mkDefault false;
documentation.info.enable = lib.mkDefault false; doc.enable = lib.mkDefault false;
documentation.nixos.enable = lib.mkDefault false; info.enable = lib.mkDefault false;
documentation.nixos.options.warningsAreErrors = false; nixos.enable = lib.mkDefault false;
nixos.options.warningsAreErrors = false;
};
# no auto-updates # no auto-updates
systemd.services.update-prefetch.enable = false; systemd.services.update-prefetch.enable = false;