-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
Run nixosTests on darwin
#193336
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
Run nixosTests on darwin
#193336
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| { system, | ||
| pkgs, | ||
| hostPkgs ? pkgs, | ||
|
|
||
| # Projects the test configuration into a the desired value; usually | ||
| # the test runner: `config: config.test`. | ||
|
|
@@ -28,10 +29,10 @@ let | |
| # in that file, which are then forwarded to the test definition | ||
| # following the `import make-test-python.nix` expression | ||
| # (if it is a function). | ||
| discoverTests (val { inherit system pkgs; }) | ||
| discoverTests (val { inherit system pkgs hostPkgs; }) | ||
| else val; | ||
| handleTest = path: args: | ||
| discoverTests (import path ({ inherit system pkgs; } // args)); | ||
| discoverTests (lazyFunction (import path) ({ inherit system pkgs hostPkgs; } // args)); | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This silently ignores |
||
| handleTestOn = systems: path: args: | ||
| if elem system systems then handleTest path args | ||
| else {}; | ||
|
|
@@ -45,7 +46,7 @@ let | |
|
|
||
| inherit | ||
| (rec { | ||
| doRunTest = arg: ((import ../lib/testing-python.nix { inherit system pkgs; }).evalTest { | ||
| doRunTest = arg: ((import ../lib/testing-python.nix { inherit system pkgs hostPkgs; }).evalTest { | ||
| imports = [ arg ]; | ||
| }).config.result; | ||
| findTests = tree: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -139,16 +139,35 @@ with pkgs; | |
| ### Push NixOS tests inside the fixed point | ||
|
|
||
| # See also allTestsForSystem in nixos/release.nix | ||
| nixosTests = import ../../nixos/tests/all-tests.nix { | ||
| inherit pkgs; | ||
| system = stdenv.hostPlatform.system; | ||
| nixosTests = let | ||
| systemArgs = | ||
| if stdenv.hostPlatform.isLinux && (stdenv.buildPlatform.isLinux || stdenv.buildPlatform.isDarwin) | ||
| then { | ||
| hostPkgs = pkgs.buildPackages; | ||
| pkgs = pkgs; | ||
| system = stdenv.hostPlatform.system; | ||
| } | ||
| else if stdenv.hostPlatform.isDarwin && stdenv.buildPlatform.isDarwin | ||
| then | ||
| # In the context of a normal darwin compile, repurpose nixosTests as a | ||
| # non-cross build. This requires a "remote" builder such as a local | ||
| # Linux VM, but all VM hosting happens on darwin. | ||
| let linuxSystem = "${stdenv.buildPlatform.parsed.cpu.name}-linux"; | ||
| in { | ||
| hostPkgs = pkgs; | ||
| pkgs = import ../.. { inherit config overlays; system = linuxSystem; }; | ||
| system = linuxSystem; | ||
| } | ||
| else throw "Don't know how to configure NixOS for VM host ${stdenv.buildPlatform.system} and/or VM guest ${stdenv.hostPlatform.system} built on ${stdenv.buildPlatform.system}"; | ||
|
Comment on lines
+143
to
+161
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This logic is useful in other places, so it should be factored or moved to a common location, such as the nixos/lib/testing/pkgs.nix module.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about |
||
| in | ||
| import ../../nixos/tests/all-tests.nix { | ||
| inherit (systemArgs) hostPkgs pkgs system; | ||
| callTest = config: config.test; | ||
| } // { | ||
| # for typechecking of the scripts and evaluation of | ||
| # the nodes, without running VMs. | ||
| allDrivers = import ../../nixos/tests/all-tests.nix { | ||
| inherit pkgs; | ||
| system = stdenv.hostPlatform.system; | ||
| inherit (systemArgs) hostPkgs pkgs system; | ||
| callTest = config: config.test.driver; | ||
| }; | ||
| }; | ||
|
|
||
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 don't think we need additional flag for this. hvf is always available on Darwin, I don't think there's any hardware platform left that doesn't support it.
On the other hand, it would be good to allow to run tests even in plain emulation. It will be slow, but will still allow to test locally.
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 know some people virtualize macOS on apple hardware in order to make their build farm setup reproducible.
It seems unlikely that nested virtualization would be available on such VMs.