|
| 1 | +# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.202.1/containers/debian/.devcontainer/base.Dockerfile |
| 2 | + |
| 3 | +# [Choice] Debian version (use bullseye or stretch on local arm64/Apple Silicon): bullseye, buster, stretch |
| 4 | +ARG VARIANT="buster" |
| 5 | +FROM mcr.microsoft.com/vscode/devcontainers/base:0-${VARIANT} |
| 6 | + |
| 7 | +# use bash to run commands in the dockerfile so we can easily source the nix environment |
| 8 | +SHELL ["/bin/bash", "-c"] |
| 9 | + |
| 10 | +# install dependencies nix needs to install itself |
| 11 | +RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ |
| 12 | + && apt-get -y install --no-install-recommends xz-utils acl |
| 13 | + |
| 14 | +# set up chsh to allow passwordless shell changing |
| 15 | +RUN sed -i 's/required/sufficient/' /etc/pam.d/chsh |
| 16 | + |
| 17 | +# setup the default vscode user that codespaces uses as a passwordless sudoer |
| 18 | +RUN usermod -aG sudo vscode && echo "vscode ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers |
| 19 | +USER vscode |
| 20 | +ENV USER=vscode |
| 21 | + |
| 22 | +# Install nix (requires non-root user) |
| 23 | +RUN curl -L https://nixos.org/nix/install | sh -s -- --no-daemon && \ |
| 24 | + echo 'source ~/.nix-profile/etc/profile.d/nix.sh' >> ~/.bashrc |
| 25 | + |
| 26 | +# Enable required Nix experimental features & pin the nixpkgs flake |
| 27 | +ENV NIXPKGS_COMMIT=ec750fd01963ab6b20ee1f0cb488754e8036d89d |
| 28 | +RUN source ~/.nix-profile/etc/profile.d/nix.sh && \ |
| 29 | + nix-env -f https://github.com/NixOS/nixpkgs/archive/$NIXPKGS_COMMIT.tar.gz -iA nix && \ |
| 30 | + mkdir -p ~/.config/nix && \ |
| 31 | + echo 'experimental-features = nix-command flakes' >> ~/.config/nix/nix.conf && \ |
| 32 | + nix registry pin nixpkgs github:NixOS/nixpkgs/$NIXPKGS_COMMIT |
| 33 | + |
| 34 | +# Install & setup direnv |
| 35 | +RUN source ~/.nix-profile/etc/profile.d/nix.sh && \ |
| 36 | + nix profile install nixpkgs#direnv nixpkgs#nix-direnv && \ |
| 37 | + echo 'eval "$(direnv hook bash)"' >> ~/.bashrc && \ |
| 38 | + echo 'source ~/.nix-profile/share/nix-direnv/direnvrc' >> ~/.direnvrc |
| 39 | + |
| 40 | +# Install docker and setup buildx as default docker builder |
| 41 | +RUN source ~/.nix-profile/etc/profile.d/nix.sh && \ |
| 42 | + nix profile install nixpkgs#docker && \ |
| 43 | + docker buildx install |
0 commit comments