NixOS virtual machines on macOS: Difference between revisions

Thu (talk | contribs)
No edit summary
Malloc (talk | contribs)
add section to enhance remote builder on darwin systems with x86_64 capability
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
NixOS is based on Linux, but a lot of developers are using MacBooks. The [https://github.com/LnL7/nix-darwin nix-darwin] project aims to bring the convenience of a declarative system approach to macOS and it is built around Nixpkgs (much like NixOS). After installing Nix, <nowiki><code>nix-darwin</code></nowiki> will help us with the following goals:
NixOS is based on Linux, but a lot of developers are using MacBooks. The [https://github.com/LnL7/nix-darwin nix-darwin] project aims to bring the convenience of a declarative system approach to macOS and it is built around Nixpkgs (much like NixOS). After installing Nix, <code>nix-darwin</code> will help us with the following goals:


# Build a complete NixOS (Linux) system.
# Build a complete NixOS (Linux) system.
Line 22: Line 22:
that the Linux builder is actually such a virtual machine.
that the Linux builder is actually such a virtual machine.


Point 4 is similar to point 3, but since the tests are _built_ using virtual
Point 4 is similar to point 3, but since the tests are '''built''' using virtual
machines, it means that these virtual machines are running inside the Linux
machines, it means that these virtual machines are running inside the Linux
builder. This is not a problem if our environment supports nested
builder. This is not a problem if our environment supports nested
Line 208: Line 208:
Note: Notice how further configuring the Linux builder uses the running Linux
Note: Notice how further configuring the Linux builder uses the running Linux
builder to build the new one.
builder to build the new one.
== <code>linux-builder</code>, with <code>x86_64-linux</code> emulation ==
Building upon previous example, the remote builder can be enhanced to build x86_64 packages without creating a second VM or builder<ref>https://github.com/nix-darwin/nix-darwin/issues/1192#issuecomment-2619629531</ref>:<syntaxhighlight lang="nix">
nix.linux-builder = {
  # ...
  systems = [ "x86_64-linux" "aarch64-linux" ];
  config.boot.binfmt.emulatedSystems = [ "x86_64-linux" ];
};
</syntaxhighlight>


== <code>direnv</code> ==
== <code>direnv</code> ==
Line 287: Line 296:
The original machine had also Screen Sharing enabled.
The original machine had also Screen Sharing enabled.


== References ==
== Further reading ==


* "Build and Deploy Linux Systems from macOS" on the [https://nixcademy.com/posts/macos-linux-builder/ Nixcademy Blog].
* [https://nixcademy.com/posts/macos-linux-builder/ Build and Deploy Linux Systems from macOS], Nixcademy
* [https://nixcademy.com/posts/running-nixos-integration-tests-on-macos/ Run NixOS Integration Tests on macOS], Nixcademy


[[Category:macOS]]
[[Category:macOS]]
[[Category:nix-darwin]]
[[Category:nix-darwin]]
[[Category:Tutorial]]
[[Category:Tutorial]]