]> git.immae.eu Git - github/fretlink/docker-nix.git/blob - debian/Dockerfile
Merge pull request #11 from ismaelbouyaf/remove-sandbox-false
[github/fretlink/docker-nix.git] / debian / Dockerfile
1 # Dockerfile to create an environment that contains the Nix package manager.
2 FROM debian:stable-slim
3
4 ARG NIX_VERSION
5 ENV NIX_VERSION ${NIX_VERSION:-2.3.9}
6 ARG LANG
7 ENV LANG ${LANG:-"en_US.UTF-8"}
8
9 RUN 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 \
12 && mkdir -m 0755 /nix && chown nixuser /nix \
13 && apt update && apt install -y wget xz-utils \
14 && apt clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \
15 && mkdir -p /etc/nix && touch /etc/nix/nix.conf
16
17 USER nixuser
18 ENV USER=nixuser
19 ENV HOME="/home/nixuser"
20 ENV NIX_SYSTEM_PATH="/nix/var/nix/profiles/system"
21 ENV NIX_PROFILE="$HOME/nix-envs"
22
23 RUN 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 \
25 && NIX_PROFILE="$NIX_SYSTEM_PATH" ~/nix-*-x86_64-linux/install \
26 && rm -rf ~/nix-*-*
27
28 # All subsequent "RUN" will use a login shell
29 SHELL ["/usr/bin/env", "bash", "-l", "-c"]
30
31 # Create bash profile
32 COPY --chown=nixuser:nixuser files/.profile ${HOME}/.profile
33
34 RUN nix-channel --add https://nixos.org/channels/nixos-unstable nixpkgs \
35 && nix-channel --update
36
37 # Propagate UTF8
38 # https://github.com/NixOS/nix/issues/599#issuecomment-153885553
39 # The same is hapenning with stack2nix
40 RUN nix-env -p "$NIX_SYSTEM_PATH" -iA nixpkgs.glibcLocales
41
42 # < Nix context as a volume
43 # We want to be able to define /nix/store as a volume
44 VOLUME ["/nix"]
45 # />
46
47 # Make sure to use "login" shell when running container
48 ENTRYPOINT ["/usr/bin/env", "bash", "-l", "-c"]