From 69e78059bbb77963e372b3355ad7331195874f84 Mon Sep 17 00:00:00 2001 From: Iulian Meghea Date: Thu, 26 Feb 2026 10:25:59 +0000 Subject: [PATCH 1/2] fix: make Nix survive home volume mount in devops image 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. --- images/devops/Dockerfile | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/images/devops/Dockerfile b/images/devops/Dockerfile index 40fafb2..9cd7451 100644 --- a/images/devops/Dockerfile +++ b/images/devops/Dockerfile @@ -35,6 +35,10 @@ rm -rf /var/lib/apt/lists/* # Create /nix owned by coder for single-user Nix install mkdir -p /nix chown coder:coder /nix + +# Enable flakes and nix-command (system-wide, outside home volume) +mkdir -p /etc/nix +echo 'experimental-features = nix-command flakes' > /etc/nix/nix.conf EOF USER coder @@ -42,8 +46,11 @@ USER coder # Install Nix in single-user mode (no daemon, no systemd required) RUN curl -L https://nixos.org/nix/install | sh -s -- --no-daemon -# Enable flakes and nix-command -RUN mkdir -p ~/.config/nix && \ - echo 'experimental-features = nix-command flakes' > ~/.config/nix/nix.conf - -ENV PATH="/home/coder/.nix-profile/bin:${PATH}" +# Symlink nix binaries into /usr/local/bin so they survive the home volume mount. +# We resolve through ~/.nix-profile (which exists at build time) to the real +# /nix/store/… paths that persist outside the home directory. +USER root +RUN for bin in /home/coder/.nix-profile/bin/nix*; do \ + ln -s "$(readlink -f "$bin")" /usr/local/bin/; \ + done +USER coder From 94b316ecb24810175c7a2795309a76605d22d140 Mon Sep 17 00:00:00 2001 From: Iulian Meghea Date: Thu, 26 Feb 2026 12:02:41 +0000 Subject: [PATCH 2/2] fix: use explicit link names to avoid collisions from readlink -f 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. --- images/devops/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/images/devops/Dockerfile b/images/devops/Dockerfile index 9cd7451..9a17e0f 100644 --- a/images/devops/Dockerfile +++ b/images/devops/Dockerfile @@ -51,6 +51,6 @@ RUN curl -L https://nixos.org/nix/install | sh -s -- --no-daemon # /nix/store/… paths that persist outside the home directory. USER root RUN for bin in /home/coder/.nix-profile/bin/nix*; do \ - ln -s "$(readlink -f "$bin")" /usr/local/bin/; \ + ln -s "$(readlink -f "$bin")" "/usr/local/bin/$(basename "$bin")"; \ done USER coder