fix: make Nix survive home volume mount in devops image#17
Merged
Conversation
Move nix.conf to /etc/nix/ (system-wide, outside the home volume) and symlink nix binaries from /usr/local/bin to their resolved /nix/store paths. This avoids relying on ~/.nix-profile or ~/.config which are wiped when Coder mounts a persistent volume over /home/coder.
Multiple nix-* binaries (nix-build, nix-env, etc.) resolve to the same /nix/store/.../bin/nix target. Using 'ln -s target /usr/local/bin/' takes the basename from the target, causing all links to collide on /usr/local/bin/nix. Fix by explicitly naming each link with basename of the original profile binary.
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
Fixes the Nix installation in the devops image so it works at runtime when Coder mounts a persistent volume over
/home/coder.Problem
PR #15 installed Nix correctly at build time, but two things broke at runtime:
~/.config/nix/nix.conf(flakes config) — wiped by the home volume mount~/.nix-profile/bin(added to PATH viaENV) — the symlink doesn't exist on the mounted volume, sonixis not foundFix
nix.confto/etc/nix/nix.conf— system-wide config, outside the home directory/usr/local/bin/— at build time, resolve~/.nix-profile/bin/nix*through to the real/nix/store/…paths (which persist outside the home volume) and create symlinks in/usr/local/bin/which is already on$PATHENV PATH— no longer needed since/usr/local/binis already on the default PATH~/.config/nixcreation — replaced by the system-wide configWhy this works
/nix/(store + var) is outside the home volume and survives workspace restarts/etc/nix/nix.confis outside the home volume/usr/local/bin/is outside the home volumereadlink -fto resolve to absolute/nix/store/…paths, so they don't depend on~/.nix-profileexisting at runtime