I am trying to install Nix on Ubuntu 24.04.4 LTS, and the installer is failing with permission issues for files it is creating. I am installing with the following command, per the documentation:
curl --proto ‘=https’ --tlsv1.2 -L ``https://nixos.org/nix/install`` | sh -s – --daemon
After user creation, the installation fails with the following message:
~~> Installing Nix
Alright! We have our first nix at /nix/store/v2s32a5zyxbq681gvdab224xmln4hzg4-nix-2.34.8
Just finished getting the nix database ready.
~~> Setting up shell profiles: /etc/bashrc /etc/profile.d/nix.sh /etc/zshrc /etc/bash.bashrc /etc/zsh/zshrc
cat: /etc/bashrc: Permission denied
Nix
if [ -e ‘/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh’ ]; then
. ‘/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh’
fi
End Nix
Sure enough, the /etc/bashrc file has only read/write permissions for the root user. In an attempt to get around this issue, I tried setting permissions manually with sudo chmod 644 /etc/bashrc, and reran the installer. This resulted in the same permission issue, now for a different file, /etc/zshrc. Attempting the same fix for this file and re-running the installer a third time results in an early exit due to an existing Nix installation being detected.
I dug a bit into why the file permissions are being set this way, and the Nix installer seems to be generating the files, despite there already being an existing bashrc file at /etc/bash.bashrc.