diff options
-rw-r--r-- | alpine/Dockerfile | 18 | ||||
-rw-r--r-- | debian/Dockerfile | 18 | ||||
-rwxr-xr-x | files/.profile | 8 |
3 files changed, 23 insertions, 21 deletions
diff --git a/alpine/Dockerfile b/alpine/Dockerfile index 2c4ae1f..db794af 100644 --- a/alpine/Dockerfile +++ b/alpine/Dockerfile | |||
@@ -2,7 +2,7 @@ | |||
2 | FROM alpine | 2 | FROM alpine |
3 | 3 | ||
4 | ARG NIX_VERSION | 4 | ARG NIX_VERSION |
5 | ENV NIX_VERSION ${NIX_VERSION:-2.3.4} | 5 | ENV NIX_VERSION ${NIX_VERSION:-2.3.9} |
6 | ARG LANG | 6 | ARG LANG |
7 | ENV LANG ${LANG:-"en_US.UTF-8"} | 7 | ENV LANG ${LANG:-"en_US.UTF-8"} |
8 | 8 | ||
@@ -18,31 +18,31 @@ RUN addgroup -g 30000 -S nixbld \ | |||
18 | USER nixuser | 18 | USER nixuser |
19 | ENV USER=nixuser | 19 | ENV USER=nixuser |
20 | ENV HOME="/home/nixuser" | 20 | ENV HOME="/home/nixuser" |
21 | ENV NIX_SYSTEM_PATH="/nix/var/nix/profiles/system" | ||
22 | ENV NIX_PROFILE="$HOME/nix-envs" | ||
21 | 23 | ||
22 | RUN cd && wget https://nixos.org/releases/nix/nix-$NIX_VERSION/nix-$NIX_VERSION-x86_64-linux.tar.xz \ | 24 | RUN 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 \ | 25 | && tar xJf nix-*-x86_64-linux.tar.xz \ |
24 | && ~/nix-*-x86_64-linux/install \ | 26 | && NIX_PROFILE="$NIX_SYSTEM_PATH" ~/nix-*-x86_64-linux/install \ |
25 | && rm -rf ~/nix-*-* | 27 | && rm -rf ~/nix-*-* |
26 | 28 | ||
27 | ENV ENV="/home/nixuser/.nix-profile/etc/profile.d/nix.sh" | ||
28 | RUN echo ". ${ENV}" >> ${HOME}/.profile | ||
29 | # All subsequent "RUN" will use a login shell | 29 | # All subsequent "RUN" will use a login shell |
30 | SHELL ["/usr/bin/env", "bash", "-l", "-c"] | 30 | SHELL ["/usr/bin/env", "bash", "-l", "-c"] |
31 | 31 | ||
32 | RUN nix-channel --add https://nixos.org/channels/nixpkgs-19.09-darwin nixpkgs \ | 32 | # Create bash profile |
33 | && nix-channel --add https://nixos.org/channels/nixpkgs-unstable unstable \ | 33 | COPY --chown=nixuser:nixuser files/.profile ${HOME}/.profile |
34 | |||
35 | RUN nix-channel --add https://nixos.org/channels/nixos-unstable nixpkgs \ | ||
34 | && nix-channel --update | 36 | && nix-channel --update |
35 | 37 | ||
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 |
39 | RUN nix-env -iA nixpkgs.glibcLocales | 41 | RUN 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 |
43 | VOLUME ["/nix"] | 45 | VOLUME ["/nix"] |
44 | # Create bash profile | ||
45 | COPY --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..632a741 100644 --- a/debian/Dockerfile +++ b/debian/Dockerfile | |||
@@ -2,7 +2,7 @@ | |||
2 | FROM debian:stable-slim | 2 | FROM debian:stable-slim |
3 | 3 | ||
4 | ARG NIX_VERSION | 4 | ARG NIX_VERSION |
5 | ENV NIX_VERSION ${NIX_VERSION:-2.3.4} | 5 | ENV NIX_VERSION ${NIX_VERSION:-2.3.9} |
6 | ARG LANG | 6 | ARG LANG |
7 | ENV LANG ${LANG:-"en_US.UTF-8"} | 7 | ENV LANG ${LANG:-"en_US.UTF-8"} |
8 | 8 | ||
@@ -18,31 +18,31 @@ RUN addgroup --gid 30000 --system nixbld \ | |||
18 | USER nixuser | 18 | USER nixuser |
19 | ENV USER=nixuser | 19 | ENV USER=nixuser |
20 | ENV HOME="/home/nixuser" | 20 | ENV HOME="/home/nixuser" |
21 | ENV NIX_SYSTEM_PATH="/nix/var/nix/profiles/system" | ||
22 | ENV NIX_PROFILE="$HOME/nix-envs" | ||
21 | 23 | ||
22 | RUN cd && wget https://nixos.org/releases/nix/nix-$NIX_VERSION/nix-$NIX_VERSION-x86_64-linux.tar.xz \ | 24 | RUN 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 \ | 25 | && tar xJf nix-*-x86_64-linux.tar.xz \ |
24 | && ~/nix-*-x86_64-linux/install \ | 26 | && NIX_PROFILE="$NIX_SYSTEM_PATH" ~/nix-*-x86_64-linux/install \ |
25 | && rm -rf ~/nix-*-* | 27 | && rm -rf ~/nix-*-* |
26 | 28 | ||
27 | ENV ENV="/home/nixuser/.nix-profile/etc/profile.d/nix.sh" | ||
28 | RUN echo ". ${ENV}" >> ${HOME}/.profile | ||
29 | # All subsequent "RUN" will use a login shell | 29 | # All subsequent "RUN" will use a login shell |
30 | SHELL ["/usr/bin/env", "bash", "-l", "-c"] | 30 | SHELL ["/usr/bin/env", "bash", "-l", "-c"] |
31 | 31 | ||
32 | RUN nix-channel --add https://nixos.org/channels/nixpkgs-19.09-darwin nixpkgs \ | 32 | # Create bash profile |
33 | && nix-channel --add https://nixos.org/channels/nixpkgs-unstable unstable \ | 33 | COPY --chown=nixuser:nixuser files/.profile ${HOME}/.profile |
34 | |||
35 | RUN nix-channel --add https://nixos.org/channels/nixos-unstable nixpkgs \ | ||
34 | && nix-channel --update | 36 | && nix-channel --update |
35 | 37 | ||
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 |
39 | RUN nix-env -iA nixpkgs.glibcLocales | 41 | RUN 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 |
43 | VOLUME ["/nix"] | 45 | VOLUME ["/nix"] |
44 | # Create bash profile | ||
45 | COPY --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..80d968e 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 |
4 | nix_profile="/home/nixuser/.nix-profile/etc/profile.d/nix.sh" | 4 | nix_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 |
10 | LOCALE_ARCHIVE="$(nix-env --installed --no-name --out-path --query glibc-locales)/lib/locale/locale-archive" | 10 | LOCALE_ARCHIVE="$NIX_SYSTEM_PATH/lib/locale/locale-archive" |
11 | export LOCALE_ARCHIVE | 11 | export LOCALE_ARCHIVE |
12 | |||
13 | PATH="$NIX_PROFILE/bin:$PATH:$NIX_SYSTEM_PATH/bin" | ||