aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@fretlink.com>2020-12-16 16:53:14 +0100
committerIsmaël Bouya <ismael.bouya@fretlink.com>2020-12-16 16:53:14 +0100
commitc33369a9ffa6945cc1928986ae280563d2ec0d85 (patch)
treea2db9c51ea64c56417e4963b84010ca68f92849a
parent425ab813a99a2aec3c4ce5cc432356451aa343c3 (diff)
downloaddocker-nix-c33369a9ffa6945cc1928986ae280563d2ec0d85.tar.gz
docker-nix-c33369a9ffa6945cc1928986ae280563d2ec0d85.tar.zst
docker-nix-c33369a9ffa6945cc1928986ae280563d2ec0d85.zip
Use dedicated system path for nix
-rw-r--r--alpine/Dockerfile12
-rw-r--r--debian/Dockerfile12
-rwxr-xr-xfiles/.profile8
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 \
18USER nixuser 18USER nixuser
19ENV USER=nixuser 19ENV USER=nixuser
20ENV HOME="/home/nixuser" 20ENV HOME="/home/nixuser"
21ENV NIX_SYSTEM_PATH="/nix/var/nix/profiles/system"
21 22
22RUN cd && wget https://nixos.org/releases/nix/nix-$NIX_VERSION/nix-$NIX_VERSION-x86_64-linux.tar.xz \ 23RUN cd && wget https://nixos.org/releases/nix/nix-$NIX_VERSION/nix-$NIX_VERSION-x86_64-linux.tar.xz \
23 && tar xJf nix-*-x86_64-linux.tar.xz \ 24 && tar xJf nix-*-x86_64-linux.tar.xz \
24 && ~/nix-*-x86_64-linux/install \ 25 && NIX_PROFILE="$NIX_SYSTEM_PATH" ~/nix-*-x86_64-linux/install \
25 && rm -rf ~/nix-*-* 26 && rm -rf ~/nix-*-*
26 27
27ENV ENV="/home/nixuser/.nix-profile/etc/profile.d/nix.sh"
28RUN echo ". ${ENV}" >> ${HOME}/.profile
29# All subsequent "RUN" will use a login shell 28# All subsequent "RUN" will use a login shell
30SHELL ["/usr/bin/env", "bash", "-l", "-c"] 29SHELL ["/usr/bin/env", "bash", "-l", "-c"]
31 30
31# Create bash profile
32COPY --chown=nixuser:nixuser files/.profile ${HOME}/.profile
33
32RUN nix-channel --add https://nixos.org/channels/nixpkgs-19.09-darwin nixpkgs \ 34RUN nix-channel --add https://nixos.org/channels/nixpkgs-19.09-darwin nixpkgs \
33 && nix-channel --add https://nixos.org/channels/nixpkgs-unstable unstable \ 35 && nix-channel --add https://nixos.org/channels/nixpkgs-unstable unstable \
34 && nix-channel --update 36 && nix-channel --update
@@ -36,13 +38,11 @@ RUN nix-channel --add https://nixos.org/channels/nixpkgs-19.09-darwin nixpkgs \
36# Propagate UTF8 38# Propagate UTF8
37# https://github.com/NixOS/nix/issues/599#issuecomment-153885553 39# https://github.com/NixOS/nix/issues/599#issuecomment-153885553
38# The same is hapenning with stack2nix 40# The same is hapenning with stack2nix
39RUN nix-env -iA nixpkgs.glibcLocales 41RUN nix-env -p "$NIX_SYSTEM_PATH" -iA nixpkgs.glibcLocales
40 42
41# < Nix context as a volume 43# < Nix context as a volume
42# We want to be able to define /nix/store as a volume 44# We want to be able to define /nix/store as a volume
43VOLUME ["/nix"] 45VOLUME ["/nix"]
44# Create bash profile
45COPY --chown=nixuser:nixuser files/.profile ${HOME}/.profile
46# /> 46# />
47 47
48# Make sure to use "login" shell when running container 48# 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 \
18USER nixuser 18USER nixuser
19ENV USER=nixuser 19ENV USER=nixuser
20ENV HOME="/home/nixuser" 20ENV HOME="/home/nixuser"
21ENV NIX_SYSTEM_PATH="/nix/var/nix/profiles/system"
21 22
22RUN cd && wget https://nixos.org/releases/nix/nix-$NIX_VERSION/nix-$NIX_VERSION-x86_64-linux.tar.xz \ 23RUN cd && wget https://nixos.org/releases/nix/nix-$NIX_VERSION/nix-$NIX_VERSION-x86_64-linux.tar.xz \
23 && tar xJf nix-*-x86_64-linux.tar.xz \ 24 && tar xJf nix-*-x86_64-linux.tar.xz \
24 && ~/nix-*-x86_64-linux/install \ 25 && NIX_PROFILE="$NIX_SYSTEM_PATH" ~/nix-*-x86_64-linux/install \
25 && rm -rf ~/nix-*-* 26 && rm -rf ~/nix-*-*
26 27
27ENV ENV="/home/nixuser/.nix-profile/etc/profile.d/nix.sh"
28RUN echo ". ${ENV}" >> ${HOME}/.profile
29# All subsequent "RUN" will use a login shell 28# All subsequent "RUN" will use a login shell
30SHELL ["/usr/bin/env", "bash", "-l", "-c"] 29SHELL ["/usr/bin/env", "bash", "-l", "-c"]
31 30
31# Create bash profile
32COPY --chown=nixuser:nixuser files/.profile ${HOME}/.profile
33
32RUN nix-channel --add https://nixos.org/channels/nixpkgs-19.09-darwin nixpkgs \ 34RUN nix-channel --add https://nixos.org/channels/nixpkgs-19.09-darwin nixpkgs \
33 && nix-channel --add https://nixos.org/channels/nixpkgs-unstable unstable \ 35 && nix-channel --add https://nixos.org/channels/nixpkgs-unstable unstable \
34 && nix-channel --update 36 && nix-channel --update
@@ -36,13 +38,11 @@ RUN nix-channel --add https://nixos.org/channels/nixpkgs-19.09-darwin nixpkgs \
36# Propagate UTF8 38# Propagate UTF8
37# https://github.com/NixOS/nix/issues/599#issuecomment-153885553 39# https://github.com/NixOS/nix/issues/599#issuecomment-153885553
38# The same is hapenning with stack2nix 40# The same is hapenning with stack2nix
39RUN nix-env -iA nixpkgs.glibcLocales 41RUN nix-env -p "$NIX_SYSTEM_PATH" -iA nixpkgs.glibcLocales
40 42
41# < Nix context as a volume 43# < Nix context as a volume
42# We want to be able to define /nix/store as a volume 44# We want to be able to define /nix/store as a volume
43VOLUME ["/nix"] 45VOLUME ["/nix"]
44# Create bash profile
45COPY --chown=nixuser:nixuser files/.profile ${HOME}/.profile
46# /> 46# />
47 47
48# Make sure to use "login" shell when running container 48# 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 @@
1#!/usr/bin/env bash 1#!/usr/bin/env bash
2 2
3# Source nix environment 3# Source nix environment
4nix_profile="/home/nixuser/.nix-profile/etc/profile.d/nix.sh" 4nix_profile="$NIX_SYSTEM_PATH/etc/profile.d/nix.sh"
5# shellcheck source=/home/nixuser/.nix-profile/etc/profile.d/nix.sh 5# shellcheck source=$NIX_SYSTEM_PATH/etc/profile.d/nix.sh
6[ -e "${nix_profile}" ] && . "${nix_profile}" 6[ -e "${nix_profile}" ] && . "${nix_profile}"
7 7
8# Propagate UTF8 8# Propagate UTF8
9# https://github.com/NixOS/nix/issues/599#issuecomment-153885553 9# https://github.com/NixOS/nix/issues/599#issuecomment-153885553
10LOCALE_ARCHIVE="$(nix-env --installed --no-name --out-path --query glibc-locales)/lib/locale/locale-archive" 10LOCALE_ARCHIVE="$NIX_SYSTEM_PATH/lib/locale/locale-archive"
11export LOCALE_ARCHIVE 11export LOCALE_ARCHIVE
12
13PATH="$PATH:$NIX_SYSTEM_PATH/bin"