fix: grant coder user ownership of /nix for single-user mode#12
Merged
megheaiulian merged 1 commit intomainfrom Feb 10, 2026
Merged
fix: grant coder user ownership of /nix for single-user mode#12megheaiulian merged 1 commit intomainfrom
megheaiulian merged 1 commit intomainfrom
Conversation
The Nix store database (/nix/var/nix/db/) is owned by root after image build, causing 'Permission denied' when the coder user runs nix commands like 'nix develop'. Grant ownership of the entire /nix tree to the coder user (uid 1000) so single-user Nix operations can acquire locks and write to the store without requiring a daemon.
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.
Summary
Permission deniederror when runningnix develop(or any Nix command that needs store access) as thecoderuserchown -R 1000:1000 ./nixinfakeRootCommandsso the coder user owns the entire/nixtree, allowing single-user Nix operations to acquire locks and write to the store/db without a daemonProblem
The image is built with
buildLayeredImageWithNixDb, which populates the Nix database at build time. The/nix/var/nix/db/directory ends up owned by root, but the container runs as usercoder(uid 1000). In single-user mode (no Nix daemon), Nix commands need direct write access to the store and database, resulting in: