]> git.immae.eu Git - github/fretlink/docker-nix.git/blobdiff - alpine/Dockerfile
Use dedicated system path for nix
[github/fretlink/docker-nix.git] / alpine / Dockerfile
index 2c4ae1f812edd74afec73db38206086a49b257a2..5399610f89c3ccf7acb7149c86a403d946b49732 100644 (file)
@@ -18,17 +18,19 @@ RUN addgroup -g 30000 -S nixbld \
 USER nixuser
 ENV USER=nixuser
 ENV HOME="/home/nixuser"
+ENV NIX_SYSTEM_PATH="/nix/var/nix/profiles/system"
 
 RUN cd && wget https://nixos.org/releases/nix/nix-$NIX_VERSION/nix-$NIX_VERSION-x86_64-linux.tar.xz \
     && tar xJf nix-*-x86_64-linux.tar.xz \
-    && ~/nix-*-x86_64-linux/install \
+    && NIX_PROFILE="$NIX_SYSTEM_PATH" ~/nix-*-x86_64-linux/install \
     && rm -rf ~/nix-*-*
 
-ENV ENV="/home/nixuser/.nix-profile/etc/profile.d/nix.sh"
-RUN echo ". ${ENV}" >> ${HOME}/.profile
 # All subsequent "RUN" will use a login shell
 SHELL ["/usr/bin/env", "bash", "-l", "-c"]
 
+# Create bash profile
+COPY --chown=nixuser:nixuser files/.profile ${HOME}/.profile
+
 RUN nix-channel --add https://nixos.org/channels/nixpkgs-19.09-darwin nixpkgs \
     && nix-channel --add https://nixos.org/channels/nixpkgs-unstable unstable \
     && nix-channel --update
@@ -36,13 +38,11 @@ RUN nix-channel --add https://nixos.org/channels/nixpkgs-19.09-darwin nixpkgs \
 # Propagate UTF8
 # https://github.com/NixOS/nix/issues/599#issuecomment-153885553
 # The same is hapenning with stack2nix
-RUN nix-env -iA nixpkgs.glibcLocales
+RUN nix-env -p "$NIX_SYSTEM_PATH" -iA nixpkgs.glibcLocales
 
 # < Nix context as a volume
 # We want to be able to define /nix/store as a volume
 VOLUME ["/nix"]
-# Create bash profile
-COPY --chown=nixuser:nixuser files/.profile ${HOME}/.profile
 # />
 
 # Make sure to use "login" shell when running container