The install experience in docker containers doesn't seem great, it seems like the 'nix' is
designed for multiuser environments only, makes use of sudo, requires it's own groups, etc.
This is the list of things I've done before going back to using asdf.
docker run -ti alpine
/ # apk update
/ # apk add curl
Try the install:
/ # curl https://nixos.org/nix/install | sh
downloading Nix 2.2.2 binary tarball for x86_64-linux from 'https://nixos.org/releases/nix/nix-2.2.2/nix-2.2.2-x86_64-linux.tar.bz2' to '/tmp/nix-binary-tarball-unpack.XXXXmncAfg'...
/tmp/nix-binary-tarball-unpack.XXXXmncAfg/unpack/nix-2.2.2-x86_64-linux/install: $USER is not set
/ # nix
/bin/sh: nix: not found
Try the install but set env USER:
/ # export USER=root
/ # curl https://nixos.org/nix/install | sh
downloading Nix 2.2.2 binary tarball for x86_64-linux from 'https://nixos.org/releases/nix/nix-2.2.2/nix-2.2.2-x86_64-linux.tar.bz2' to '/tmp/nix-binary-tarball-unpack.XXXXKEGGjc'...
warning: installing Nix as root is not supported by this script!
performing a single-user installation of Nix...
directory /nix does not exist; creating it by running 'mkdir -m 0755 /nix && chown root /nix' using sudo
/tmp/nix-binary-tarball-unpack.XXXXKEGGjc/unpack/nix-2.2.2-x86_64-linux/install: line 81: sudo: not found
/tmp/nix-binary-tarball-unpack.XXXXKEGGjc/unpack/nix-2.2.2-x86_64-linux/install: please manually run 'mkdir -m 0755 /nix && chown root /nix' as root to create /nix
/ # nix
/bin/sh: nix: not found
Install sudo:
/ # apk add sudo
(1/1) Installing sudo (1.8.27-r0)
Executing busybox-1.30.1-r2.trigger
OK: 8 MiB in 19 packages
/ # nix
/bin/sh: nix: not found
/ # curl https://nixos.org/nix/install | sh
warning: installing Nix as root is not supported by this script!
performing a single-user installation of Nix...
directory /nix does not exist; creating it by running 'mkdir -m 0755 /nix && chown root /nix' using sudo
copying Nix to /nix/store.................................
initialising Nix database...
warning: the group 'nixbld' specified in 'build-users-group' does not exist
warning: the group 'nixbld' specified in 'build-users-group' does not exist
Nix: creating /root/.nix-profile
warning: the group 'nixbld' specified in 'build-users-group' does not exist
installing 'nix-2.2.2'
error: the group 'nixbld' specified in 'build-users-group' does not exist
/tmp/nix-binary-tarball-unpack.XXXXAipLdP/unpack/nix-2.2.2-x86_64-linux/install: unable to install Nix into your default profile
Group is missing, briefly consider adding the group, then give up.
/ # groups
root bin daemon sys adm disk wheel floppy dialout tape video
Conclusion - it would be nice if nix could run in a single user container environment - but it doesn't - I can't use it in CI.
Don't run the installer and nix as root, multi-user is not a requirement but requires an unprivileged user.
Why does it actually require it?
I understand that this is not the best practice to do so, but it is
extremely common in the docker world. We should make it work, to ensure
that people can try it under docker. At the same time there should be a
warning about this not being recommended.
On Sat, Jul 13, 2019, 14:40 Daiderd Jordan notifications@github.com wrote:
Don't run the installer and nix as root, multi-user is not a requirement
but requires an unprivileged user.—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/NixOS/nix/issues/2989?email_source=notifications&email_token=AAAIDIM44CRCEE32TTA2UQDP7HELNA5CNFSM4IC3V4GKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZ3Q56Q#issuecomment-511119098,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAAIDIMT735WFP6S4RDMJ3LP7HELNANCNFSM4IC3V4GA
.
Building arbitrary software has terrible security implications, other projects like postgresql also refuse running as root.
Most helpful comment
Why does it actually require it?
I understand that this is not the best practice to do so, but it is
extremely common in the docker world. We should make it work, to ensure
that people can try it under docker. At the same time there should be a
warning about this not being recommended.
On Sat, Jul 13, 2019, 14:40 Daiderd Jordan notifications@github.com wrote: