Skip to content

Commit

Permalink
install-multi-user: chown bootstrap store contents
Browse files Browse the repository at this point in the history
Before this change, the bootstrap store contents would be owned by the user who ran the script. This leads to inconsistencies in store path permissions, and can cause confusing issues for users (an example being zsh's compaudit being fired when attempting to use the completions from the bootstrap copy of Nix).
  • Loading branch information
winterqt committed Dec 11, 2022
1 parent 145e9a8 commit 958efd4
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions scripts/install-multi-user.sh
Original file line number Diff line number Diff line change
Expand Up @@ -810,6 +810,24 @@ install_from_extracted_nix() {
_sudo "to make the new store non-writable at $NIX_ROOT/store" \
chmod -R ugo-w "$NIX_ROOT/store/"

# This is copied from create_directories, see it for why we do all this stuff just to find chown.
local get_chr_own="$(PATH="$(getconf PATH 2>/dev/null)" command -vp chown)"
if [[ -z "$get_chr_own" ]]; then
get_chr_own="$(command -v chown)"
fi

if [[ -z "$get_chr_own" ]]; then
reminder <<EOF
I wanted to change ownership of new Nix store files,
but I couldn't locate 'chown'. (You may need to fix your PATH.)
To manually change file ownership, you can run:
sudo chown -R 'root:$NIX_BUILD_GROUP_NAME' '$NIX_ROOT'
EOF
else
_sudo "to change ownership of Nix store files" \
"$get_chr_own" -R "root:$NIX_BUILD_GROUP_NAME" "$NIX_ROOT" || true
fi

if [ -d "$NIX_INSTALLED_NIX" ]; then
echo " Alright! We have our first nix at $NIX_INSTALLED_NIX"
else
Expand Down

0 comments on commit 958efd4

Please sign in to comment.