devices.nas: switch to networkd

This commit is contained in:
陈浩南 2024-03-21 15:29:56 +08:00
parent 28f3976a48
commit dce1220b24
2 changed files with 18 additions and 15 deletions

View File

@ -44,7 +44,7 @@ inputs:
nixpkgs.march = "silvermont";
nix.substituters = [ "https://cache.nixos.org/" "https://nix-store.chn.moe" ];
kernel.patches = [ "cjktty" "lantian" ];
networking.hostname = "nas";
networking = { hostname = "nas"; networkd.dhcp = [ "enp3s0" ]; };
gui.preferred = false;
};
hardware = { cpus = [ "intel" ]; gpu.type = "intel"; };

View File

@ -3,6 +3,8 @@ inputs:
options.nixos.system.networking = let inherit (inputs.lib) mkOption types; in
{
hostname = mkOption { type = types.nonEmptyStr; };
networkManager.enable = mkOption
{ type = types.bool; default = inputs.config.nixos.system.networking.networkd.dhcp == []; };
networkd =
{
dhcp = mkOption { type = types.listOf types.nonEmptyStr; default = []; };
@ -12,20 +14,7 @@ inputs:
[
# general config
{
networking =
{
networkmanager =
{
enable = true;
# let networkmanager ignore the kernel command line `ip=xxx`
extraConfig =
''
[device]
keep-configuration=no
'';
};
hostName = networking.hostname;
};
networking.hostName = networking.hostname;
boot.kernel.sysctl =
{
"net.core.rmem_max" = 67108864;
@ -48,6 +37,20 @@ inputs:
"net.bridge.bridge-nf-call-arptables" = false;
};
}
# networkManager
(inputs.lib.mkIf networking.networkManager.enable
{
networking.networkmanager =
{
enable = true;
# let networkmanager ignore the kernel command line `ip=xxx`
extraConfig =
''
[device]
keep-configuration=no
'';
};
})
# networkd
(inputs.lib.mkIf (networking.networkd.dhcp != [])
{