Hacker News new | ask | show | jobs
by OJFord 788 days ago
I'm recently back on macOS for work, and I wanted to love nix-darwin, but just couldn't get it even installed / basics running well enough to start to enjoy configuring things with it. The whole flakes mess really doesn't help.

(Maybe if you're already running NixOS and familiar with the latest it's a lot easier.)

I couldn't even uninstall it cleanly, since the Mac was new I gave up after some time and decided it was easier to reinstall macOS (which takes several hours but at least I can just leave it and then know that it's done).

So I'm back to (purely) brew (and scripts to `defaults write` etc.).

My frustration with brew is that it's getting increasingly opinionated, and those opinions are not familiar to me from any other OS/package manager... Like if you want postgres v15 you have to `brew install postgresql@15`, and then even if that's your only installed version it's 'keg-only', which means it's not on your PATH, and their suggestion is to dump some stuff at the end of your ~/.zshrc, which aside from the fact you're not using zsh and they could tell that, just seems dumb.

Then there's python & npm packages... They're deprecated and being removed as independent formulae, so don't do it like that. You're not allowed to install them with the python/node formula you installed, so don't do that. So what do you do, `python -m venv ~/system-python-venv` or something, activate it, and install in there. And now remember to activate that every time you want to use a command that happens to be a python package so you had to install it there. Or dump it in the end of your zshrc, I guess!

1 comments

The hardest part of Nix module systems for foreign operating systems, like Nix-Darwin and Home Manager, is absolutely installing them. The difficult bits are the bits they don't control— the parts where they plug into the underlying OS.

If you wanna give Nix-Darwin another go, I'm happy to help. Feel free to hit me up in the main Nix / NixOS channel or the Nix on macOS channel on Matrix. Getting everything working shouldn't take long with a little guidance.

(I can also help you get it cleanly uninstalled without reinstalling macOS, if you come away unsatisfied. I have manually uninstalled (i.e., not using the uninstaller) before.)

Any advice on getting the determinate installer and nix-darwin (via flakes) to be more seamless together? I have a decent setup, but the install/remove is clunkier than it needs to be because

1) on install, nix-darwin complains about the nix.conf that determinate sets up

2) on uninstall, determinate complains about nix-darwin being installed

1. I don't think this could be called seamless. But I just don't use the normal Nix-Darwin installer. I:

  a. build darwin-rebuild from the Nix-Darwin flake
  b. do a darwin-rebuild build --flake of the target system
  c. delete all of the files Nix-Darwin will complain about colliding with upon first install, including `/etc/nix/nix.conf`
  d. run the activation scripts in the built system directly, like
     ./result/activate-user
     sudo ./result/activate
For (d), make sure you run them in that order because it's actually the user activation script which ensures that /run/current-system exists.

For (c), just inspect the files in `result/etc` (or wherever you put the symlink to your built system, or directly from the Nix store) and compare them to what already exists in `/etc`, e.g.,

  find result/etc/ -type l | sed -E 's|^result||g' | xargs -I{} sh -c "test -f '{}' && echo '{}'"
should give you a list of files to nuke or back up or whatever, if you're trying to automate this.

2. Nix-Darwin has its own uninstaller whose job is to go remove all the references to `/etc/static` from `/etc` and some launchd crap, which are the bits and pieces that the Determinate Nix Installer finds and complains about when you try to uninstall Nix with an active Nix-Darwin installation. The uninstaller gets installed by default (try `less $(which darwin-uninstaller)`), but if it's missing for some reason you can also run it from the flake like `nix run github:LnL7/nix-darwin#darwin-uninstaller`.

Yeah, I actually have a slightly more streamlined version of step 1 by running the flake directly, I am just annoyed that I have to manually get involved (and I also have to manually reconcile options that determinate sets in the nix.conf, by translating them into my nix-darwin config).
> and I also have to manually reconcile options that determinate sets in the nix.conf, by translating them into my nix-darwin config

This is what I used to do to appease the installer before. After some options changed and I was like 'you know what, I'm happy with the ones I set; if I have already built the system before I run the activation script, then it's fine to delete /etc/nix/nix.conf.'.

The Nix-Darwin installer isn't a great option for me anyway because it assumes your darwin-config will live in ~/.nixpkgs/darwin-configuration.nix, but I like to keep it in /etc/nix-darwin/configuration.nix for a more NixOS-like convention.