mirror of
https://github.com/CHN-beta/nixos.git
synced 2026-01-12 04:39:23 +08:00
modules.system.networking -> network
This commit is contained in:
@@ -19,7 +19,7 @@ inputs:
|
||||
};
|
||||
initrd.sshd = {};
|
||||
nixpkgs.march = "silvermont";
|
||||
networking = {};
|
||||
network = {};
|
||||
};
|
||||
hardware = { cpus = [ "intel" ]; gpu.type = "intel"; };
|
||||
services =
|
||||
|
||||
@@ -8,7 +8,7 @@ inputs:
|
||||
system =
|
||||
{
|
||||
nixpkgs.march = "cascadelake";
|
||||
networking =
|
||||
network =
|
||||
{
|
||||
static =
|
||||
{
|
||||
|
||||
@@ -7,7 +7,7 @@ inputs:
|
||||
system =
|
||||
{
|
||||
nixpkgs.march = "broadwell";
|
||||
networking =
|
||||
network =
|
||||
{
|
||||
static.eno2 =
|
||||
{ ip = "192.168.178.2"; mask = 24; gateway = "192.168.178.1"; dns = "192.168.178.1"; };
|
||||
|
||||
@@ -7,7 +7,7 @@ inputs:
|
||||
system =
|
||||
{
|
||||
nixpkgs.march = "broadwell";
|
||||
networking =
|
||||
network =
|
||||
{
|
||||
static =
|
||||
{
|
||||
|
||||
@@ -9,7 +9,7 @@ inputs:
|
||||
system =
|
||||
{
|
||||
nixpkgs.march = "skylake";
|
||||
networking =
|
||||
network =
|
||||
{
|
||||
static.eno2 = { ip = "192.168.178.1"; mask = 24; };
|
||||
wireless = [ "457的5G" ];
|
||||
|
||||
@@ -8,7 +8,7 @@ inputs:
|
||||
system =
|
||||
{
|
||||
nixpkgs.march = "znver3";
|
||||
networking =
|
||||
network =
|
||||
{
|
||||
static.enp58s0 =
|
||||
{ ip = "192.168.178.2"; mask = 24; gateway = "192.168.178.1"; dns = "192.168.178.1"; };
|
||||
|
||||
@@ -19,7 +19,7 @@ inputs:
|
||||
};
|
||||
nixpkgs.march = "haswell";
|
||||
initrd.sshd = {};
|
||||
networking =
|
||||
network =
|
||||
{
|
||||
bridge.nixvirt.interfaces = [ "eno1" ];
|
||||
static.nixvirt =
|
||||
|
||||
@@ -16,7 +16,7 @@ inputs:
|
||||
rollingRootfs = {};
|
||||
};
|
||||
nixpkgs.march = "znver4";
|
||||
networking = {};
|
||||
network = {};
|
||||
};
|
||||
hardware.cpus = [ "amd" ];
|
||||
services.sshd = {};
|
||||
|
||||
@@ -16,7 +16,7 @@ inputs:
|
||||
rollingRootfs = {};
|
||||
};
|
||||
nixpkgs.march = "znver4";
|
||||
networking = { dhcp = [ "nixvirt" ]; bridge.nixvirt.interfaces = [ "enp1s0" ]; };
|
||||
network = { dhcp = [ "nixvirt" ]; bridge.nixvirt.interfaces = [ "enp1s0" ]; };
|
||||
};
|
||||
hardware.cpus = [ "amd" ];
|
||||
services =
|
||||
|
||||
@@ -16,7 +16,7 @@ inputs:
|
||||
rollingRootfs = {};
|
||||
};
|
||||
nixpkgs.march = "haswell";
|
||||
networking = {};
|
||||
network = {};
|
||||
};
|
||||
hardware.cpus = [ "intel" ];
|
||||
services =
|
||||
|
||||
@@ -22,7 +22,7 @@ inputs:
|
||||
grub.installDevice = "/dev/disk/by-path/pci-0000:00:04.0";
|
||||
nixpkgs.march = "znver2";
|
||||
initrd.sshd = {};
|
||||
networking = {};
|
||||
network = {};
|
||||
};
|
||||
services =
|
||||
{
|
||||
|
||||
@@ -22,7 +22,7 @@ inputs:
|
||||
grub.installDevice = "/dev/disk/by-path/pci-0000:00:05.0-scsi-0:0:0:0";
|
||||
nixpkgs.march = "znver2";
|
||||
initrd.sshd = {};
|
||||
networking = {};
|
||||
network = {};
|
||||
};
|
||||
services =
|
||||
{
|
||||
|
||||
@@ -35,8 +35,8 @@ inputs:
|
||||
{
|
||||
assertions =
|
||||
[{
|
||||
assertion = inputs.config.nixos.system.networking != null;
|
||||
message = "initrd networking requires systemd networkd.";
|
||||
assertion = inputs.config.nixos.system.network != null;
|
||||
message = "initrd network requires systemd networkd.";
|
||||
}];
|
||||
boot =
|
||||
{
|
||||
@@ -46,7 +46,7 @@ inputs:
|
||||
# resolved does not work in initrd, causing network.target to fail
|
||||
services.resolved.enable = false;
|
||||
systemd.network =
|
||||
let inherit (inputs.config.nixos.system.networking) dhcp static bridge; in
|
||||
let inherit (inputs.config.nixos.system.network) dhcp static bridge; in
|
||||
let
|
||||
networks = inputs.lib.unique
|
||||
(
|
||||
|
||||
@@ -22,7 +22,7 @@ inputs:
|
||||
"sr_mod" "usbcore" "usbhid" "usbip-core" "usb-common" "usb_storage" "vhci-hcd" "virtio" "virtio_blk"
|
||||
"virtio_net" "virtio_ring" "virtio_scsi" "cryptd" "libaes"
|
||||
"ahci" "ata_piix" "nvme" "sdhci_acpi" "virtio_pci" "xhci_pci"
|
||||
# networking for nas
|
||||
# network for nas
|
||||
"igb"
|
||||
# disk for srv1
|
||||
"megaraid_sas"
|
||||
@@ -38,7 +38,7 @@ inputs:
|
||||
"igb"
|
||||
# touchscreen for one
|
||||
"pinctrl-tigerlake"
|
||||
# bridge networking
|
||||
# bridge network
|
||||
"bridge"
|
||||
]
|
||||
++ (inputs.lib.optionals (kernel.variant != "nixos") [ "crypto_simd" ]);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
inputs:
|
||||
{
|
||||
options.nixos.system.networking = let inherit (inputs.lib) mkOption types; in mkOption
|
||||
options.nixos.system.network = let inherit (inputs.lib) mkOption types; in mkOption
|
||||
{
|
||||
# null: use network-manager; otherwise use networkd
|
||||
type = types.nullOr (types.submodule { options =
|
||||
@@ -32,7 +32,7 @@ inputs:
|
||||
};});
|
||||
default = null;
|
||||
};
|
||||
config = let inherit (inputs.config.nixos.system) networking; in inputs.lib.mkMerge
|
||||
config = let inherit (inputs.config.nixos.system) network; in inputs.lib.mkMerge
|
||||
[
|
||||
# general config
|
||||
{
|
||||
@@ -61,7 +61,7 @@ inputs:
|
||||
};
|
||||
networking.nftables = { enable = true; flushRuleset = false; };
|
||||
}
|
||||
(inputs.localLib.mkConditional (networking == null)
|
||||
(inputs.localLib.mkConditional (network == null)
|
||||
{
|
||||
networking.networkmanager =
|
||||
{
|
||||
@@ -88,7 +88,7 @@ inputs:
|
||||
linkConfig.RequiredForOnline = "routable";
|
||||
};
|
||||
})
|
||||
networking.dhcp))
|
||||
network.dhcp))
|
||||
(builtins.listToAttrs (builtins.map
|
||||
(network:
|
||||
{
|
||||
@@ -103,7 +103,7 @@ inputs:
|
||||
dns = inputs.lib.mkIf (network.value.dns != null) [ network.value.dns ];
|
||||
};
|
||||
})
|
||||
(inputs.localLib.attrsToList networking.static)))
|
||||
(inputs.localLib.attrsToList network.static)))
|
||||
(builtins.listToAttrs (builtins.map
|
||||
(network:
|
||||
{
|
||||
@@ -115,7 +115,7 @@ inputs:
|
||||
linkConfig.RequiredForOnline = "routable";
|
||||
};
|
||||
})
|
||||
(inputs.localLib.attrsToList networking.bridge)))
|
||||
(inputs.localLib.attrsToList network.bridge)))
|
||||
(builtins.listToAttrs (builtins.concatLists (builtins.map
|
||||
(bridge: builtins.map
|
||||
(network:
|
||||
@@ -128,38 +128,38 @@ inputs:
|
||||
linkConfig.RequiredForOnline = "enslaved";
|
||||
};
|
||||
}) bridge.value.interfaces)
|
||||
(inputs.localLib.attrsToList networking.bridge))))
|
||||
(inputs.localLib.attrsToList network.bridge))))
|
||||
(builtins.listToAttrs (builtins.map
|
||||
(network: { name = "10-${network}"; value.networkConfig.IPMasquerade = "both"; })
|
||||
networking.masquerade))
|
||||
network.masquerade))
|
||||
];
|
||||
netdevs = builtins.listToAttrs (builtins.map
|
||||
(network: { name = "10-${network}"; value.netdevConfig = { Name = network; Kind = "bridge"; }; })
|
||||
(builtins.attrNames networking.bridge));
|
||||
(builtins.attrNames network.bridge));
|
||||
};
|
||||
networking =
|
||||
{
|
||||
useNetworkd = true;
|
||||
wireless = inputs.lib.mkIf (networking.wireless != null)
|
||||
wireless = inputs.lib.mkIf (network.wireless != null)
|
||||
{
|
||||
enable = true;
|
||||
networks = builtins.listToAttrs (builtins.map
|
||||
(network: { name = network; value.pskRaw = "ext:${network}"; })
|
||||
networking.wireless);
|
||||
network.wireless);
|
||||
secretsFile = inputs.config.sops.templates."wireless.env".path;
|
||||
};
|
||||
firewall.trustedInterfaces = networking.trust;
|
||||
firewall.trustedInterfaces = network.trust;
|
||||
};
|
||||
# dnsable dns fallback, use provided dns servers or no dns
|
||||
services.resolved.fallbackDns = [];
|
||||
sops = inputs.lib.mkIf (networking.wireless != null)
|
||||
sops = inputs.lib.mkIf (network.wireless != null)
|
||||
{
|
||||
templates."wireless.env".content = builtins.concatStringsSep "\n" (builtins.map
|
||||
(network: "${network}=${inputs.config.sops.placeholder."wireless/${network}"}")
|
||||
networking.wireless);
|
||||
network.wireless);
|
||||
secrets = builtins.listToAttrs (builtins.map
|
||||
(network: { name = "wireless/${network}"; value = {}; })
|
||||
networking.wireless);
|
||||
network.wireless);
|
||||
};
|
||||
})
|
||||
];
|
||||
Reference in New Issue
Block a user