-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Flake support, project reorganization, asahi overlay #47
Conversation
Hmm, including a mesa override in the overlay causes rebuilds for everything that depends on mesa, regardless of whether the experimental GPU option is actually enabled. The option ends up being kind of silly, since it doesn't actually change anything. I'll fix this tomorrow. |
Actually, I think this is good enough. Overriding The overlay now lets you reference nixpkgs.overlays = [ (final: prev: { mesa = final.mesa-asahi-edge; }) ]; (regarding #45) |
While I appreciate the effort, this is a big change for the project and I'm not sure about it. Primarily, I'm not ready to go flakes-only. Though popular, they are still experimental and require extra effort from users to set up, and the simplicity of the current install is useful. There are certainly things I could adjust for a better flakes experience but I don't regularly use them in this context so some suggestions here would be helpful. I do think the code needs reorganization and was hoping #35 would provide a good solution to that, but it doesn't seem to have happened. I will probably put together a PR myself for this which cribs ideas from this PR and #35 and solicit feedback from you and the community on if that meets your needs. It's hard to accept a big PR like this one without having fiddled with it myself first. As for the Mesa fixes, I have a better solution to that I am working on which avoids so much recompilation and hope to get it out soon. |
wondering is possible for these tricks to be a part of NixOS/nixos-hardware |
The nixos module can still easily be used without using flakes. I decided to go with flakes-only for the iso and package outputs because flakes solve many of the problems that Namely,
|
If you'd prefer, (and if you end up agreeing that flakes would be the better solution,) I could get rid of the
|
As for just ensuring a better experience for flake users, the nixos module is easy enough to use as a non-flake input (specifically since the nixos module doesn't have any required project depnendencies): imports = [
"${inputs.nixos-m1-non-flake}/nixos-module"
]; You'd just have to get rid of the One small advantage (for the nixos module) for having the project be a flake, however, is that flake users would gain the ability to easily pin the asahi packages to the "working versions" specified by the nixpkgs in the flake lockfile. |
(to clarify) The flake in this PR does not require users to have a flake-based system configuration. The nixos module can still be imported manually, through a channel, or through a tarball. The PR merely adds a standardized and convenient way to import the module from a flake. This PR does require either an extra CLI flag However, this can be completely worked around with via |
Thanks for the clarification on your intentions and the outcomes. Yeah, I agree the current situation is rather ad-hoc and clunky. You raise some good points about how flakes would make it cleaner. I'm not aware that there are any actual problems here at the moment in particular with regard to purity, but making it impossible to make those kinds of mistakes is good. I don't think It's very important to me that a user be able to download an ISO off GitHub, boot it, and install quickly without having to download and rebuild a whole kernel on their system. Nix does make it easy, but it's still not a great time on the lower-end machines. Some of the impurities as I recall were there to make this work. AFAIK these should be possible to deal with when involving flakes but they do need to work properly. Please give me a week or so to review and play with this in depth. Please also rebase on top of the latest release. I might do another release in a couple days once the recent nixpkgs staging merge makes it to the NixOS release channels. |
@sequencer Some people have tried this (and moving support for these machines into nixpkgs too) but I haven't kept much track and I don't think it's feasible until the kernel upstreaming matures a little more. |
Ok, I'm running into new issues with the recent changes on
|
Hm, that was another memory around impurity that is now surfacing. I used to have I can add an option to overlay the new mesa I suppose but that's rather unfair for flakes users because essentially everything needed to be rebuilt. |
Instead of using |
I did consider that option while working on this. One issue is that it would become much more difficult for non-flake users to incorporate the nixos module into their system, since the overlay would depend on this project's Flake users can already pretty easily override sources with flake inputs via overlays: final: prev: {
mesa-asahi-edge = prev.mesa-asahi-edge.overrideAttrs (old: {
src = inputs.mesa-asahi;
});
} |
TODO: Try to get This will make Also, |
The catch with m1n1 is that it has to be a native build so that the tools like the proxy client and command line come out for x86_64-linux but also a cross build so that the m1n1 stub is built for aarch64-linux. Might be possible to split this into two separate derivations? I think your solution is workable for U-Boot though, it always expects to be run using an aarch64 stdenv. The bit with the kernel package is necessary to support the "install a kernel from a cross-compiled ISO without rebuilding it" scenario. The comment might be a little bit incorrect but we do in fact build the config derivation "for" x86_64-linux when cross-building the ISO, even though the contents never change. There might be a better way to do that. The current clause there should be compatible with flakes as it specifically checks for currentSystem to exist and assumes you are running natively if not. |
In the absolute worst case, we could explicitly re-import nixpkgs with As for the kernel config IFD, we can just replace note: nixpkgs uses native builds when |
Okay, this should be the final rebase. I am still interested in this, just had to make sure everybody's builds didn't break. |
Some notes about the default firmware directory:
Maybe we should set the default to (edit: actually |
Yes, the fact that The reason for the two paths is evaluation in the installer ISO. The actual installer gets the firmware by running |
…r-bootstrap` note: installer-bootstrap won't build at this commit
adjust project structure
export m1n1 and uboot-asahi for cross-compilation remove asahi-fwextract from package outputs
stop using `pkgsCross.aarch64-multiplatform`
Flake lock file updates: • Updated input 'nixpkgs': 'github:nixos/nixpkgs/37b97ae3dd714de9a17923d004a2c5b5543dfa6d' (2023-01-13) → 'github:nixos/nixpkgs/2d38b664b4400335086a713a0036aafaa002c003' (2023-01-17) • Updated input 'rust-overlay': 'github:oxalica/rust-overlay/ca474ccdd5f81ed742328e15dae38bb57a1006e3' (2023-01-13) → 'github:oxalica/rust-overlay/5f7315b9800e2e500e6834767a57e39f7dbfd495' (2023-01-19)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks again for this work. I've been able to build and boot the cross ISO, and have built (but not tried to boot) the ISO natively. Actually installing doesn't quite work correctly yet but I am assuming the packages all still function.
We still need to address documentation too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rename is not complete. If you want I can push to your branch, or you can fix it. Then I will test again.
use `apple-silicon-support/modules` and `apple-silicon-support/packages`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please address the mentioned issues. I will then squash, merge, and update the documentation.
]; | ||
}; | ||
in { | ||
inherit (pkgs) m1n1 uboot-asahi; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it safe to inherit the kernel package here too? Being able to directly build the kernel and the configured-for-boot u-boot/m1n1 was the reason I had the config initially exposed but it sounds like that causes problems in the flake.
If not I will figure it out later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issue I had with outputting the kernel package was NixOS/nix#4265, which also breaks nix flake show
. Luckily we should be able to get rid of the IFD using pure nix, as I've mentioned below.
We could also output the installer config, but I think it's not as clear where the config should go in the output, especially since we need to account for different possible build platforms, so I wanted to avoid it if possible.
@@ -15,7 +18,7 @@ | |||
"CONFIG_${builtins.elemAt kv 0}=${builtins.elemAt kv 1}"; | |||
in lib.strings.concatMapStringsSep "\n" perLine lines; | |||
|
|||
readConfig = configfile: import (localPkgs.runCommand "config.nix" { } '' | |||
readConfig = configfile: import (runCommand "config.nix" { } '' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has definitely broken hardware.asahi.buildPkgs
. I am pretty sure the above comment is wrong. The real issue is that the config.nix
file does not make its way to the ISO. Thus, when the configuration is evaluated, the runCommand
needs to be executed to get the complete source code, but runCommand
expects to run on a hardware.asahi.buildPkgs
system and fails.
I want to keep the localPkgs
hack for now (we don't need lib = localPkgs.lib
though) and fix it later. That option will still be broken as it was for flakes users before, but it will be fine for the install scenario.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the solution is to replace the "config.nix"
IFD with a pure nix regex parser. It seems like it'll be pretty straightforward, and it can be upstreamed to nixpkgs since nixpkgs also uses an IFD currently.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
opened #51
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added back the localPkgs
workaround for now.
Thanks for all this work, I have replaced my local config with the latest version of this PR, at the end of this comment I paste a copy of my flake.nix on /etc/nixos. FYI, The overlay strategy with the latest version of this flake gives:
|
I have verified the latest version of this PR on a new (flake-based) configuration and it works. This set up is very flexible for downstream users like me. Here is an example: I let nix flakes update the rust overlay to latest and nixpkgs to latest, and it worked after adding this to my configuration.nix (blacklist-types is now blocklist-types).
|
Resolves #34 (and #36 #37)
Supersedes #35
Supersedes #46 and closes #45 (probably)
This PR does a couple of things:
packages
,nixos-module
, andiso-configuration
packages/overlay.nix
and update the nixos module and the installer to use ithardware.asahi.overlay
option to the module, which the module automatically appends to the system nixpkgsflake.nix
, which replacesdefault.nix
andpins.nix
and outputsdefault.nix
installer-bootstrap
package for every system supported by nixpkgs, cross-compiling as needed/boot/asahi
as a non-flake inputCI and docs would need to be updated.
nix-build -A installer-bootstrap-cross -j2
with
nix build .#installer-bootstrap -j2
--experimental-features 'nix-command flakes'
or configuration changes)nix-build
commands with flake-based commandsx86_64-linux
inputs.nixos-m1.nixosModules.default
/boot/asahi
as a non-flake inputI'm currently using the nixos module output of the flake for my system configuration, but the iso is yet to be tested.