Overwrite `/lib/firmware` file

My Macbook Pro has a couple of issues regarding Wi-Fi connectivity, on Arch I had to copy my version of this file in /lib/firmware/brcm/, how can I achieve the same in NixOS?

I’m following this forum thread.



I think you want NixOS Search - Loading...
I use the following in my NixOS config to include the firmware for my bluetooth dongle

  hardware.firmware = [
        driverPkg = builtins.fetchTarball {
          url = "https://mpow.s3-us-west-1.amazonaws.com/mpow_MPBH456AB_driver+for+Linux.tgz";
          sha256 = "0mq2jq0mhmh2mjxhbr74hgv63ji77n2vn4phfpg55x7j9kixjs1a";
      pkgs.runCommandNoCC "firmware-rtl8761b" { } ''
        mkdir -p $out/lib/firmware/rtl_bt
        cp ${driverPkg}/rtkbt-firmware/lib/firmware/rtlbt/rtl8761b_config $out/lib/firmware/rtl_bt/rtl8761b_config.bin
        cp ${driverPkg}/rtkbt-firmware/lib/firmware/rtlbt/rtl8761b_fw $out/lib/firmware/rtl_bt/rtl8761b_fw.bin

Thank you for you reply, I’m having a couple of issues trying your response (noob here). I have the file locally because I had to make some changes.

As of now I wrote

hardware.firmware = [
  pkgs.runCommandNoCC "..." { } ''
    cp $out/root/brcmfmac43602-pcie.txt /lib/firmware/brcm

I’m not sure what to write between the quotation marks.

I tried a couple of options but they fail with the error the option value hardware.firmware... is not of type 'package'

Can you help me please? Thanks

You’re missing parentheses surrounding everything inside the square brackets (pkgs.runCommandNoCC "..." {} ''...''). Without them Nix will try and parse it as a list of 4 separate expressions instead of a list containing 1 expression.

  • pkgs.runCommandNoCC "..." {} the quotation marks here are for the derivation name. (You can use whatever you want. I used "brcmfmac43602-pcie" below)

Maybe try something like the following:
(If you place this config in /etc/nixos/configuration.nix it will expect brcmfmac43602-pcie.txt to be in the /etc/nixos/ directory.)

hardware.firmware = [
    pkgs.runCommandNoCC "brcmfmac43602-pcie" { } ''
      mkdir -p $out/lib/firmware/brcm
      cp ${./brcmfmac43602-pcie.txt} $out/lib/firmware/brcm/brcmfmac43602-pcie.txt
1 Like

Thank you very much! Now I can connect to Wi-Fi without a dongle! :slight_smile:

1 Like

hey sorry for necrobumping this thread, but does that create a file in /lib/firmware or does that also allow to overwrite or patch a file that already exist ?

if it doesn’t overwrite, how can i do so ?
the file i want to overwrite is part of linux-firmware.
thank you very much ! :slight_smile: