Day 3: Fighting with network interfaces
Tags: nixos, apple, firmware
Published: 2023-05-11 00:33:05

I went down quite a rabbit hole trying to figure out hardware compatibility on my own. I'll walk through how I worked on the Wi-Fi issue here. Most of this content will be useless because I ended up with another solution, but I'll describe it anyway. To begin, I asked ChatGPT what I should do. ChatGPT apparently knows a lot about NixOS, though not the latest information unfortunately. So if any of the steps taken here seem unintuitive, don't worry. I had guidance and you can too.

From the top, we know that if we want to use Network Manager as the primary way of managing internet (I do), then it needs access to the wifi interface. To see my interfaces, I ran this command:

```
 ip link show
```
To see your available interfaces. I only had two results, `lo` and `enp7s0u2`. The `lo` will be there for everyone, and a variation of the `enp*` will represent an available ethernet interface. With working wireless, another entry should appear. Its absence means something is wrong. From here, I checked to see if my wireless network controller could even be found in the first place. To do this I added a new package, pciutils (PCI Utilities) to check the devices attached to my PCI slots (connections to the motherboard).

 Adding it made my environment.systemPackages look like this:

```
  environment.systemPackages = with pkgs; [
    (vscode-with-extensions.override {
      vscodeExtensions = with vscode-extensions; [
        bbenoist.nix
      ];
    })
    pciutils
  ];
```

You can see the vscode w/ extensions from before, and now pciutils is there too.

I then ran the simple command

```
lspci | grep -i broadcom
```

And good news, it exists! `03:00.0 Network controller: Broadcom Inc. and subsidiaries BCM4364 802.11ac Wireless Network Adapter (rev 03)` The mystery remained though, why if we could find the device we couldn't use it. Or might you say _drive_ it? We need drivers!

There were more commands to investigate, such as 

```
lsmod | grep -i brcmfmac
```
To help check if there were conflicting drivers. I had a hard time interpreting the results, but ChatGPT said there was a conflict. I continued with this pair-debugging plan and ran more commands and did and undid a bunch of things. There are many versions of the Broadcom chip and the `BCM4364` version in my `MacbookPro15,1` is just one of many. I tried pretty hard to get this installed. Here are a bunch of things I tried/learned:

- Added `wl` to `boot.kernelModules`
- Enabled `hardware.enableAllFirmware = true` flag in hardware-configuration.nix
- Added `linuxKernel.packages.linux_zen.broadcom_sta` to my system packages in configuration.nix
- Blacklisted the apparently undesirable conflicting module with `boot.blacklistedKernelModules = [ "brcmfmac" ];`
- Explicitly added linux 5.5 packages
- Found that the popularly recommended site, [aunali1](https://web.archive.org/web/20210217170329/https://packages.aunali1.com/apple/wifi-fw/18G2022/), was offline, no longer offering broadcome drivers
- Found that my BCM4364 is codenamed Midway and the others of the same generation are named after pacific/Hawaiian islands

Finally, I found https://t2linux.org/

Apple started introducing the T2 security chip in 2017 and my laptop has it. All new devices have it or something that has the same effect: Makes it super hard to use the laptop hardware.

Unfortunately following this guide was very difficult for me. Some of the instructions don't quite make sense and others don't have the expected result. It seems like doing something out of order or having done something differently ahead of following these steps can prevent success with this method. 

I found myself in a state where there was something going on with the startup manager and I couldn't boot from other partitions or USB devices at all. I tried so many things. Really. And I hate to admit defeat, but this time I am doing just that. I resorted to resetting my Macbook to factory defaults, completely wiping it. I will try again fresh and be very careful about the steps I take.