How to add a user in Dockerfile based on nixos/nix?

I’d like to run code as a user inside containers using shell.nix.

When I start a container, docker run --rm -it nixos/nix, there are no useradd nor adduser commands.

I add one using nix-env -iA nixpkgs.shadow, but after that when I run useradd someuser, I get an error: “cannot open /etc/passwd”.

The same thing happens when I try to do this in Dockerfile. I could just use the debian base image and install nix the usual way using the installer script, but maybe there’s a way to do this using the nixos/nix image?