2023-06-11 23:09:59 +02:00
|
|
|
{
|
2024-03-02 22:05:30 +01:00
|
|
|
pkgs,
|
|
|
|
lib,
|
|
|
|
inputs',
|
|
|
|
secret,
|
|
|
|
notnft,
|
|
|
|
...
|
|
|
|
}: let
|
|
|
|
inherit
|
|
|
|
(lib)
|
|
|
|
concatStringsSep
|
|
|
|
;
|
|
|
|
in {
|
2023-09-28 10:31:25 +02:00
|
|
|
systemd.network.enable = true;
|
2023-06-11 23:09:59 +02:00
|
|
|
networking = {
|
|
|
|
hostName = "omen";
|
2023-09-28 10:31:25 +02:00
|
|
|
|
2023-06-11 23:09:59 +02:00
|
|
|
hostId = "10c7ffc5";
|
|
|
|
|
2024-03-02 22:05:30 +01:00
|
|
|
nameservers = [(secret.network.ips.blowhole.ip or "")];
|
2023-09-28 10:31:25 +02:00
|
|
|
|
|
|
|
firewall.enable = false;
|
2023-06-11 23:09:59 +02:00
|
|
|
|
|
|
|
wireguard.interfaces."wg0" =
|
2024-03-02 22:05:30 +01:00
|
|
|
secret.wireguard."omen" or {privateKey = "";};
|
2023-10-29 17:51:04 +01:00
|
|
|
useDHCP = false;
|
2023-06-11 23:09:59 +02:00
|
|
|
};
|
|
|
|
|
2023-09-28 10:31:25 +02:00
|
|
|
services.networkd-dispatcher = {
|
|
|
|
enable = true;
|
|
|
|
rules.wlan-eth-switch = {
|
2024-03-02 22:05:30 +01:00
|
|
|
onState = ["no-carrier" "configured"];
|
2023-09-28 10:31:25 +02:00
|
|
|
script = ''
|
|
|
|
#!${pkgs.runtimeShell}
|
|
|
|
export PATH=$PATH:${pkgs.iwd}/bin
|
|
|
|
echo "entered state: '$STATE' on interface '$IFACE' with IPs '$IP_ADDRS'"
|
|
|
|
|
|
|
|
case $IFACE in
|
|
|
|
eth0)
|
2023-10-21 17:46:17 +02:00
|
|
|
echo $IP_ADDRS | ${lib.getExe' pkgs.grepcidr "grepcidr"} ${secret.network.networks.home.amsterdam or ""} > /dev/null
|
2023-09-28 10:31:25 +02:00
|
|
|
home_net=$?
|
|
|
|
|
|
|
|
case $STATE in
|
|
|
|
no-carrier)
|
|
|
|
if [ "$(iwctl station wlan0 show | grep -i State | tr -s ' ' | cut -f 3 -d ' ')" == "disconnected" ] ; then
|
|
|
|
iwctl device wlan0 set-property Powered off
|
|
|
|
iwctl device wlan0 set-property Powered on
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
configured)
|
|
|
|
if [ "$home_net" == "0" ] ; then
|
|
|
|
iwctl station wlan0 disconnect
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.network.links."50-eth0" = {
|
2023-10-21 17:46:17 +02:00
|
|
|
matchConfig.MACAddress = secret.network.mac.usbc-omen or "";
|
2023-09-28 10:31:25 +02:00
|
|
|
linkConfig.Name = "eth0";
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.network.networks."50-eth0" = {
|
|
|
|
matchConfig.Name = "eth0";
|
|
|
|
networkConfig.DHCP = "ipv4";
|
|
|
|
linkConfig.RequiredForOnline = "no";
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.network.networks."50-wlan0" = {
|
|
|
|
matchConfig.Name = "wlan0";
|
|
|
|
linkConfig.RequiredForOnline = "no";
|
|
|
|
# networkConfig.DHCP = "ipv4";
|
|
|
|
|
|
|
|
# networkConfig.DNS = "${secret.network.ips.blowhole.ip}";
|
|
|
|
# dhcpV4Config.UseDNS = false;
|
|
|
|
# dhcpV6Config.UseDNS = false;
|
|
|
|
};
|
|
|
|
|
|
|
|
services.resolved.enable = false;
|
|
|
|
environment.etc."resolv.conf".text = ''
|
2023-10-21 17:46:17 +02:00
|
|
|
nameserver ${secret.network.ips.blowhole.ip or ""}
|
2023-09-28 10:31:25 +02:00
|
|
|
'';
|
|
|
|
|
|
|
|
services.resolved.extraConfig = ''
|
|
|
|
[Resolve]
|
2023-10-21 17:46:17 +02:00
|
|
|
DNS=${secret.network.ips.blowhole.ip or ""}
|
2023-09-28 10:31:25 +02:00
|
|
|
FallbackDNS=
|
|
|
|
'';
|
|
|
|
|
|
|
|
networking.wireless.iwd.enable = true;
|
2023-11-19 12:26:10 +01:00
|
|
|
networking.wireless.iwd.settings = {
|
|
|
|
General.EnableNetworkConfiguration = true;
|
|
|
|
};
|
2023-06-28 14:22:11 +02:00
|
|
|
hardware.bluetooth = {
|
|
|
|
enable = true;
|
|
|
|
settings = {
|
2024-03-02 22:05:30 +01:00
|
|
|
General.Enable = concatStringsSep "," ["Control" "Gateway" "Headset" "Media" "Sink" "Socket" "Source"];
|
2023-06-28 14:22:11 +02:00
|
|
|
};
|
|
|
|
};
|
2023-06-11 23:09:59 +02:00
|
|
|
}
|