tpwrules / nixos-apple-silicon

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

Improvement 1: Standardize package inclusion with an overlay #34

Closed onethirtyfive closed 1 year ago

onethirtyfive commented 1 year ago

Motivations/context (here only, in first issue)

Gotta say it: as more of a NixOS end-user than hacker, I'm grateful for this repo. Thank you for making this possible!

You mentioned edge and GPU support being something you'd have to give some thought to.

I have done a lot of "spiking" to that end in my local repo and ended up with major modifications which I find beneficial, but throwing those at you at once would be presumptuous.

Instead, I invite you on a refactoring process step by step (hence the titled numbering). Each improvement builds on the prior and will have its own PR. If at any point I've lost you or you don't like the direction at least you will have everything to that point. Every commit is "tested" in two ways:

  1. nix-build '<m1-support>' -I m1-support=/home/me/Code/nixos/nixos-m1 -A installer-bootstrap
  2. nixos-rebuild build -I m1-support=/home/me/Code/nixos/nixos-m1 (where in my configuration.nix I have imports = [ ./hardware-configuration.nix <m1-support/nix/m1-support>];)

I hope this jogs nixos-m1 and m1-support domains adequately. Rebuilding these appears to be a no-op, which I think signifies safety--I'm not substantively changing things.

Introducing an asahi-overlay for both nixos-m1 and m1-support

Let's introduce an asahi-overlay which we can use in both nixos-m1 and m1-support. This will remove the repetition and "failure surface area" of invoking sibling packages ad hoc N times. Instead, let's have all m1-support packages be ambient members of config.hardware.asahi.pkgs. This way, referencing them is as easy as pkgs.asahi-fwextract. (Because of laziness, they remain override-able! Finally, I got that through my head this time.)

That's all these changes do.

tpwrules commented 1 year ago

I had the GPU stuff mostly finished, but had to wait for an issue to be fixed in nixpkgs before I was comfortable publishing it (and wait to get solid internet access and test effectively!) Sorry about the duplication of work. Most of this will likely have to be rebased.

In the future, please either submit one issue as an RFC, or one PR with multiple commits. This makes it easier to comment and decide. I will comment on all your suggestions here and close the other issues.

Improvement 1 to add an overlay makes good sense. The names should be better chosen and align with upstream nixpkgs. I think guidance can be taken from the nixos-hardware repository here.

Similarly improvements 2 and 3 of de-mingling packages and modules is good. Maybe they should be done before improvement 1 even.

I'm not sure about improvement 4. That seems like it would require IFD from hell to accomplish. Can you point me to your implementation? Maybe something in passthru.updateScript would be a better fit, or simply properly documenting release and test steps.

onethirtyfive commented 1 year ago

Thanks for graciously handling my awkward approach. And for edge-kernel and GPU support! I'm not bothered at all, I learned a ton. I will start over on main de-mingling packages and modules.

Let's punt on the overlay. To be clear: I was thinking about something modest, not something like rust-overlay. But a "full fat" overlay might be an interesting thing. :thinking: I will need more input on this.

Finally, thanks for the IFD reminder. My implementation is indeed rife with it. It's also a mess right now because I got into a yak shave before regrouping for the stuff I did here. I will look into passthru.updateScript--it seems a bit arcane at first blush.

Thanks again!

onethirtyfive commented 1 year ago

This is still on the docket! Holidays and work stuff. Updates as I can.

luxus commented 1 year ago

thanks for all the effort!