From 6d5c55aeaaa565ffccf83396682e94792b18cb9b Mon Sep 17 00:00:00 2001 From: xnm Date: Sun, 20 Oct 2024 23:32:04 +0300 Subject: [PATCH] switched from `networkmanager` to `iwd` --- .../fish/functions/airplane_mode_toggle.fish | 22 ++++++++-------- home/.config/fish/functions/wifi_toggle.fish | 8 +++--- home/.config/waybar/config | 2 +- nixos/dns.nix | 15 ++++++++++- nixos/networking.nix | 25 +++++++++++++++++-- 5 files changed, 53 insertions(+), 19 deletions(-) diff --git a/home/.config/fish/functions/airplane_mode_toggle.fish b/home/.config/fish/functions/airplane_mode_toggle.fish index ae41ed7..25a1bb7 100644 --- a/home/.config/fish/functions/airplane_mode_toggle.fish +++ b/home/.config/fish/functions/airplane_mode_toggle.fish @@ -7,27 +7,27 @@ function airplane_mode_toggle set -l bluetooth_status (cat $backup_file | grep -o 'bluetooth:\(on\|off\)$' | cut -d':' -f2) # Restore network states - if test "$wifi_status" = "on" - nmcli radio wifi on - # else - # nmcli radio wifi off + if test "$wifi_status" = on + rfkill unblock wifi + # else + # rfkill block wifi end - if test "$bluetooth_status" = "on" + if test "$bluetooth_status" = on rfkill unblock bluetooth - # else - # rfkill block bluetooth + # else + # rfkill block bluetooth end # Remove the backup file rm $backup_file else # Backup the current network states and turn off all networks - echo "wifi:$(rfkill list wifi | grep -q "Soft blocked: no" && echo "on" || echo "off")" > $backup_file - echo "bluetooth:$(rfkill list bluetooth | grep -qi "Soft blocked: no" && echo "on" || echo "off")" >> $backup_file + echo "wifi:$(rfkill list wifi | grep -q "Soft blocked: no" && echo "on" || echo "off")" >$backup_file + echo "bluetooth:$(rfkill list bluetooth | grep -qi "Soft blocked: no" && echo "on" || echo "off")" >>$backup_file # Add more lines to backup other network types if needed - nmcli radio wifi off + rfkill block wifi rfkill block bluetooth end -end \ No newline at end of file +end diff --git a/home/.config/fish/functions/wifi_toggle.fish b/home/.config/fish/functions/wifi_toggle.fish index ee34fe2..7cbf844 100644 --- a/home/.config/fish/functions/wifi_toggle.fish +++ b/home/.config/fish/functions/wifi_toggle.fish @@ -1,11 +1,11 @@ function wifi_toggle - set wifi_status (nmcli radio wifi) + set wifi_status (rfkill list wifi | grep -i -o "Soft blocked: yes") set backup_file ~/.cache/airplane_backup - if [ "$wifi_status" = enabled ] - nmcli radio wifi off + if [ -z "$wifi_status" ] + rfkill block wifi else - nmcli radio wifi on + rfkill unblock wifi if test -e $backup_file rm $backup_file end diff --git a/home/.config/waybar/config b/home/.config/waybar/config index 76029d1..235b930 100644 --- a/home/.config/waybar/config +++ b/home/.config/waybar/config @@ -162,7 +162,7 @@ // "tooltip-format-ethernet":"Interface: {ifname}\nIP: {ipaddr}\nGW: {gwaddr}\nNetmask: {netmask}\nCIDR: {cidr}\n\n{bandwidthUpBits}\t{bandwidthDownBits}\t󰹹{bandwidthTotalBits}", "max-length": 35, "on-click": "fish -c wifi_toggle", - "on-click-right": "wezterm start nmtui", + "on-click-right": "iwgtk", }, "group/misc": { diff --git a/nixos/dns.nix b/nixos/dns.nix index 1d56f0f..afdfea6 100644 --- a/nixos/dns.nix +++ b/nixos/dns.nix @@ -3,16 +3,29 @@ { # Enable Encrypted DNS networking = { - nameservers = [ "127.0.0.1" "::1" ]; + nameservers = [ "127.0.0.1" "[::1]" ]; # If using dhcpcd: + dhcpcd.enable = false; # disable, because enabled by default dhcpcd.extraConfig = "nohook resolv.conf"; + # If using NetworkManager: networkmanager.dns = "none"; + + # If using resolvconf: + resolvconf = { + enable = false; # FIXME remember to delete /etc/resolv.conf after applying this config + useLocalResolver = true; + }; + + # If using iwd: + wireless.iwd.settings.Network.NameResolvingService = "none"; }; services.dnscrypt-proxy2 = { enable = true; settings = { + listen_addresses = [ "127.0.0.1:53" "[::1]:53" ]; + ipv6_servers = true; require_dnssec = true; diff --git a/nixos/networking.nix b/nixos/networking.nix index d28dee6..20fd73f 100644 --- a/nixos/networking.nix +++ b/nixos/networking.nix @@ -1,13 +1,34 @@ -{ ... }: +{ pkgs, ... }: { # Enable networking networking.hostName = "isitreal-laptop"; # Define your hostname. # Pick only one of the below networking options. # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. - networking.networkmanager.enable = true; # Easiest to use and most distros use this by default. + # networking.networkmanager.enable = true; # Easiest to use and most distros use this by default. + # networking.networkmanager.wifi.backend = "iwd"; + + networking.wireless.iwd = { + enable = true; + settings = { + General = { + EnableNetworkConfiguration = true; + }; + Network = { + EnableIPv6 = true; + }; + Scan = { + DisablePeriodicScan = true; + }; + }; + }; # Configure network proxy if necessary # networking.proxy.default = "http://user:password@proxy:port/"; # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain"; + + environment.systemPackages = with pkgs; [ + iwgtk + impala + ]; }