Skip to content

packaging/scripted-installer: Only chown pre-existing files when needed - #16785

Merged
xokdvium merged 3 commits into
masterfrom
multi-user-install-chown-take-2
Nov 9, 2026
Merged

xokdvium merged 3 commits into
masterfrom
multi-user-install-chown-take-2

Conversation

@xokdvium

@xokdvium xokdvium commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

Partially reverts 9533d33, modulo the 0:0 vs
0:nixbld ownership. I got a bit overzealous deleting code and it did turn out
load-bearing.

So apparently not even root can chown /nix/.Trashes on macOS (╯°□°)╯︵ ┻━┻
This is quite impossible to test in CI too?

Because of #13719, we leave /nix/store/*
objects alone that have nixbld group ownership for now. Chowning them to root
might be impossible because of App Management on macOS (e.g. xcode store objects).
Also older installers messed this part up.

/nix/var/nix/builds/* is ignored entirely.

Implementation


Add 👍 to pull requests you find important.

The Nix maintainer team uses a GitHub project board to schedule and track reviews.

@xokdvium
xokdvium requested a review from edolstra as a code owner November 8, 2026 19:04
@xokdvium
xokdvium force-pushed the multi-user-install-chown-take-2 branch 3 times, most recently from c3d2be8 to 692ae8b Compare November 8, 2026 19:19

@lisanna-dettwyler lisanna-dettwyler left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Insanity

@xokdvium

xokdvium commented Nov 8, 2026

Copy link
Copy Markdown
Contributor Author

I at least hope that macos flavor of find supports all the right flags... Let's see what the CI says.

@xokdvium
xokdvium marked this pull request as draft November 8, 2026 19:25
@xokdvium
xokdvium force-pushed the multi-user-install-chown-take-2 branch 3 times, most recently from 8869fc2 to e60894c Compare November 8, 2026 20:09
@xokdvium
xokdvium force-pushed the multi-user-install-chown-take-2 branch 4 times, most recently from 599e119 to 1285d77 Compare November 9, 2026 00:00
Partially reverts 9533d33, modulo the 0:0 vs
0:nixbld ownership. I got a bit overzealous deleting code and it did turn out
load-bearing.

So apparently not even root can chown /nix/.Trashes on macOS (╯°□°)╯︵ ┻━┻
This is quite impossible to test in CI too?

Because of #13719, we leave /nix/store/*
objects alone that have nixbld group ownership for now. Chowning them to root
might be impossible because of App Management on macOS (e.g. xcode store objects).
Also older installers messed this part up.

/nix/var/nix/builds/* is ignored entirely.
@xokdvium
xokdvium force-pushed the multi-user-install-chown-take-2 branch from 1285d77 to db97f25 Compare November 9, 2026 00:03
The -n trick doesn't work on macOS sadly. So instead we can delete
the bootstrap closure and replace it afterwards. --load-db re-registers
existing valid paths so it should be fine.
App Management also denies changing the mode of apps in the store.
If the user is running the installer over an existing install this might (and will)
blow up if they have apps in the store.
@xokdvium

xokdvium commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

Now actually made this work on macOS for installing over an existing install (no full disk access). I'm a bit uneasy about ignoring failures, but it's now scoped only to macOS. Some failures are also unavoidable due to App Management so I don't know what a better fix could entail.

@xokdvium
xokdvium marked this pull request as ready for review November 9, 2026 13:57
@xokdvium xokdvium added installer macos Nix on macOS, aka OS X, aka darwin regression Something doesn't work anymore labels Nov 9, 2026
@github-project-automation github-project-automation Bot moved this to Triage in Nix team Nov 9, 2026
Comment on lines +843 to +846
if [ "${#colliding_files[@]}" -gt 0 ]; then
_sudo "to remove colliding closure files in $NIX_ROOT/store before copying" \
rm -rf "${colliding_files[@]}"
fi

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This bit is somewhat scary to me, but it does seem it's a good middle ground for starting with a fresh state. Since --load-db re-registers previously valid paths this might lead to a bit of mismatch.

It's idempotent of course, but not too resilient against interruptions (although the current installer already isn't convenient to modify an existing installation).

@xokdvium
xokdvium added this pull request to the merge queue Nov 9, 2026
Merged via the queue into master with commit 16fa212 Nov 9, 2026
23 checks passed
@xokdvium
xokdvium deleted the multi-user-install-chown-take-2 branch November 9, 2026 14:49
@github-project-automation github-project-automation Bot moved this from Triage to Done in Nix team Nov 9, 2026
@xokdvium xokdvium added the backport 2.35-maintenance Automatically creates a PR against the branch label Nov 9, 2026
@internal-nix-ci

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport 2.35-maintenance Automatically creates a PR against the branch installer macos Nix on macOS, aka OS X, aka darwin regression Something doesn't work anymore

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants