-
-
Notifications
You must be signed in to change notification settings - Fork 266
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
Recipes for being a happy Nixer on a Mac #1104
Conversation
Co-authored-by: Jacek Galowicz <jacek@galowicz.de>
|
||
# Nix natively on macOS | ||
|
||
First, you need to install Nix on your macOS. Using the [Official Installer](https://nixos.org/download) works fine, but there is no uninstall support. Instead, The [Nix installer from Determinate Systems](https://github.com/DeterminateSystems/nix-installer?tab=readme-ov-file#determinate-nix-installer) is the recommended installer for Nix on macOS, especially if you plan on using flakes. If you need help, follow https://nixcademy.com/posts/nix-on-macos/. |
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 don't use passive voice on subjective claims. Recommended by whom? I understand it's nix-darwin
maintainers. Maybe it would help readers to orient themselves if we started the article with an overview of the situation and the general approach taken here.
|
||
Here are a few things you can try if you get errors starting or running the tests: | ||
|
||
* Upgrade to the latest `nixpkgs`. Sadly, macOS support is not a first-class priority for the nixpkgs maintainers and is sometimes broken for a few days until fixes are pushed. |
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 is official documentation, so I insist on staying factual and refrain from value judgement. The support status for macOS in Nixpkgs is crucial information for managing expectations, but I'd recommend linking to upstream documentation so people can can figure out the details themselves and we here don't run the risk of having to keep up with information getting out of date. And at least for high-level facts that are unlikely to change any time soon, I recommend using the upstream (and positive, constructive) phrasing, something like: macOS currently has second-tier support in Nixpkgs.
|
||
A big part of developing for NixOS are the [NixOS Integration Tests](https://nix.dev/tutorials/nixos/integration-testing-using-virtual-machines.html). Although macOS is a different architecture (called `darwin`) than NixOS, we can run the NixOS Tests directly on macOS because the [Linux Builder](./#linux-builder) provided by `nix-darwin` is used to build the Linux VMs that the tests run against. | ||
|
||
Assuming the Linux Builder is installed and running, let's run an example NixOS test with `$ nix -L build github:tfc/nixos-integration-test-example` and you should see `test script finished in ...s` in your output after a few minutes. |
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.
We'll need to have a word on using opaque external code (and flakes) for guides and tutorials... :)
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.
Yep, agreed.
Hey @fricklerhandwerk, please don't review this just yet. It's a very rough draft, mostly just gathering information and confirming the instructions work. I would normally do this locally, but since I'm on a sprint it's here so it's easy to share with others for testing on different machines. |
nix.linux-builder.enable = true; | ||
``` | ||
|
||
Rebuild with `darwin-rebuild switch` and verify that the Linux Builder VM is actually running with `$ sudo launchctl list org.nixos.linux-builder`. |
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.
Maybe mention what is the expected output of the $ sudo launchctl list org.nixos.linux-builder
command?
{
"LimitLoadToSessionType" = "System";
"Label" = "org.nixos.linux-builder";
"OnDemand" = false;
"LastExitStatus" = 0;
"PID" = 573;
"Program" = "/bin/sh";
"ProgramArguments" = (
"/bin/sh";
"-c";
"/bin/wait4path /nix/store && exec /nix/store/nqj05s4sh0wi2rhdykz56q1ndhin13ja-linux-builder-start";
);
};
Co-authored-by: Amon Stopinšek <am-on@users.noreply.github.com>
This guide turned out to be too much of a "personal notetaking" instead of "general documentation", so I moved it to our blog instead: https://paretosecurity.com/blog/being-a-happy-nixer-on-a-mac |
Refs Thaigersprint/thaigersprint-2025#1