I recently got an m4 Mac from work and I am trying to setup nix-darwin in my flake.
I installed nix using the Determinate Systems installer (tried with and without the Determinate option).
I then try to rebuild my flake with nix --extra-experimental-features flakes --extra-experimental-features nix-command run nix-darwin/nix-darwin-24.11#darwin-rebuild -- switch --flake .#hostname and I get:
error: getting status of '/etc/nix/registry.json': Permission denied
I have a look at that directory:
❯ sudo ls -al /etc/nix
total 512
drwxr-x--- 5 root wheel 160 11 Mar 22:54 .
drwxr-xr-x 87 root wheel 2784 11 Mar 22:42 ..
-rw-r--r-- 1 root wheel 249938 10 Mar 14:38 macos-keychain.crt
-rw-r--r--@ 1 root wheel 1037 11 Mar 22:42 nix.conf
-rw-r--r--@ 1 root wheel 141 11 Mar 22:42 nix.custom.conf
And that file does not exist.
Am I missing something here to get going?
The instructions do not say to use sudo, so I am not bypassing the permissions error - which I suspect is not the root of the problem.
They don’t? I don’t remember the details, but how would darwin-rebuild work without sudo before nix.settings.trusted-users is first defined, I wonder? The rebuild command needs to elevate privileges somehow, does it not?
I am not sure (yet). I get additional errors when I use sudo that ultimately fail with the same nix error as when run without… Still will have to figure out the sudo portion.
yeah, I know Lix is supported (nix-darwin), but I have not educated myself on the differences yet and was sticking with what the rest of my flake was using (reg nix), so I didn’t introduce variables as I was learning this. I had historically messed around with my configs so much on my nixos installs that when I moved off of unstable and everything calmed down, I adopted the “only change what I need to change” method, and my Nix experience completely stabilized. So, I get hesitant with any potential “make work” changes.
ok, once I resolved the nix error, and got through the full command, I was prompted for sudo a few times. So they must account for needed escalation elsewhere and only where needed.