Questions, questions, questions (newbie)

I started learning Nix and my goal is to create a dev container for working on projects with VSCode.

I am at a crossroad,s but first my experience is:

  1. I installed a VM with NixOS
  2. I read Nix Pills and understand derivations and various patterns (monorepo, callpackage, …)
  3. I read NixOS & Flakes Book and updated my NixOS to use flakes. Tried the new CLI.

At this point I learned about Home Manager and realized I don’t need to use a VM to experiment with Flakes, so I created a distrobox using Fedora 43 as a basis with everything available for review here.

Basically:

  • I install nix package manager single-user with flakes support
sh <(curl --proto ‘=https’ --tlsv1.2 -L https://nixos.org/nix/install) --no-daemon --yes

mkdir -p ~/.config/nix ; echo “experimental-features = nix-command flakes” | tee -a ~/.config/nix/nix.conf
  • I install home manager with:
nix-channel --add https://github.com/NixOS/nixpkgs/archive/release-25.11.tar.gz nixpkgs

nix-channel --add https://github.com/nix-community/home-manager/archive/release-25.11.tar.gz home-manager

nix-channel --update

nix-shell '<home-manager>' -A install
  • I have a minimal user-level home.nix for the distrobox which sets up basic zsh

At this point I’m sort of happy because people with Windows/WSL can actually use this.

I have shared this with others running Windows and it allowed them to play with nix packages by adding them to the home.nix file.

But I’ve not reached my goal: The idea was that I would be able to have a .devcontainer.json that can be used regardless of WSL (just via docker).

So now I am a bit confused. I read Using Nix with Dockerfiles and realized that there is an “official” nixos/nix OCI image, which I immediately tried and landed in:

$ podman run -it nixos/nix
bash-5.2# cat /etc/nix/nix.conf
build-users-group = nixbld
sandbox = false
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
bash-5.2# ls /etc/nixos
ls: cannot access '/etc/nixos': No such file or directory
bash-5.2# cat /etc/os-release
cat: /etc/os-release: No such file or directory
bash-5.2# nix --version
nix (Nix) 2.32.4
bash-5.2# nixos-rebuild --help
bash: nixos-rebuild: command not found
bash-5.2# nix-channel --list
nixpkgs https://nixos.org/channels/nixpkgs-unstable

So I am not sure what this image is. It seems to have the package manager but I do not understand how to customize it.

So questions:

  1. The resource I found () seems to use a Dockerfile to actually build a project and isolate a closure of the output (minimal set of dependencies). I understand that, but I really want my docker image to have VS code tooling (that VSCode installs) to be used for development. Is there a better resource?
  2. The official nixos/nix image does not have a /etc/nixos/configuration.nix. How do I customize it (e.g. if I wanted to install a specific version of clang and cmake for C++ development)? I also want to create a user called vscode with id 1000 which I would expect to provide in /etc/configuration.nix as per what I did using these instructions in my very first NixOS VM. How do I extend this image to create that user?
  3. VSCode installs a “server” when the dev container starts. I am worried that the binaries will “explode” due to nixos/nix image not being a “standard” distro with /lib and /usr/lib etc…

In short, is there a good example of a dev container built by slightly customizing the official image?