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,57 +6,61 @@
}: { }: {
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 = };
lib.mapAttrs'
(num: _:
lib.nameValuePair "eth${num}" {
extraConfig = ''
[Match]
Name = eth${num}
[Network] systemd = {
DHCP = both network.enable = true;
LLMNR = true network.networks =
IPv4LL = true lib.mapAttrs'
LLDP = true (num: _:
IPv6AcceptRA = true lib.nameValuePair "eth${num}" {
IPv6Token = ::521a:c5ff:fefe:65d9 matchConfig.Name = "eth${num}";
# used to have a stable address for zfs send networkConfig = {
Address = fd42:4492:6a6d:43:1::${num}/64 DHCP = "yes";
LLMNR = true;
[DHCP] IPv4LLRoute = true;
UseHostname = false LLDP = true;
RouteMetric = 512 IPv6AcceptRA = true;
''; # used to have a stable address for zfs send
}) Address = "fd42:4492:6a6d:43:1::${num}/64";
{ };
"0" = { }; dhcpConfig = {
"1" = { }; UseHostname = false;
"2" = { }; RouteMetric = 512;
"3" = { }; };
}; ipv6AcceptRAConfig.Token = "::521a:c5ff:fefe:65d9";
})
{
"0" = { };
"1" = { };
"2" = { };
"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;