From c33369a9ffa6945cc1928986ae280563d2ec0d85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Isma=C3=ABl=20Bouya?= Date: Wed, 16 Dec 2020 16:53:14 +0100 Subject: Use dedicated system path for nix --- alpine/Dockerfile | 12 ++++++------ debian/Dockerfile | 12 ++++++------ files/.profile | 8 +++++--- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/alpine/Dockerfile b/alpine/Dockerfile index 2c4ae1f..5399610 100644 --- a/alpine/Dockerfile +++ b/alpine/Dockerfile @@ -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 diff --git a/debian/Dockerfile b/debian/Dockerfile index e5d410e..52eb820 100644 --- a/debian/Dockerfile +++ b/debian/Dockerfile @@ -18,17 +18,19 @@ RUN addgroup --gid 30000 --system 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 diff --git a/files/.profile b/files/.profile index 2fadec2..e705bc0 100755 --- a/files/.profile +++ b/files/.profile @@ -1,11 +1,13 @@ #!/usr/bin/env bash # Source nix environment -nix_profile="/home/nixuser/.nix-profile/etc/profile.d/nix.sh" -# shellcheck source=/home/nixuser/.nix-profile/etc/profile.d/nix.sh +nix_profile="$NIX_SYSTEM_PATH/etc/profile.d/nix.sh" +# shellcheck source=$NIX_SYSTEM_PATH/etc/profile.d/nix.sh [ -e "${nix_profile}" ] && . "${nix_profile}" # Propagate UTF8 # https://github.com/NixOS/nix/issues/599#issuecomment-153885553 -LOCALE_ARCHIVE="$(nix-env --installed --no-name --out-path --query glibc-locales)/lib/locale/locale-archive" +LOCALE_ARCHIVE="$NIX_SYSTEM_PATH/lib/locale/locale-archive" export LOCALE_ARCHIVE + +PATH="$PATH:$NIX_SYSTEM_PATH/bin" -- cgit v1.2.3 From 62b9189f2da7d9b0804f38d564a1efed1e5db0fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Isma=C3=ABl=20Bouya?= Date: Wed, 16 Dec 2020 17:07:17 +0100 Subject: Use a profile folder outside of /nix/var --- alpine/Dockerfile | 1 + debian/Dockerfile | 1 + files/.profile | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/alpine/Dockerfile b/alpine/Dockerfile index 5399610..f6ea60c 100644 --- a/alpine/Dockerfile +++ b/alpine/Dockerfile @@ -19,6 +19,7 @@ USER nixuser ENV USER=nixuser ENV HOME="/home/nixuser" ENV NIX_SYSTEM_PATH="/nix/var/nix/profiles/system" +ENV NIX_PROFILE="$HOME/nix-envs" 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 \ diff --git a/debian/Dockerfile b/debian/Dockerfile index 52eb820..edc605c 100644 --- a/debian/Dockerfile +++ b/debian/Dockerfile @@ -19,6 +19,7 @@ USER nixuser ENV USER=nixuser ENV HOME="/home/nixuser" ENV NIX_SYSTEM_PATH="/nix/var/nix/profiles/system" +ENV NIX_PROFILE="$HOME/nix-envs" 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 \ diff --git a/files/.profile b/files/.profile index e705bc0..80d968e 100755 --- a/files/.profile +++ b/files/.profile @@ -10,4 +10,4 @@ nix_profile="$NIX_SYSTEM_PATH/etc/profile.d/nix.sh" LOCALE_ARCHIVE="$NIX_SYSTEM_PATH/lib/locale/locale-archive" export LOCALE_ARCHIVE -PATH="$PATH:$NIX_SYSTEM_PATH/bin" +PATH="$NIX_PROFILE/bin:$PATH:$NIX_SYSTEM_PATH/bin" -- cgit v1.2.3 From d7db3dbcf09fe8940319777df11c956bb78dddd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Isma=C3=ABl=20Bouya?= Date: Thu, 17 Dec 2020 14:52:08 +0100 Subject: Upgrade nix version --- alpine/Dockerfile | 5 ++--- debian/Dockerfile | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/alpine/Dockerfile b/alpine/Dockerfile index f6ea60c..db794af 100644 --- a/alpine/Dockerfile +++ b/alpine/Dockerfile @@ -2,7 +2,7 @@ FROM alpine ARG NIX_VERSION -ENV NIX_VERSION ${NIX_VERSION:-2.3.4} +ENV NIX_VERSION ${NIX_VERSION:-2.3.9} ARG LANG ENV LANG ${LANG:-"en_US.UTF-8"} @@ -32,8 +32,7 @@ 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 \ +RUN nix-channel --add https://nixos.org/channels/nixos-unstable nixpkgs \ && nix-channel --update # Propagate UTF8 diff --git a/debian/Dockerfile b/debian/Dockerfile index edc605c..632a741 100644 --- a/debian/Dockerfile +++ b/debian/Dockerfile @@ -2,7 +2,7 @@ FROM debian:stable-slim ARG NIX_VERSION -ENV NIX_VERSION ${NIX_VERSION:-2.3.4} +ENV NIX_VERSION ${NIX_VERSION:-2.3.9} ARG LANG ENV LANG ${LANG:-"en_US.UTF-8"} @@ -32,8 +32,7 @@ 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 \ +RUN nix-channel --add https://nixos.org/channels/nixos-unstable nixpkgs \ && nix-channel --update # Propagate UTF8 -- cgit v1.2.3