Skip to content

Commit

Permalink
install nix under the unprivileged user
Browse files Browse the repository at this point in the history
  • Loading branch information
dysinger committed Mar 31, 2016
1 parent bc825fb commit 0bf0eed
Showing 1 changed file with 19 additions and 25 deletions.
44 changes: 19 additions & 25 deletions etc/docker/ubuntu-with-gnupg/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,42 +1,36 @@
FROM fpco/ubuntu-with-libgmp:14.04

# INSTALL PACKAGES
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update
RUN apt-get -y install curl expect

# SETUP A NIX BUILD GROUP & USER
# CREATE USER
ENV USER user
ENV HOME /home/$USER
RUN groupadd -r nixbld
RUN useradd -c "Nix Build" -d /var/empty -g nixbld -G nixbld \
-M -N -r -s "$(which nologin)" nixbld
RUN useradd -m $USER -G nixbld
ADD .gnupg/ $HOME/.gnupg/
RUN chown -R user:user $HOME
RUN chmod -R go-rwsx $HOME
RUN mkdir /nix
RUN chown $USER:nixbld /nix
WORKDIR $HOME
USER $USER

# INSTALL NIX
RUN curl -s https://nixos.org/nix/install | USER=root sh
RUN ln -s /nix/var/nix/profiles/default/etc/profile.d/nix.sh /etc/profile.d/
RUN bash -lc "nix-channel --update"
RUN curl -s https://nixos.org/nix/install | sh
RUN echo "\nsource /nix/var/nix/profiles/default/etc/profile.d/nix.sh" \
| tee -a $HOME/.bash_profile

# INSTALL ALL 3 VERSIONS OF GNUPG
# INSTALL GNUPGS & SETUP KEYS
RUN bash -lc "nix-env -p /nix/var/nix/profiles/gpg14 -iA nixpkgs.nix nixpkgs.gnupg1orig"
RUN bash -lc "nix-env -p /nix/var/nix/profiles/gpg20 -iA nixpkgs.nix nixpkgs.gnupg20"
RUN bash -lc "nix-env -p /nix/var/nix/profiles/gpg21 -iA nixpkgs.nix nixpkgs.gnupg"

# MAKE GNUPG 1 THE DEFAULT
RUN bash -lc "nix-env -S /nix/var/nix/profiles/gpg14"

# CREATE USER w/ HOME DIR
RUN useradd -m user
ENV HOME /home/user
ADD .gnupg/ $HOME/.gnupg/
RUN chown -R user:user $HOME
RUN chmod -R go-rwsx $HOME
WORKDIR $HOME

# SETUP GPG
USER user
RUN bash -lc "nix-env -S /nix/var/nix/profiles/gpg14" ;# SET CURRENT PROFILE TO GPG 1.4
RUN bash -lc "gpg --import $HOME/.gnupg/public.asc $HOME/.gnupg/subkey.asc"
RUN bash -lc "expect $HOME/.gnupg/trust"
RUN rm $HOME/.gnupg/*.asc $HOME/.gnupg/trust

# CLEANUP
RUN apt-mark auto curl expect
RUN apt-get -y autoremove
RUN apt-get -y clean
# LOGIN SHELL
CMD /bin/bash -l

0 comments on commit 0bf0eed

Please sign in to comment.