hosts/ni/networking: add enable option

This commit is contained in:
Gabriel Arazas 2023-12-13 10:04:18 +08:00
parent b04a284489
commit 8e42fa92d0
No known key found for this signature in database
GPG Key ID: ADE0C41DAB221FCC
2 changed files with 51 additions and 21 deletions

View File

@ -27,6 +27,7 @@
hosts.ni = { hosts.ni = {
hardware.qol.enable = true; hardware.qol.enable = true;
networking.enable = true;
networking.setup = "networkmanager"; networking.setup = "networkmanager";
networking.wireguard.enable = true; networking.wireguard.enable = true;
}; };
@ -105,7 +106,6 @@
tools.enable = true; tools.enable = true;
setups.personal-webstorage.enable = true; setups.personal-webstorage.enable = true;
}; };
vpn.personal.enable = true;
}; };
# This is somewhat used for streaming games from it. # This is somewhat used for streaming games from it.

View File

@ -2,12 +2,13 @@
let let
hostCfg = config.hosts.ni; hostCfg = config.hosts.ni;
cfg = hostCfg.networking.setup; cfg = hostCfg.networking;
in in
{ {
options.hosts.ni.networking.setup = lib.mkOption { options.hosts.ni.networking = {
enable = lib.mkEnableOption "networking setup";
setup = lib.mkOption {
type = lib.types.enum [ "networkd" "networkmanager" ]; type = lib.types.enum [ "networkd" "networkmanager" ];
default = "networkmanager";
description = '' description = ''
Indicates the component of the network setup. In practice, you'll most Indicates the component of the network setup. In practice, you'll most
likely just use NetworkManager since it is what is being supported by likely just use NetworkManager since it is what is being supported by
@ -18,10 +19,39 @@ in
risk. risk.
::: :::
''; '';
default = "networkmanager";
example = "networkd"; example = "networkd";
}; };
};
config = lib.mkIf cfg.enable (lib.mkMerge [
{
# Put on your cloak, kid.
profiles.vpn.personal.enable = true;
# We'll go with a software firewall. We're mostly configuring it as if we're
# using a server even though the chances of that is pretty slim.
networking.nftables.enable = true;
networking.firewall.enable = true;
# Just supporting local systems, businesses, and business systems.
services.avahi = {
enable = true;
nssmdns = true;
publish = {
enable = true;
userServices = true;
};
};
# Your internal network.
services.resolved.domains = [
"~plover.foodogsquared.one"
"~0.27.172.in-addr.arpa"
"~0.28.172.in-addr.arpa"
];
}
config = lib.mkMerge [
(lib.mkIf (cfg.setup == "networkd") { (lib.mkIf (cfg.setup == "networkd") {
networking = { networking = {
usePredictableInterfaceNames = true; usePredictableInterfaceNames = true;
@ -44,12 +74,12 @@ in
systemd.network.enable = true; systemd.network.enable = true;
# Setting up the bond devices. # Setting up the bond devices.
systemd.networks."40-bond1-dev1" = { systemd.network.networks."40-bond1-dev1" = {
matchConfig.Name = "enp1s0"; matchConfig.Name = "enp1s0";
networkConfig.Bond = "bond1"; networkConfig.Bond = "bond1";
}; };
systemd.networks."40-bond1-dev2" = { systemd.network.networks."40-bond1-dev2" = {
matchConfig.Name = "wlp2s0"; matchConfig.Name = "wlp2s0";
networkConfig = { networkConfig = {
Bond = "bond1"; Bond = "bond1";
@ -58,11 +88,11 @@ in
}; };
# Creating the ethernet-wireless-network bond. # Creating the ethernet-wireless-network bond.
systemd.netdevs."40-bond1".netdevConfig = { systemd.network.netdevs."40-bond1".netdevConfig = {
Name = "bond1"; Name = "bond1";
Kind = "bond"; Kind = "bond";
}; };
systemd.networks."40-bond1" = { systemd.network.networks."40-bond1" = {
matchConfig.Name = "bond1"; matchConfig.Name = "bond1";
networkConfig.DHCP = "yes"; networkConfig.DHCP = "yes";
}; };
@ -93,5 +123,5 @@ in
interfaces = [ "enp1s0" "wlp2s0" ]; interfaces = [ "enp1s0" "wlp2s0" ];
}; };
}) })
]; ]);
} }