]> git.immae.eu Git - github/fretlink/docker-nix.git/blame - alpine/Dockerfile
chore(nix-cli): upgrade from 2.1.3 to 2.2.1
[github/fretlink/docker-nix.git] / alpine / Dockerfile
CommitLineData
89f0519e
P
1# Dockerfile to create an environment that contains the Nix package manager.
2FROM alpine
3
4ARG NIX_VERSION
e6f85a81 5ENV NIX_VERSION ${NIX_VERSION:-2.2.1}
c223b406
P
6ARG LANG
7ENV LANG ${LANG:-"en_US.UTF-8"}
89f0519e
P
8
9RUN addgroup -g 30000 -S nixbld \
10 && for i in $(seq 1 30); do adduser -S -D -h /var/empty -g "Nix build user $i" -u $((30000 + i)) -G nixbld nixbld$i ; done \
11 && adduser -D nixuser \
12 && mkdir -m 0755 /nix && chown nixuser /nix \
13 && apk add --no-cache bash \
e6f85a81
HAL
14 && rm -rf /var/cache/apk/* \
15 # sandboxing enabled by default since 2.2
16 && mkdir -p /etc/nix && echo 'sandbox = false' > /etc/nix/nix.conf
89f0519e
P
17
18USER nixuser
19ENV USER=nixuser
20ENV HOME="/home/nixuser"
21
22RUN cd && wget https://nixos.org/releases/nix/nix-$NIX_VERSION/nix-$NIX_VERSION-x86_64-linux.tar.bz2 \
23 && tar xjf nix-*-x86_64-linux.tar.bz2 \
24 && ~/nix-*-x86_64-linux/install \
25 && rm -rf ~/nix-*-*
26
27ENV ENV="/home/nixuser/.nix-profile/etc/profile.d/nix.sh"
c223b406 28RUN echo ". ${ENV}" >> ${HOME}/.profile
75cabc50 29# All subsequent "RUN" will use a login shell
89f0519e 30SHELL ["/usr/bin/env", "bash", "-l", "-c"]
75cabc50 31
4d15def7
HAL
32RUN nix-channel --add https://nixos.org/channels/nixpkgs-19.03-darwin nixpkgs \
33 && nix-channel --add https://nixos.org/channels/nixpkgs-unstable unstable \
34 && nix-channel --update
75cabc50
P
35
36# Propagate UTF8
37# https://github.com/NixOS/nix/issues/599#issuecomment-153885553
38# The same is hapenning with stack2nix
39RUN nix-env -iA nixpkgs.glibcLocales \
40 && echo "export LOCALE_ARCHIVE=$(nix-env --installed --no-name --out-path --query glibc-locales)/lib/locale/locale-archive" >> ${HOME}/.profile
41
42# Make sure to use "login" shell when running container
95f6e232 43ENTRYPOINT ["/usr/bin/env", "bash", "-l", "-c"]