Can I install nix as root

I am trying to install nix as a multi-user setup.
Can I install as root?
On CentOS 7 I am not able to install as root?
I get the following error:
“Please do not run this script with root privileges. I will call sudo when I need to.”

I have a test VM that I use infrequently and want to install few applications via nix. As its infrequent I only add the root user. Hence I am not able to install nix without creating a new user. I also was not able to find any option to ‘force’ install as root.

The installer does not accept to be run as root, you could remove the checks for that, but then there will be no support for any problems you might have during and/or after the installation.

Despite how often you use or not use the machine, you really should only use an unpriviliged user for everything and use sudo once you really need the elevated permissions.

Can you point me to the checks for root ?
I am using command “sh <(curl -L https://nixos.org/nix/install) --daemon”

That command downloads a script and pipes it to sh. I’d really like to stress that you’re entering uncharted territory.

That said, if you get rid of the sh <() --daemon it will download the script instead, from where you can make changes how you see fit.

You will probably end up destroying this VM at some point in the process, make sure there’s nothing valuable on it.

1 Like

The install script should be pretty safe to retry a few times. I still think using a VM from a clean state is a good idea to have a clean state everytime. You shouldn’t be able to permanently brick anything.

You’re looking for nix/install-multi-user.sh at 8977cdee6aac8ef3238b28543199572150929bab · NixOS/nix · GitHub

Here’s a rough outline of the steps to download and edit the install script: `install-multi-user.sh` asks user to "edit this script" when it's invoked by the `curl | sh` script · Issue #4915 · NixOS/nix · GitHub