]> git.immae.eu Git - github/fretlink/docker-nix.git/blame - debian/Dockerfile
Add debian based images
[github/fretlink/docker-nix.git] / debian / Dockerfile
CommitLineData
89f0519e 1# Dockerfile to create an environment that contains the Nix package manager.
0366f366 2FROM debian:stable-slim
89f0519e
P
3
4ARG NIX_VERSION
5ENV NIX_VERSION ${NIX_VERSION:-2.1.3}
c223b406
P
6ARG LANG
7ENV LANG ${LANG:-"en_US.UTF-8"}
89f0519e 8
0366f366
P
9RUN addgroup --gid 30000 --system nixbld \
10 && for i in $(seq 1 30); do adduser --system --disabled-password --home /var/empty --gecos "Nix build user $i" --uid $((30000 + i)) --ingroup nixbld nixbld$i ; done \
11 && adduser --disabled-password nixuser \
89f0519e 12 && mkdir -m 0755 /nix && chown nixuser /nix \
0366f366
P
13 && apt update && apt install -y wget bzip2 \
14 && apt clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
89f0519e
P
15
16USER nixuser
17ENV USER=nixuser
18ENV HOME="/home/nixuser"
19
20RUN cd && wget https://nixos.org/releases/nix/nix-$NIX_VERSION/nix-$NIX_VERSION-x86_64-linux.tar.bz2 \
21 && tar xjf nix-*-x86_64-linux.tar.bz2 \
22 && ~/nix-*-x86_64-linux/install \
23 && rm -rf ~/nix-*-*
24
25ENV ENV="/home/nixuser/.nix-profile/etc/profile.d/nix.sh"
c223b406 26RUN echo ". ${ENV}" >> ${HOME}/.profile
75cabc50 27# All subsequent "RUN" will use a login shell
89f0519e 28SHELL ["/usr/bin/env", "bash", "-l", "-c"]
75cabc50
P
29
30RUN nix-channel --add https://nixos.org/channels/nixpkgs-unstable \
31 && nix-channel --update
32
33# Propagate UTF8
34# https://github.com/NixOS/nix/issues/599#issuecomment-153885553
35# The same is hapenning with stack2nix
36RUN nix-env -iA nixpkgs.glibcLocales \
37 && echo "export LOCALE_ARCHIVE=$(nix-env --installed --no-name --out-path --query glibc-locales)/lib/locale/locale-archive" >> ${HOME}/.profile
38
39# Make sure to use "login" shell when running container
95f6e232 40ENTRYPOINT ["/usr/bin/env", "bash", "-l", "-c"]