forked from commercialhaskell/stack
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
install nix under the unprivileged user
- Loading branch information
Showing
1 changed file
with
19 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |