nix-community / docker-nixpkgs

docker images from nixpkgs [maintainer=@zimbatm]
https://hub.docker.com/u/nixpkgs
MIT License
185 stars 36 forks source link

Support running Nix as a non-root user #62

Open exarkun opened 1 year ago

exarkun commented 1 year ago

Currently if the Docker container is started as a non-root user (eg nobody), Nix commands fail with permission errors. For example:

❯ docker run --rm -it --user nobody nixos/nix:2.16.1
bash-5.1$ nix --extra-experimental-features 'flakes nix-command' profile install nixpkgs#hello
error: could not set permissions on '/nix/var/nix/profiles/per-user' to 755: Operation not permitted

It would be nice if it were possible to use these commands as some non-root user (not necessarily "nobody") without further modifying the image.

the-sun-will-rise-tomorrow commented 9 months ago

❯ docker run --rm -it --user nobody nixos/nix:2.16.1

the-sun-will-rise-tomorrow commented 9 months ago

I made a PR for nixos/nix: https://github.com/NixOS/nix/pull/9854

@exarkun Maybe you can test it?