I want to base a container on Ubuntu and use the determinant installer but at the same time have a user in the container, not root:
# Dockerfile
FROM ubuntu:latest
RUN apt update -y
RUN apt install curl systemd -y
RUN curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install linux \
--extra-conf "sandbox = false" \
--no-start-daemon \
--no-confirm
ENV PATH="${PATH}:/nix/var/nix/profiles/default/bin"
RUN nix run nixpkgs#hello
CMD [ "/bin/systemd" ]
How would I extend this example, such that a user ci
works with nix?
I tried to
FROM ubuntu:latest
RUN apt update -y
RUN apt install curl systemd -y
RUN curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install linux \
--extra-conf "sandbox = false" \
--no-start-daemon \
--no-confirm
ENV PATH="${PATH}:/nix/var/nix/profiles/default/bin"
ARG USER_NAME=ci
ARG USER_UID=1000
ARG USER_GID=1000
RUN userdel ubuntu || true
RUN groupadd -g "$USER_GID" "$USER_NAME"
RUN useradd -p "$(openssl passwd -1 "$USER_NAME")" \
-m --shell "bash" \
-u "$USER_UID" -g "$USER_GID" \
-G sudo "$USER_NAME" && \
passwd -d "$USER_NAME"
ENV USER="$USER_NAME"
ENV PATH="/nix/var/nix/profiles/per-user/default/bin:$PATH"
CMD ["bash"]
but a podman run -it test nix build nixpkgs#hello
runs in all sort of permission issues?
Whats the correct way to do this?
The answer should be contributed back to the determinant system installer etc.