Error on nixos-rebuild with an empty configuration file

I am running nixos under VirtualBox. I was using it a few weeks ago with no problems. Today, I made a small configuration script and had some problems, so I decided to keep cutting out parts to find out what caused the problem. Eventually I had an empty configuration script. Still errors. So, I loaded a new vm with nixos and ran nixos-rebuild on a completely virgin image, and still had the error. I don’t remember it doing this a few weeks ago.

The error message is
error: creating symlink from ‘/nix/var/nix/profiles/system-2-link.tmp-2593-1723222645’ to ‘/nix/store/…’: Permission denied

This happens after it has finished building a new system, and it is basically adding a link to the new system to /nix/var/nix/profiles.

I started off seeing this with nixos 18.09 but then tried it with nixos 18.03 and got the same result.

Any ideas what to do?

I didn’t remember that nixos-rebuild needed to be run as root. Dumb mistake.

1 Like