tpwrules / nixos-apple-silicon

Resources to install NixOS bare metal on Apple Silicon Macs
MIT License
757 stars 76 forks source link

GPU driver support #30

Closed malte-v closed 1 year ago

malte-v commented 1 year ago

A couple of days ago the Asahi team released their first GPU driver for the M* machines: https://asahilinux.org/2022/12/gpu-drivers-now-in-asahi-linux/ It would be nice to have them in nixos-m1 as well.

fx-chun commented 1 year ago

AFAIK (if you just wanted to try it out) you would only need a newer Mesa + the linux-asahi edge kernel; should work if you bump both packages to the necessary versions. I don't have an M1 setup so I can't verify, of course.

You'd want to use system.replaceRuntimeDependencies to replace the Mesa package at runtime however, since it would incur a pretty hefty rebuild replacing the real one.

tpwrules commented 1 year ago

I had to step away for Real Life just as this was released, unfortunately. Expect an update to support this in the next few days!

zzywysm commented 1 year ago

Someone has already been working on this, though I personally haven't tested it yet: https://github.com/yu-re-ka/nixos-m1/commits/gpu

onethirtyfive commented 1 year ago

yu-re-ka's work is great. I figured out how to use their mesa package override about a month ago. They were missing rust kernel support and some tricky kernel configs. None of which was obvious or documented at the time. Even that recently, It was hard to know what to use together. Let me tell you, it was not fun. :)

Since the creation of that gpu branch, Asahi formally released their drivers into their repositories and added a PKGBUILDs spec for their mesa fork. This lets us work with a "whole version of asahi" by one digest--packages which Asahi team advertise should work fine together just fine--rather than stitching things together.

It appears yu-re-ka patched in my (hacky) rust support into that branch!

So, yes, you can use yu-re-ka's gpu support, just ensure that your nix/m1-support/kernel/config has all the additions in edge kernel config, and that the packages you've specified elsewhere across your nixos-m1 fork (on your copy yu-re-ka's gpu branch!) are all sourced from the individual PKGBUILDs for each project from that same PKGBUILDs commit. I hope that makes sense.

You'll need linux-asahi (commit_id AND config overlaid with config.edge) and mesa-asahi-edge (commit_id). And you'll need to know how to use <m1-support> overriding via NIX_PATH to make it all build for your local system.

I can either explain this or make it easier for everyone, so I'll be spending my energy doing the latter.

tl;dr GPU support is a solved problem. I'm using it now! Making it easy, however, is not. I'm working on it (#34 and all others in that sequence). if my changes are to @tpwrules' liking. Regardless, @tpwrules is my hero. I would've had no idea where to start.

Thanks for coming to my TED talk. :rofl: