cli: only warn about mount namespace when the store actually needs remounting#15547
Open
amaanq wants to merge 1 commit intoNixOS:masterfrom
Open
cli: only warn about mount namespace when the store actually needs remounting#15547amaanq wants to merge 1 commit intoNixOS:masterfrom
amaanq wants to merge 1 commit intoNixOS:masterfrom
Conversation
xokdvium
reviewed
Apr 20, 2026
xokdvium
reviewed
Apr 20, 2026
Eveeifyeve
approved these changes
Apr 20, 2026
bb604ae to
38c67fe
Compare
38c67fe to
8e3ee73
Compare
Previously, when unshare(CLONE_NEWNS) failed and the store was read-only, Nix warned but still remounted the store writable on the host mount table. This silently affected other processes sharing the namespace. Now it throws an error, since proceeding would mutate shared state.
8e3ee73 to
bd160f9
Compare
xokdvium
reviewed
Apr 21, 2026
| @@ -13,9 +13,24 @@ namespace nix { | |||
| */ | |||
| void saveMountNamespace(); | |||
Contributor
There was a problem hiding this comment.
Can this function be made static now?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
The previous warning in
main.ccfired on every invocation as root whenunshare(CLONE_NEWNS)failed, which is noisy in containers. Move the warning tomakeStoreWritable()so it only triggers when the store is read-only and we lack a private mount namespace, i.e. when the remount would actually leak into the host mount table. Also switch frome.msg()toe.message()to avoid the redundant "error: " prefix.Context
@xokdvium and I chatted about this in the Nix meeting yesterday
Add 👍 to pull requests you find important.
The Nix maintainer team uses a GitHub project board to schedule and track reviews.