John Fremlin's blog: Run anything on NixOS with Docker passthrough

Posted 2021-02-15 06:33:41 GMT

NixOS is very opinionated. Suppose you want to run the latest Android Studio or a Python project with weird pip installs. It will work on Ubuntu and take work on NixOS.

Here is a Dockerbuild that makes an image where you share your home directory, and can use apps installed in Ubuntu.

FROM ubuntu:devel
ENV DEBIAN_FRONTEND=noninteractive
RUN perl -pi -e 's/# deb-src/deb-src/' /etc/apt/sources.list
RUN dpkg --add-architecture i386 \
    && apt-get update \
    && apt-get install -qy \
    cmake g++ git \
    build-essential \
    tar python tzdata sudo bash-completion \
    gdb openssh-server rsync dpkg-dev clangd default-jdk \
    libc6:i386 libncurses5:i386 libstdc++6:i386 lib32z1 libbz2-1.0:i386 \
    && apt-get build-dep -qy plasma-desktop clangd libc6:i386 default-jdk \
    && apt-get dist-upgrade -qy \
    && apt-get clean -qy
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
RUN useradd --shell /bin/bash -u ${VII_USER_ID} -o -c "dockerpassthrough" -m ${VII_USER_NAME}
RUN adduser ${VII_USER_NAME} sudo

To build:

docker build --build-arg VII_USER_ID=$(id -u) --build-arg VII_USER_NAME=$USER . -t vii-ubuntu-passthrough

To run a shell

 docker run --mount type=bind,source=$HOME,target=$HOME --mount type=bind,source=/tmp,target=/tmp --net=host -e DISPLAY=$DISPLAY -it vii-ubuntu-passthrough:latest  bash 

Post a comment