Nix on MacOS 11.7 (Big Sur) user/permissions errors

Hello, I’m getting the following error with a mult-user Nix installation on my 2013 Macbook Pro.

I recently had a repair done at a local Mac repair shop, and created a new Admin account for them to run diagnostics. They may have deleted or chowned the wrong the folder or something and caused this.

My main user account is “byron” and it’s an admin account, and is the account I used to install Nix, but it’s not showing up in /nix/var/nix/profiles/per-user/. Anyone know what might have caused this, and how to fix it?

$> nix-env -uv
…
error: opening lock file '/nix/var/nix/profiles/per-user/byron/profile.lock': No such file or directory
$> ls /nix/var/nix/profiles/per-user
total 0
drwxr-xr-x  3 root  nixbld   96 Oct  6 09:27 .
drwxr-xr-x  9 root  nixbld  288 Dec 12 21:04 ..
drwxr-xr-x  5 root  nixbld  160 Dec 12 21:04 root
$> whoami
byron
$> sudo nix-env -uv
error:
       … while trying to find an upgrade for 'nix-2.18.1'

       … in the right operand of the update (//) operator

         at /nix/store/b9l8kawzv1kndn20gly0p96cx3biwvwg-nixpkgs/nixpkgs/pkgs/stdenv/generic/check-meta.nix:466:5:

          465|     }
          466|     // attrs.meta or { }
             |     ^
          467|     # Fill `meta.position` to identify the source location of the package.

       … in the left operand of the update (//) operator

         at /nix/store/b9l8kawzv1kndn20gly0p96cx3biwvwg-nixpkgs/nixpkgs/pkgs/stdenv/generic/check-meta.nix:468:5:

          467|     # Fill `meta.position` to identify the source location of the package.
          468|     // optionalAttrs (pos != null) {
             |     ^
          469|       position = pos.file + ":" + toString pos.line;

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: Unsupported Nix system: x86_64-darwin
$> nix upgrade-nix
replacing old 'nix-2.18.1'
installing 'nix-2.18.1'
building '/nix/store/4x9098ncangw7w5wxa4j350shdxl7fqf-user-environment.drv'...
error: opening lock file '/nix/var/nix/profiles/default.lock': Permission denied
error: program '/nix/store/aapb4b2gah70km3vq0b50qky25hkcdnm-nix-2.18.1/bin/nix-env' failed with exit code 1
$> sudo nix upgrade-nix
Password:
warning: $HOME ('/Users/byron') is not owned by you, falling back to the one defined in the 'passwd' file ('/var/root')
downloading 'https://github.com/NixOS/nixpkgs/raw/master/nixos/modules/installer/tools/nix-fallback-paths.nix'warning: $HOME ('/Users/byron') is not owned by you, falling back to the one defined in the 'passwd' file ('/var/root')
warning: $HOME ('/Users/byron') is not owned by you, falling back to the one defined in the 'passwd' file ('/var/root')
replacing old 'nix-2.18.1'
installing 'nix-2.18.1'

Update: Somehow the errors stopped and everything works fine now. Not sure what I did though.

1 Like