'ip route add default' required every reboot

I’m running NixOS 23.05 on a MacBookPro11,3.

Due to the broadcom wireless, I have the following in my hardware-configuration.nix:
boot.kernelModules = [ “kvm-intel” “wl” ];
boot.extraModulePackages = [ config.boot.kernelPackages.broadcom_sta ];

I’m blacklisting bcma, since I know I need to specifically use wl, so I’ve added the following to my configuration.nix:
boot.blacklistedKernelModules = [ “bcma” ];

These are the only network related lines in my configuration.nix:
networking.wireless.enable = false;
networking.networkmanager.enable = true;

(I’ve tried with and without the ‘networking.wireless.enable = false;’ line, with no real difference. I’ve just read that having it prevented some errors in the background for other macbook users)

I can see the available wireless networks as soon as I log in. The system correctly automatically connects to the wifi as soon as I log in. I get an IP address, so DHCP is working. However, routing is broken on boot, and I need to manually set a default route through my router to get connectivity out to the web every time the system starts.

Here are the commands in order that I ran after my most recent reboot.

  1. verify that I’ve got an IP address from my active connection to the wifi:
    [pixelcrash@nixbookpro:~]$ ip a
    1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host noprefixroute
    valid_lft forever preferred_lft forever
    2: wlp3s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 60:03:08:9c:dd:e6 brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.134/24 brd 192.168.0.255 scope global dynamic noprefixroute wlp3s0
    valid_lft 86367sec preferred_lft 86367sec
    inet6 fe80::1088:8bff:fe2e:252c/64 scope link
    valid_lft forever preferred_lft forever
    inet6 fe80::de73:a912:62f7:a13a/64 scope link noprefixroute
    valid_lft forever preferred_lft forever

  2. Show that I’ve got no connection out to the web, even with the active connection to my router:
    [pixelcrash@nixbookpro:~]$ ping google.com
    PING google.com (142.250.217.110) 56(84) bytes of data.
    ^C
    google.com ping statistics —
    12 packets transmitted, 0 received, 100% packet loss, time 11273ms

  3. Rechecking my IP address, which shows a new line for ‘169.254.198.247/16’ for reasons uknown:
    [pixelcrash@nixbookpro:~]$ ip a
    1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host noprefixroute
    valid_lft forever preferred_lft forever
    2: wlp3s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 60:03:08:9c:dd:e6 brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.134/24 brd 192.168.0.255 scope global dynamic noprefixroute wlp3s0
    valid_lft 86349sec preferred_lft 86349sec
    inet 169.254.198.247/16 brd 169.254.255.255 scope global noprefixroute wlp3s0
    valid_lft forever preferred_lft forever
    inet6 fe80::1088:8bff:fe2e:252c/64 scope link
    valid_lft forever preferred_lft forever
    inet6 fe80::de73:a912:62f7:a13a/64 scope link noprefixroute
    valid_lft forever preferred_lft forever

  4. Show my route list:
    [pixelcrash@nixbookpro:~]$ sudo ip route list
    default dev wlp3s0 scope link src 169.254.198.247 metric 1003002
    169.254.0.0/16 dev wlp3s0 scope link src 169.254.198.247 metric 3002
    192.168.0.0/24 dev wlp3s0 proto kernel scope link src 192.168.0.134 metric 600

Note: the default route is related to the broken ‘169.254.198.247/16’ IP.

  1. Manually add a default route via my router
    [pixelcrash@nixbookpro:~]$ sudo ip route add default via 192.168.0.1

  2. Verify that I’m immediately able to get a connection out to the web after adding the new route.
    [pixelcrash@nixbookpro:~]$ ping google.com
    PING google.com (142.250.217.78) 56(84) bytes of data.
    64 bytes from sea09s29-in-f14.1e100.net (142.250.217.78): icmp_seq=1 ttl=117 time=7.22 ms
    64 bytes from sea09s29-in-f14.1e100.net (142.250.217.78): icmp_seq=2 ttl=117 time=6.48 ms
    64 bytes from sea09s29-in-f14.1e100.net (142.250.217.78): icmp_seq=3 ttl=117 time=8.52 ms
    64 bytes from sea09s29-in-f14.1e100.net (142.250.217.78): icmp_seq=4 ttl=117 time=6.30 ms
    ^C
    google.com ping statistics —
    4 packets transmitted, 4 received, 0% packet loss, time 3004ms
    rtt min/avg/max/mdev = 6.296/7.128/8.518/0.873 ms

  3. Show the new route list, which includes the one I added that fixed things:
    [pixelcrash@nixbookpro:~]$ sudo ip route list
    default via 192.168.0.1 dev wlp3s0
    default dev wlp3s0 scope link src 169.254.198.247 metric 1003002
    169.254.0.0/16 dev wlp3s0 scope link src 169.254.198.247 metric 3002
    192.168.0.0/24 dev wlp3s0 proto kernel scope link src 192.168.0.134 metric 600

Why is my system able to correctly create a connection to my router on boot as expected, but it requires manual intervention to correctly route through it every time? Is there a way to prevent the ‘default dev wlp3s0 scope link src 169.254.198.247 metric 1003002’ route from being added at all?

I’m struggling here, because I’ve figured out enough to manually push through the error and get things working, but it’s very strange that the system isn’t correctly processing routing after making network connections. Any help is appreciated!