Skip to content

Trim down pkgs.linux-firmware to fit actually used hardware #343

@yfyf

Description

@yfyf

Pretty much all the firmware lives in a single package linux-firmware, which contains support for very diverse hardware and is getting bloated with each NixOS release (see NixOS/nixpkgs#148197), without an easy way to trim it down.

Since we mostly target specific x86 hardware with Intel CPUs using UHD, we can remove a lot of firmware for the unused hardware (AMD, Nvidia, legacy, etc).

PoC override that does this:

self: super: {
  linux-firmware = super.linux-firmware.overrideAttrs (old: {
    postInstall = (old.postInstall or "") + ''
      cd $out/lib/firmware

      # ARM SoC / embedded platforms
      rm -rf qcom mrvl airoha amlogic amphion arm cadence cnm dpaa2 \
             imx meson microchip nxp powervr rockchip ti-keystone \
             ti-connectivity inside-secure cypress

      # Atheros (Qualcomm) WiFi
      rm -rf ath6k ath9k_htc ath10k ath11k ath12k

      # NVIDIA GPU firmware
      rm -rf nvidia noveau

      # Mellanox / ConnectX server NICs
      rm -rf mellanox

      # Delete broken symlinks
      find $out -xtype l -delete
    '';
  });
}

The difference on nixpkgs 25.11 is more than 2x (~1GB smaller):

  • Size of pkgs.linux-firmware as used in PlayOS "as is": 1744M
  • Size of pkgs.linux-firmware as used in PlayOS with the overlay: 793M

The absolute size difference when compressed is smaller, but it still seems to yield a ~500M reduction in the compressed RAUC bundle size.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions