Darwin experience comapred to NixOS

I’ve been using NixOS for many years now across several machines and enjoy the experience greatly. I’m looking into getting a new laptop and considering the M1/M2 Macs as an option.

I would be very thankful for any “real life” experience from people running nix-darwin on these, especially if they also use NixOS. As someone who has never used a Mac, it’s difficult for me to judge some things based solely on the documentation/implementation as I’m unfamiliar with the underlying system.

Some things in particular I’d love to know:

  • Does the declarative system configuration feel similarly stable and comprehensive as NixOS? How difficult is it to do the equivalent of booting into a previous generation? Do system updates and nix-darwin generations start to “drift apart” at some point requiring intervention?
  • How is the package availability? Based on your day-to-day experience, not nixpkgs statistics. Do you find things broken or lacking?
  • Is there a way to build nixosConfigurations flake outputs targeting x86_64-linux locally?
  • In case you have both NixOS and Mac systems, how much configuration can be shared and how similar do the environments feel in practice? Given, e.g., a properly made flake devenv, do you have to be aware of which system you’re working on?

Thank you!

I use both NixOS and nix-darwin.

  1. The declarative system configuration is good. You can’t “boot” into another generation, but it’s trivial to rollback and activate one. I haven’t had issues with macOS and nix-darwin interfering with each other.
  2. I don’t use the mac for much. Most of what I do is over SSH on my linux desktop. But I haven’t really encountered any issues with package availability.
  3. You cannot currently cross compile from macOS to linux. But you can run an aarch64-linux VM, which I do. From there you can either cross compile for x86_64, which is always a pain, or you can try to use Apple’s Rosetta for linux, which I haven’t tried but I’ve seen others have some success with.
  4. Most of my NixOS configuration is pretty linux specific. Like systemd services, desktop environment configuration, hardware related things, etc… But I do manage to share a reasonable amount. My systemPackages are mostly shared, my nix settings are shared, my bash profile and prompt are shared. And I have a module implementing the subset of services.openssh that I need on nix-darwin so that I can share a bunch there too, which helps me share code for configuring remote builders with SSH certificates.

Btw, I found myself much happier in the mac terminal after I installed just a bunch of basic CLI utilities from nixpkgs instead of using the ones from macOS.

  environment.systemPackages = with pkgs; [
    # Just get... all of the basics from nixpkgs                                                                                                                                              
    bzip2 coreutils-full curl
    diffutils file findutils
    gawk gnugrep gnused
    gnutar gzip less man
    netcat openssh rsync
    inetutils tree unzip watch

Other than that, keep in mind that I personally try to keep my configurations somewhat minimal. I spent a number of years excitedly making grand convoluted nixos/nix-darwin configs and making everything heavily customized. Then I decided to nuke it all and start over and I found myself missing basically none of it. So now I just keep it simple. Point being, I may not be the most representative of how seamless this all is, since I might use it a little less intensely than others might.

1 Like

Thank you, that’s very helpful! Shame about the cross-compilation, that might be a deal-breaker for me.

If you’ll still have NixOS machines, you can also set up a remote builder.

1 Like