Created
October 14, 2022 10:35
-
-
Save senges/96aa696cc1687220abefd533cc4bf903 to your computer and use it in GitHub Desktop.
Nix in Ubuntu for Docker
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
FROM ubuntu:22.04 | |
ARG USER=user | |
ARG HOME=/home/${USER} | |
ARG DEBIAN_FRONTEND=noninteractive | |
ENV USER=${USER} | |
RUN apt update && apt install -y sudo wget xz-utils && rm -rf /var/lib/apt/lists/* | |
RUN addgroup --gid 1000 ${USER} \ | |
&& adduser --uid 1000 --ingroup ${USER} --home ${HOME} \ | |
--shell $(which bash || which sh) \ | |
--disabled-password --gecos "" ${USER} \ | |
&& echo "${USER} ALL=(ALL:ALL) NOPASSWD: ALL" > /etc/sudoers.d/20-nix-user | |
ARG NIX_VERSION=2.11.0 | |
ARG NIX_RELEASE=https://releases.nixos.org/nix/nix-${NIX_VERSION}/nix-${NIX_VERSION}-x86_64-linux.tar.xz | |
RUN wget -O - ${NIX_RELEASE} | tar -C /tmp -xJf - \ | |
&& mv /tmp/nix-* /tmp/nixos \ | |
&& mkdir /nix \ | |
&& chown ${USER}:${USER} /nix \ | |
&& su - ${USER} -c '/tmp/nixos/install -- --no-daemon' \ | |
&& su - ${USER} -c '${HOME}/.nix-profile/bin/nix-env -u --always' \ | |
&& echo ". ~/.nix-profile/etc/profile.d/nix.sh" >> ${HOME}/.bashrc \ | |
&& echo 'export PATH=$PATH:'${HOME}'/.nix-profile/bin' >> /root/.bashrc \ | |
&& rm -rf /tmp/nix* | |
USER ${USER}:${USER} | |
WORKDIR ${HOME} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment