]>
Commit | Line | Data |
---|---|---|
89f0519e P |
1 | # Dockerfile to create an environment that contains the Nix package manager. |
2 | FROM alpine | |
3 | ||
4 | ARG NIX_VERSION | |
d7db3dbc | 5 | ENV NIX_VERSION ${NIX_VERSION:-2.3.9} |
c223b406 P |
6 | ARG LANG |
7 | ENV LANG ${LANG:-"en_US.UTF-8"} | |
89f0519e P |
8 | |
9 | RUN addgroup -g 30000 -S nixbld \ | |
10 | && for i in $(seq 1 30); do adduser -S -D -h /var/empty -g "Nix build user $i" -u $((30000 + i)) -G nixbld nixbld$i ; done \ | |
11 | && adduser -D nixuser \ | |
12 | && mkdir -m 0755 /nix && chown nixuser /nix \ | |
788f0fc5 | 13 | && apk add --no-cache bash xz \ |
e6f85a81 HAL |
14 | && rm -rf /var/cache/apk/* \ |
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" | |
c33369a9 | 21 | ENV NIX_SYSTEM_PATH="/nix/var/nix/profiles/system" |
62b9189f | 22 | ENV NIX_PROFILE="$HOME/nix-envs" |
89f0519e | 23 | |
788f0fc5 PB |
24 | RUN 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 \ | |
c33369a9 | 26 | && NIX_PROFILE="$NIX_SYSTEM_PATH" ~/nix-*-x86_64-linux/install \ |
89f0519e P |
27 | && rm -rf ~/nix-*-* |
28 | ||
75cabc50 | 29 | # All subsequent "RUN" will use a login shell |
89f0519e | 30 | SHELL ["/usr/bin/env", "bash", "-l", "-c"] |
75cabc50 | 31 | |
c33369a9 IB |
32 | # Create bash profile |
33 | COPY --chown=nixuser:nixuser files/.profile ${HOME}/.profile | |
34 | ||
d7db3dbc | 35 | RUN nix-channel --add https://nixos.org/channels/nixos-unstable nixpkgs \ |
4d15def7 | 36 | && nix-channel --update |
75cabc50 P |
37 | |
38 | # Propagate UTF8 | |
39 | # https://github.com/NixOS/nix/issues/599#issuecomment-153885553 | |
40 | # The same is hapenning with stack2nix | |
c33369a9 | 41 | RUN nix-env -p "$NIX_SYSTEM_PATH" -iA nixpkgs.glibcLocales |
63ece951 PB |
42 | |
43 | # < Nix context as a volume | |
44 | # We want to be able to define /nix/store as a volume | |
63ece951 | 45 | VOLUME ["/nix"] |
63ece951 | 46 | # /> |
75cabc50 P |
47 | |
48 | # Make sure to use "login" shell when running container | |
95f6e232 | 49 | ENTRYPOINT ["/usr/bin/env", "bash", "-l", "-c"] |