Nix Flakes

Files
README.md

mplabx #

Nix flake packaging Microchip MPLAB X (v6.35) for NixOS / Nix on Linux.

The full installation is built entirely at build time: the official BitRock installer is downloaded and run inside a bubblewrap + fakeroot chroot, so the result is a self-contained store path under $out/opt/microchip/mplabx. Nothing is installed into the host /opt.

Only the MPLAB IPE (programming environment) is installed; the IDE and compiler toolchains (XC8/XC16/XC32) are out of scope. IDE-only component directories are pruned from the store path.

Usage #

{
  inputs.mplabx.url = "github:you/mplabx";
  outputs = { self, mplabx, ... }: {
    nixosConfigurations.myhost = nixpkgs.lib.nixosSystem {
      modules = [
        mplabx.nixosModules.default
        {
          services.mplabx = {
            enable = true;
            users = [ "ben" ];
          };
        }
      ];
    };
  };
}

On a plain Nix setup (no NixOS):

$ nix run '.#mplab-ipe'         # MPLAB IPE GUI
$ nix run '.#ipecmd' -- -?       # headless ipecmd CLI (usage)
$ nix build '.#mplabx-unwrapped' # the raw install (no wrappers/FHS)

Packages #

  • mplabx-unwrapped — the raw install from the official installer, at opt/microchip/mplabx/v6.35.
  • mplabx-fhs — buildFHSEnv sandbox that presents the install at the hardcoded /opt/microchip/mplabx location and provides the runtime libraries (GTK, X11, libusb, mesa, udev, JDK, ...).
  • mplab-ipe — launcher for the IPE GUI.
  • ipecmd — launcher for the headless ipecmd CLI.
  • default — alias for mplab-ipe.

An overlay is available at overlays.default.

NixOS module (services.mplabx) #

  • enable — install the package and enable udev rules.
  • package — which package to install (default mplabx.mplab-ipe).
  • users — additional users to add to the plugdev group (programmers are usually accessible without udev rules on modern kernels, but the group is provided for completeness).

Udev rules are installed for PICkit 4, PICkit 5, MPLAB SNAP, ICD 4/5, REAL ICE and a generic Microchip USB VID (04d8). A stub for MPLAB's /etc/.mplab_ide/mchpsegusbmonitor is also provided.

How it works #

  • pkgs/mplabx/unwrapped.nix fetches MPLABX-v6.35-linux-installer.tar (SRI-hashed, requires a Referer header), extracts the BitRock installer with makeself, and runs it in a bwrap chroot under fakeroot with:

    --mode unattended --unattendedmodeui none \
    --ide 0 --ipe 1 --8bitmcu 0 --16bitmcu 0 --32bitmcu 0 --othermcu 0 \
    --collectInfo 0 --collectMyMicrochipInfo 0
    

    Only etc, usr/share, lib/udev and opt are copied to the store path. IDE-only directories are deleted afterwards (see etc/mplab_ipe.clusters for the clusters IPE actually loads).

  • pkgs/mplabx/fhs.nix builds a buildFHSEnv rootfs; extraBuildCommands adds the /opt/microchip/mplabx symlink because MPLAB scripts hardcode paths like /opt/microchip/mplabx/v6.35/sys/java/zulu8....

  • pkgs/mplabx/wrapper.nix produces the mplab-ipe and ipecmd launchers, which exec the FHS env and derive JAVA_HOME from the bundled JRE.

Notes / caveats #

  • Device packs are not bundled (that saves ~10 GB). They are downloaded at runtime by the Pack Manager into ~/.mchp_packs. If offline use is needed, bundle them via the installer's --8bitmcu / --16bitmcu / --32bitmcu options.
  • MPLAB's own mchpsegusbmonitor helper does not exist on a plain NixOS system; the module provides a stub at /etc/.mplab_ide/. Its absence is harmless (the launcher backgrounds it and continues).
  • The first GUI run initializes the userdir at ~/.mplab_ipe/dev/v6.35.
  • ipecmd runs with DISPLAY unset (headless) as shipped by Microchip.
  • Build depends on network access to ww1.microchip.com (blocked inside nix's default sandbox, so use --option sandbox false or a sandbox-exempt builder if needed).