-
-
Notifications
You must be signed in to change notification settings - Fork 14.6k
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
macOS support for NixOS tests #282401
macOS support for NixOS tests #282401
Conversation
Closes NixOS#193336 Closes NixOS#261694 Related to 108984 This pull request is a composite of the changes from NixOS#193336 and also NixOS#261694, with some changes of my own that I made. The goal here was to get the following flake to build and run on `aarch64-darwin`: ```nix { inputs.nixpkgs.url = <this branch>; outputs = { nixpkgs, ... }: { checks.aarch64-darwin.default = nixpkgs.legacyPackages.aarch64-darwin.nixosTest { name = "test"; nodes.machine = { }; testScript = ""; }; }; } ``` … and after this change it does. There's no longer a need for the user to set `nodes.*.nixpkgs.pkgs` or `nodes.*.virtualisation.host.pkgs` as the correct values are inferred from the host system. This change is spiritually much closer to the approach in NixOS#261694 than the approach in NixOS#193336. However, I still made a few changes compared to NixOS#261694: - I didn't include the change to increase `ulimit` I think this change was questionable because I feel like a script provided by Nixpkgs shouldn't be tinkering with the user's ambient `ulimit` settings. - I named the required system feature `hvf` instead of `apple-virt` I preferred the `hvf` system feature name chosen by NixOS#193336. - I didn't use the `node.pkgs` setting to set `nodes.*.nixpkgs.pkgs` That does not work, based on my testing, but setting the same thing in `nixos/lib/testing/nodes.nix` does work. - I created a `pkgsLocal` helper This is based on the feedback from @roberth here: https://github.com/NixOS/nixpkgs/pull/261694/files#r1365443955 … and is similar in spirit to `pkgsCross`.
@ofborg eval |
I don't see this in the code.
I've chosen this name because the detection appears to be avf/hvf agnostic. |
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/getting-nixos-to-work-macos-m1-2-3-aarch64-darwin/39510/1 |
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/getting-nixos-to-work-macos-m1-2-3-aarch64-darwin/39510/2 |
Yeah, I'm planning on getting to fixing the |
… based on feedback from @roberth This plays nicer with other changes the user might want to make and also works in conjunction with the `pkgsReadOnly`. Note that this required deleting the `nixpkgs.pkgs` default because that's not compatible with setting `nixpkgs.system`. If `nixpkgs.pkgs` is defined (even as a default-valued option) then `nixpkgs.system` is ignored.
This is no longer necessary now that we're overriding `nixpkgs.system` instead of `nixpkgs.pkgs`
@roberth: Alright, I think I finally understood what you were proposing and implemented that. The main caveat is that I had to get rid of the |
@roberth: Thanks! Your changes look good to me |
Works great! |
Is it normal for |
@ofborg eval |
# If already linux: the same package set unaltered | ||
# Otherwise, return a natively built linux package set for the current cpu architecture string. | ||
# (ABI and other details will be set to the default for the cpu/os pair) | ||
pkgsLinux = |
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 this might be running into the same issue as when you were using pkgsLocal
(#282401 (comment)). ofborg might be happier if you exclude pkgsLinux
from https://github.com/NixOS/nixpkgs/blob/1b439a273dadd4c675e81a0e05abbc9258889c02/pkgs/top-level/release-attrpaths-superset.nix
(if the label comes back, that'll be confirmation, but I don't think it'd be harmful to add it to that list before that happens)
Thanks to everybody for y'all's help! |
Hi @Gabriella439 , Thanks for working on this. Doing so gives me:
I'm not sure how to go about debugging this. I can list the referrers, but it just tells me that there's a Is there a step I've missed? I got the impression that I don't need to specify pkgs in the machine configuration anymore? Is it something to do with |
@414owen your mac seems to be all set to execute NixOS integration tests. It still needs a linux builder to build the NixOS guest systems. See https://nixcademy.com/2024/02/12/macos-linux-builder/ |
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/macos-support-for-running-nixos-tests/40801/1 |
Doc update, please review: |
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: |
@tfc: I was able to reproduce the file limit bug that you were originally trying to address and root cause the problem! It turns out that the problem is caused by an old (pre-2.5) installation of multi-user Nix. In Nix 2.5 the file limit was raised for the The easiest way to verify the presence or absence of the problem is to check the
If that's present then it means you're likely unaffected by this bug. However, if that's absent (typically because Nix was originally installed at version older than 2.5) then you're probably going to be affected by that bug. If anyone is reading this and wondering how to fix the problem, the solution is to edit $ sudo launchctl kickstart -k system/org.nixos.nix-daemon |
Closes #193336
Closes #261694
Related to #108984
This pull request is a composite of the changes from #193336 and also #261694, with some changes of my own that I made.
The goal here was to get the following flake to build and run on
aarch64-darwin
:… and after this change it does. There's no longer a need for the user to set
nodes.*.nixpkgs.pkgs
ornodes.*.virtualisation.host.pkgs
as the correct values are inferred from the host system.This change is spiritually much closer to the approach in #261694 than the approach in #193336. However, I still made a few changes compared to #261694:
I didn't include the change to increase
ulimit
I think this change was questionable because I feel like a script provided by Nixpkgs shouldn't be tinkering with the user's ambient
ulimit
settings.I named the required system feature
hvf
instead ofapple-virt
I preferred the
hvf
system feature name chosen by RunnixosTests
on darwin #193336.I didn't use the
node.pkgs
setting to setnodes.*.nixpkgs.pkgs
That does not work, based on my testing, but setting
nixpkgs.system
innixos/lib/testing/nodes.nix
does work with some supporting changes topkgs/build-support/testers/default.nix
.Description of changes
Things done
Add a 👍 reaction to pull requests you find important.