Registry.json and permission issues - nix-darwin

Hi there,

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.

cheers!

I seem to remember nix-darwin requiring sudo when I was using it. Maybe give that a try?

Alternatively maybe you can try Lix if the Nix install is 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?

A kind Mastodon user pointed me to using:

nix --extra-experimental-features flakes --extra-experimental-features nix-command run github:LnL7/nix-darwin/nix-darwin-24.11#darwin-rebuild -- switch --flake .#dustinkrysak

Note the github:LnL7.... - that’s what I added. And now I am just getting what looks to be standard nix errors. :rofl:

I may ultimately need to use sudo, but at least I am now past this issue.

1 Like

I had tried sudo, but then I was getting complains about:

warning: $HOME ('/Users/dustin.krysak') is not owned by you, falling back to the one defined in the 'passwd' file ('/var/root')

And then eventually fails with the same nix error I get when running without sudo.

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. :rofl:

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.