]>
Commit | Line | Data |
---|---|---|
89f0519e | 1 | # Dockerfile to create an environment that contains the Nix package manager. |
0366f366 | 2 | FROM debian:stable-slim |
89f0519e P |
3 | |
4 | ARG NIX_VERSION | |
788f0fc5 | 5 | ENV NIX_VERSION ${NIX_VERSION:-2.3.1} |
c223b406 P |
6 | ARG LANG |
7 | ENV LANG ${LANG:-"en_US.UTF-8"} | |
89f0519e | 8 | |
0366f366 P |
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 \ | |
89f0519e | 12 | && mkdir -m 0755 /nix && chown nixuser /nix \ |
788f0fc5 | 13 | && apt update && apt install -y wget xz-utils \ |
e6f85a81 HAL |
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 | |
89f0519e P |
17 | |
18 | USER nixuser | |
19 | ENV USER=nixuser | |
20 | ENV HOME="/home/nixuser" | |
21 | ||
788f0fc5 PB |
22 | RUN cd && wget https://nixos.org/releases/nix/nix-$NIX_VERSION/nix-$NIX_VERSION-x86_64-linux.tar.xz \ |
23 | && tar xJf nix-*-x86_64-linux.tar.xz \ | |
89f0519e P |
24 | && ~/nix-*-x86_64-linux/install \ |
25 | && rm -rf ~/nix-*-* | |
26 | ||
27 | ENV ENV="/home/nixuser/.nix-profile/etc/profile.d/nix.sh" | |
c223b406 | 28 | RUN echo ". ${ENV}" >> ${HOME}/.profile |
75cabc50 | 29 | # All subsequent "RUN" will use a login shell |
89f0519e | 30 | SHELL ["/usr/bin/env", "bash", "-l", "-c"] |
75cabc50 | 31 | |
788f0fc5 | 32 | RUN nix-channel --add https://nixos.org/channels/nixpkgs-19.09-darwin nixpkgs \ |
4d15def7 HAL |
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 | |
63ece951 PB |
39 | RUN nix-env -iA nixpkgs.glibcLocales |
40 | ||
41 | # < Nix context as a volume | |
42 | # We want to be able to define /nix/store as a volume | |
63ece951 PB |
43 | VOLUME ["/nix"] |
44 | # Create bash profile | |
45 | COPY --chown=nixuser:nixuser files/.profile ${HOME}/.profile | |
46 | # /> | |
75cabc50 P |
47 | |
48 | # Make sure to use "login" shell when running container | |
95f6e232 | 49 | ENTRYPOINT ["/usr/bin/env", "bash", "-l", "-c"] |