]> git.immae.eu Git - github/fretlink/docker-nix.git/blame - debian/Dockerfile
Remove sandbox=false
[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
d7db3dbc 5ENV NIX_VERSION ${NIX_VERSION:-2.3.9}
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 \
788f0fc5 13 && apt update && apt install -y wget xz-utils \
e6f85a81 14 && apt clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \
516309b3 15 && mkdir -p /etc/nix && touch /etc/nix/nix.conf
89f0519e
P
16
17USER nixuser
18ENV USER=nixuser
19ENV HOME="/home/nixuser"
c33369a9 20ENV NIX_SYSTEM_PATH="/nix/var/nix/profiles/system"
62b9189f 21ENV NIX_PROFILE="$HOME/nix-envs"
89f0519e 22
788f0fc5
PB
23RUN cd && wget https://nixos.org/releases/nix/nix-$NIX_VERSION/nix-$NIX_VERSION-x86_64-linux.tar.xz \
24 && tar xJf nix-*-x86_64-linux.tar.xz \
c33369a9 25 && NIX_PROFILE="$NIX_SYSTEM_PATH" ~/nix-*-x86_64-linux/install \
89f0519e
P
26 && rm -rf ~/nix-*-*
27
75cabc50 28# All subsequent "RUN" will use a login shell
89f0519e 29SHELL ["/usr/bin/env", "bash", "-l", "-c"]
75cabc50 30
c33369a9
IB
31# Create bash profile
32COPY --chown=nixuser:nixuser files/.profile ${HOME}/.profile
33
d7db3dbc 34RUN nix-channel --add https://nixos.org/channels/nixos-unstable nixpkgs \
4d15def7 35 && nix-channel --update
75cabc50
P
36
37# Propagate UTF8
38# https://github.com/NixOS/nix/issues/599#issuecomment-153885553
39# The same is hapenning with stack2nix
c33369a9 40RUN nix-env -p "$NIX_SYSTEM_PATH" -iA nixpkgs.glibcLocales
63ece951
PB
41
42# < Nix context as a volume
43# We want to be able to define /nix/store as a volume
63ece951 44VOLUME ["/nix"]
63ece951 45# />
75cabc50
P
46
47# Make sure to use "login" shell when running container
95f6e232 48ENTRYPOINT ["/usr/bin/env", "bash", "-l", "-c"]