nixos/machines/serverle/wifi.nix

40 lines
961 B
Nix
Raw Normal View History

2023-05-16 21:02:30 +02:00
{ config, pkgs, ... }:
2022-11-10 20:25:29 +01:00
{
2022-12-03 11:59:58 +01:00
sops.secrets."wifi/bismarck" = {
path = "/etc/NetworkManager/system-connections/Bismarck WLAN.nmconnection";
2022-11-10 20:25:29 +01:00
};
2023-05-16 21:02:30 +02:00
# Try fix wifi disconnect
networking.networkmanager.wifi.powersave = false;
networking.networkmanager.wifi.scanRandMacAddress = false;
# pragmatic fix for wifi loss
systemd.timers."reconnect-wifi" = {
wantedBy = [ "timers.target" ];
timerConfig = {
OnBootSec = "5m";
OnUnitActiveSec = "5m";
Unit = "reconnect-wifi.service";
};
};
systemd.services."reconnect-wifi" = {
script = ''
2023-05-16 22:42:34 +02:00
set +e # allow exit codes other then zero to check if online
set -u
2023-05-16 21:02:30 +02:00
2023-05-16 22:42:34 +02:00
${pkgs.networkmanager}/bin/nm-online -t 10
2023-05-16 21:02:30 +02:00
if [ $? != 0 ]
then
${pkgs.coreutils}/bin/echo "reconnect wifi"
${pkgs.networkmanager}/bin/nmcli connection up 'Bismarck WLAN'
fi
'';
serviceConfig = {
Type = "oneshot";
User = "root";
};
};
2022-11-10 20:25:29 +01:00
}