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