🍪 Kernel patches and NixOS modules that bring Apple silicon MacBooks closer to macOS.
README.md

silicon-bakery #

NixOS modules and kernel patches for the 14" MacBook Pro with M2 Pro (Mac14,9, J414s). It sits on top of nixos-apple-silicon and tries to close the gap to macOS on display, power and input. Most of it should work on other M2 Pro and M2 Max laptops, but this is the only machine it is written for.

frieren has run the series and the modules since 19 November 2026. The display, colour, backlight, CPU, video decode and service changes are checked on it; sleep, audio by ear, AirPods, haptics and the camera are not yet. docs/roadmap.md lists what was checked and how, and what is left.

Kernel patches #

The series in patches/linux applies in order on top of asahi-7.3.4-2:

  • 0001 to 0003 fix negative coefficients in the DCP colour matrix, add a second matrix for True Tone, and expose all five colour channels of the ambient light sensor.

  • 0004 adds the KMS Colorspace property to the internal panel. Default has DCP map sRGB onto the P3 panel, the way macOS does it. DCI-P3_RGB_D65 passes the framebuffer through as Display P3, for a compositor that composites in P3.

  • 0005 marks XRGB2101010 as premultiplied, so 10-bit scanout blends correctly.

  • 0006 is ProMotion, ported from chadmed's VRR work. The panel advertises vrr_capable with a 24 to 120 Hz range.

  • 0007 sets the backlight in exact nits. The firmware takes a small float, and stock Asahi approximates it with a lookup table that is off by up to 7%. The range stays at 2 to 500 nits, the same as macOS.

  • 0008 adds an energy model for the t602x CPU clusters, so energy-aware scheduling keeps light work on the efficiency cores.

  • 0009 adds EDR headroom for XDR highlights, see below.

  • 0010 stops apple-pmgr-misc lowering the memory controller under the PMP during sleep, which on t6000 broke resume. With the PMP running it lowers only the fabric. Ported from Aurora.

  • 0011 lets apps pick the camera frame rate and holds it in low light instead of dropping to 15 fps. Ported from Aurora.

  • 0012 reports play, pause and volume from wired headset remotes. Ported from Aurora.

  • 0013 fades brightness changes over 250 ms instead of stepping, as macOS does. Based on Aurora's fade for older firmware.

  • 0014 to 0106 are picked from Aurora and Aurora-DeepIdle, each reviewed and most changed on the way:

    • Trackpad haptics: click strength and host-driven Force Click (0032 to 0036), and waking on keyboard and trackpad input (0037).
    • Sleep: an RTC wake alarm for rtcwake (0019), the HDMI rails off (0018), quiet USB-C controllers (0020), amps set up again after resume (0016, 0017).
    • Wi-Fi and Bluetooth: firmware crash recovery, clean suspend and faster reconnects (0023 to 0029), Bluetooth resume (0030, 0031).
    • The battery temperature for DCP's backlight thermal model (0014), a device tree reference leak (0015), and two I/O speedups (0021, 0022).
    • Rosetta-style x86 flags for emulators like FEX, on the host and in KVM guests (0038, 0039).
    • Fixes: microphones offer only the float format they deliver (0040), the SSD survives unaligned direct I/O (0041), no speaker dropouts at period ends (0042), unknown battery times read as unavailable instead of 0 (0043).
    • Camera: firmware boot failures stop the coprocessor before freeing its memory (0044), and V4L2 format and buffer fixes (0045).
    • GPU: firmware structure lifetimes (0046, 0047), a killed client's work finishes before its memory goes (0048), cheaper binds for muvm games (0049), rate-limited fault reports (0050), and firmware stats in agx_stats (0051).
    • Video decode reliability: H.264 and HEVC edge cases, error recovery, and request flows for FFmpeg and Chromium (0055 to 0087).
    • Keyboard and trackpad receive hardening (0092), the AWDL interface AirDrop needs (0093, 0094, 0100), Wi-Fi fixes (0101 to 0103), and display fixes, chiefly a slow power-off no longer leaving the panel dark until reboot (0095, 0096, 0104 to 0106). 0097 and 0098 are small amp and PMIC fixes, 0099 the watchdog.
    • CPU: powering down idle cores from 100 µs of idle instead of 10 ms (0088), and boost frequencies schedutil can actually reach (0089, 0090, upstream v3). 0091 fixes a 32-bit shift in the PMP report driver.
    • The hardware video encoder (0052 to 0054), built only with videoEncode.enable, which also patches m1n1.
  • 0107 to 0109 complete EDR on the 13.5 firmware: the brightness limit macOS sends with each level, and debugfs knobs for the value at +0x304 and for tagging RGB surfaces.

  • 0113 makes the GPU's idle-off delay a parameter, asahi.idle_off_delay_ms, set with hardware.siliconBakery.gpu.idleOffDelayMs. It stays 2 ms unless set; macOS uses 1 ms while the GPU is busy.

The PMP patches in patches/pmp and patches/m1n1 are separate and off by default.

Setup #

inputs.silicon-bakery.url = "git+https://tangled.org/apothecary.moe/silicon-bakery";

imports = [ inputs.silicon-bakery.nixosModules.default ];

hardware.siliconBakery.enable = true;

Rebuilding compiles a patched kernel, so the first switch takes a while.

True Tone #

truetoned reads the light sensor, estimates the colour of the room light and runs Apple's colour adaptation, ported to Rust, so the white point of the panel follows the room like it does on macOS. It also sets the brightness from the room light, and when you change the brightness by hand the curve moves to match, so it keeps your preference. Night Shift is built in: a warmer white point from sunset to sunrise or between fixed times, fading over half an hour, through the same colour matrix.

It needs Apple's adaptation tables and your panel's factory calibration, copied once from macOS:

nix run git+https://tangled.org/apothecary.moe/silicon-bakery#truetone-extract -- ~/asahi-firmware/truetone

Keep the three files it writes private: they are Apple's data and your Mac's calibration. Then:

hardware.siliconBakery.trueTone = {
  enable = true;
  data = inputs.asahi-firmware + "/truetone";
};

truetoned --data <dir> --dry-run -v prints each matrix instead of applying it.

Options #

Option Default
hardware.siliconBakery.enable false Kernel patches, notch, power tuning
hardware.siliconBakery.notch true Draw beside the notch
hardware.siliconBakery.keyboardBacklight.enable true Drive the keyboard backlight from the light sensor
hardware.siliconBakery.keyboardBacklight.idleSeconds 0 Turn it off after this long without typing, 0 to never
hardware.siliconBakery.power.chargeLimit 80 Stop charging at this percentage, null to leave it alone
hardware.siliconBakery.power.optimizedCharging with a limit below 100 Learn the usual unplug time and charge to 100% in the two hours before
hardware.siliconBakery.power.deepIdle false Turn off WFI so idle CPUs always power down. 0088 already powers them down from 100 µs of idle, which gets 94% of the saving
hardware.siliconBakery.power.sleepLog true Log battery drain across each suspend
hardware.siliconBakery.power.boostOnBattery false Allow the P-core boost frequencies (up to 3.5 GHz) on battery too. On AC they are always allowed
hardware.siliconBakery.power.background.enable true Maintenance timers (store optimise, fstrim, logrotate, scrub) on the efficiency cores at idle priority
hardware.siliconBakery.power.idle.enable false Screen off after 2 minutes, lock after 5 and before sleep
hardware.siliconBakery.power.idle.suspendSeconds 900 Suspend after this long without input, null to never
hardware.siliconBakery.power.idle.suspendOnAC false Also suspend on the charger. Off, as on macOS, it suspends only once the charger comes out
hardware.siliconBakery.power.wifiPowerSave true Keep Wi-Fi power saving on
hardware.siliconBakery.powerModes.enable false power-profiles-daemon with a Low Power Mode: a CPU power budget and lower clocks in power-saver
hardware.siliconBakery.powerModes.lowPowerMode "never" Switch to power-saver by itself: always, on battery or on the adapter
hardware.siliconBakery.audio.enable with Asahi sound Speaker volume applied once, real speaker latency, headphone volume kept across boots, speakersafetyd fixes
hardware.siliconBakery.audio.speakerLimiter true A true-peak limiter at the end of the speaker DSP, so bass no longer clips
hardware.siliconBakery.trueTone.enable false Run truetoned
hardware.siliconBakery.trueTone.mode 1 Strength, as macOS's ColorAdaptationMode
hardware.siliconBakery.trueTone.autoBrightness true Brightness from the room light, learning from manual changes
hardware.siliconBakery.trueTone.nightShift.enable false Warmer white point at night
hardware.siliconBakery.trueTone.nightShift.schedule "sunset-to-sunrise" Or fixed times such as "22:00-07:00"
hardware.siliconBakery.trueTone.nightShift.latitude, .longitude 0 Where you are, for sunset and sunrise
hardware.siliconBakery.trueTone.nightShift.temperature 3400 Night colour temperature in kelvin
hardware.siliconBakery.macosSync.bluetooth with BlueZ Copy Bluetooth devices paired in macOS before BlueZ starts, and refresh their keys when macOS pairs them again
hardware.siliconBakery.macosSync.wifi with iwd Copy Wi-Fi networks saved in macOS before iwd starts
hardware.siliconBakery.airpods.enable false AirPods stem presses as media keys, and LibrePods
hardware.siliconBakery.airpods.librepods true Noise control, pause on ear removal, battery of each bud and the case
hardware.siliconBakery.trackpad.click "medium" light, medium or firm, like macOS's Click setting
hardware.siliconBakery.trackpad.forceClick false Clicks driven from finger pressure, with a deeper Force Click
hardware.siliconBakery.videoEncode.enable false H.264 and HEVC encoding in hardware, through V4L2. Patches m1n1, never run on an M2 Pro
hardware.siliconBakery.gpu.idleOffDelayMs null Milliseconds the GPU stays powered after going idle; the driver's 2 ms when null, macOS uses 1 while busy. Measured on an M2 Pro: 1 saved under 0.1 ms per wake and leaned 3–8% slower in latency tests, so leave it unset; see docs/gpu.md
hardware.siliconBakery.gpu.devDriver false Load a development asahi.ko built by tools/asahi-dev in place of the stock one, so drm/asahi changes need a 25 s build and a reboot, not a kernel build; asahi_dev=0 on the kernel command line forces the stock driver. See docs/gpu.md
hardware.siliconBakery.mesa.trimCdmBarrier false The trimmed CDM barrier after compute dispatches (patches/mesa/0003), about 2% faster LLM decode on an M2 Max. On an M2 Pro, CTS flaked and the GPU faulted twice with it on; leave it off, see docs/gpu.md
hardware.siliconBakery.pmp.enable false Start the Power Management Processor, see docs/pmp.md

With programs.gamemode.enable, games started through GameMode run on the performance cores and keep schedutil, as Aurora configures it.

Low Power Mode #

powerModes.enable runs power-profiles-daemon with Aurora's power daemons. Balanced and performance change nothing. In power-saver, as in macOS's Low Power Mode, the CPU clusters share a power budget taken from the energy model in 0008, recomputed every 100 ms, and the performance cores stay at or below 64% of their top clock (2.2 GHz on the M2 Pro, 2.0 GHz if the daemon starts with boost off). Realtime threads stop forcing their core to its top clock, and PCIe links may use their deepest power states. Aurora measured it on an M2 MacBook Air: twice the work per watt with eight busy threads, and 0.33 W less at idle. Switch with powerprofilesctl set power-saver or a bar's power profile menu, or set lowPowerMode = "battery".

The keyboard backlight uses Aurora's kbd-light. The Bluetooth sync uses Aurora's aurora-btsync, which unlike asahi-btsync picks up keys macOS changed.

AirPods #

Pair them in macOS and boot Linux: macosSync.bluetooth copies the key, so both systems use the same pairing. Pairing them again in Linux gives the AirPods a new key for this Mac, and macOS then has to pair again.

airpods.enable runs LibrePods as a user service, patched to keep AAC when it switches profiles after ear detection. Its menu lives in the system tray, so niri needs a bar with one; without it, librepods opens the window and librepods-ctl noise:anc (or off, transparency, adaptive) switches noise control from a key binding. Stem presses arrive as media keys, so bind XF86AudioPlay, XF86AudioPause, XF86AudioNext and XF86AudioPrev in niri.

Tools #

brightness-step up|down moves through the same 16 brightness levels as the macOS brightness keys.

power-report samples power draw, CPU idle residency, battery and how often the GPU and display firmware wake for a minute. power-report sleep lists the drain over each suspend, and power-report health shows the maximum capacity and cycle count, as in macOS's Battery Health.

gpu-bench runs the same GPU tests under Metal on macOS and under Vulkan on Linux: dispatch and submission costs, memory bandwidth, ALU, fill, texture and geometry rates, render latency beside a compute load, a compositor's frame and GPU power-off around small jobs, each with GPU power and clock. tools/gpu-bench/results has macOS's numbers on this Mac and compare.py sets a Linux run beside them.

edr-probe shows full-screen test patterns at a given EDR headroom from a text console and reports the system power for each, which tracks the backlight the panel uses. docs/xdr.md has the measurements.

niri #

output "eDP-1" {
    variable-refresh-rate
}

binds {
    XF86MonBrightnessUp allow-when-locked=true { spawn "brightness-step" "up"; }
    XF86MonBrightnessDown allow-when-locked=true { spawn "brightness-step" "down"; }
}

XDR #

SDR brightness already matches macOS. For HDR highlights up to 1600 nits, macOS keeps the link at 8-bit SDR and asks DCP for EDR headroom with each swap: the backlight goes up by H and DCP scales SDR pixels down by 1/H. 0009 finds those swap fields on the 13.5 firmware Asahi runs and exposes them as an EDR_HEADROOM CRTC property.

Measured on frieren, it works: at headroom 2 the backlight doubles while SDR stays at SDR white, and an fp16 extended-linear surface reaches 2x SDR white with values of 2.0. With HDR content on screen the panel goes past 500 nits. PQ surfaces are shown relative to the boosted level without the 1/H scale, so on this firmware a compositor converts PQ to extended linear. niri still needs that fp16 output path. docs/xdr.md has the details.

GPU #

The GPU firmware manages power itself, and the kernel hands it Apple's own DVFS, power and thermal parameters. Measured against macOS on this Mac, what differs is when the GPU powers off (0113), the display side (overlay planes, uncompressed scanout) and Mesa: on the same llama.cpp build, Vulkan runs prompts at a third of Metal's speed and tokens at half, because Honeykrisp's matrix-vector kernels reach 79–106 GB/s against Metal's 146–173 and G14 has no matrix path. docs/gpu.md has the measurements and the plan.

Touch ID #

Left out on purpose. The only driver writes to Secure Enclave storage that macOS shares, and the writes cannot be undone. See docs/touch-id.md.