Closed joelnn closed 1 year ago
While we're on this, there are two forms of that command in the docs:
curl https://nixos.org/nix/install | sh
bash <(curl https://nixos.org/nix/install)
The shebang in the script is for /bin/sh, so I guess the first form is technically more appropriate.
I believe the curl https://nixos.org/nix/install | sh
installer is for single-user mode because the installation script has this line:
echo "performing a single-user installation of Nix..." >&2
Somebody correct me if I'm wrong, but I believe multi-user Nix installations are prepared by either:
Nix
via a package manager,NixOS
(which provides multi-user support out-of-the-box)However, I've never actually performed a multi-user install so I'm only basing that on what I've read
All you need is contained in the bootstrap archive. Installing Nix amounts to copying the store paths in the archive onto your file system and using the bootstrap nix to initialize the state. There's nothing that stops you from converting a single-user install into a multi-user install, but you probably will need to muck about with permissions to get it to work properly after you've added the build users. It's not quite one-click install at the moment ... but not that much of a hassle, IMO. There may be better ways that I'm unaware of as well (apart from distro packages, as mentioned above, which probably are your best bet for a smooth experience).
Installing Nix amounts to copying the store paths in the archive onto your file system and using the bootstrap nix to initialize the state.
That sounds straightforward, but there must be a good reason why the install script supports single-user only?
I guess https://github.com/NixOS/nix/pull/135 indicates that non-NixOS multi-user install may not be ready anyway, I can't tell.
@joelnn it is difficult to do automatically and portably, I guess; for a single-user scenario, there's way fewer assumptions you need to make about the host. For systemd users, the process could be somewhat streamlined by providing appropriate tmpfiles.d and sysusers.d files (or have the installer generate them based on user input), which could at least portably (across systemd) setup groups/users and create requisite dirs with the appropriate modes/ownership.
Good points. I'm not too concerned about portability, I would be very happy to have a /nix dropped in place with all the distro-neutral bits, and could make my way from there with some docs on what nix-daemon requires. I agree Nix shouldn't worry about distro-specific packaging, though as you say, any coverage of systemd would be awesome.
My vague dream for a non-NixOS install would be to have it drop in /nixos, chroot itself there, mount its own user namespace (cgroup), start its own systemd/init (pid cgroup?), symlink /nix in the non-nixos host to /nixos/nix, and then have a way for users outside the chroot/container to install software inside the container (via nix-daemon?). Services run by nix packages would run inside the container. Like running NixOS in a VM or LXD/Docker, but with a bridge to the outside world. I guess /etc would be a problem.
@joelnn You may be interested in my instructions/script referenced here https://github.com/NixOS/nixpkgs/issues/16142
@expipiplus1 Very nice, thanks. I was interested in using Nix to bring in 'unstable' or source packages on my Debian and Centos systems, without affecting the base platform stability. I've fallen back to throwing things in a VM for now, but I'd like to try again someday. Ran out of time to play.
I think multi-user install on non-NixOS is probably the best way to grow the Nix/NixOS community over time. Would be great to be able to use it at work, in place of things like Lmod or ad hoc install from source.
https://gist.github.com/joepie91/043a51a7b70be5f50f1d worked perfectly for me on Debian, and seems like a relatively straightforward and simple way to install multi-user NixPkg.
@grahamc - The fancy multi-user install default for macOS and systemd Linux systems is great!
Wondering if you have any docs or plans to update the installation docs for multi-user and this daemon mode? As a total noob, it's unclear how to run nix as a user outside of root. The installation docs and the nix pills assume single user mode, and thus speak of a "nix" user after installation.
btw - when I look at the following for my own user, jlund (the user I ran the install script with), after a clean macOS post nix install:
$ ls -l ~/.nix-profile lrwxr-xr-x 1 jlund staff 44 28 May 11:40 /Users/jlund/.nix-profile -> /nix/var/nix/profiles/per-user/jlund/profile
/nix/var/nix/profiles/per-user/jlund/profile
does not exist. /nix/var/nix/profiles/per-user/jlund
exists but profile
does not. Is that right? docs suggest I should be able to source ~/.nix-profile/etc/profile.d/nix.sh
but that seems to be for single-user mode.
Also with multi mode, it's less clear how to "uninstall". rm -rf /nix
doesn't seem to be enough anymore.
related: https://github.com/NixOS/nix/issues/1889#issuecomment-392599569
@lundjordan Apparently you have to actually do something with nix-env
for a /nix/var/nix/profiles/per-user/<your user>
folder to be created (so that your ~/.nix-profile
symlink isn't pointing to a non-existent folder). For example you can run nix-env -iA nixpkgs.hello
.
What's that you say? You don't yet have a nix-env
binary in your PATH? Yes, of course! This is because in order to have a nix-env
binary in your PATH, you need to source ~/.nix-profile/etc/profile.d/nix.sh
. But before you can source ~/.nix-profile/<anything>
, you need to actually have that folder.
So step 1 depends on step 2, which in turn depends on step 1. :sweat_smile:
One way to work around this is to restart your computer, which will cause the ~/.profile.d/nix.sh
file to be sourced (among other things this adds ~/.nix-profile/bin
to the PATH
, so that you can run something with nix-env
to seed your per-user profile folder). Maybe this workaround can be added to the nix documentation.
ah, thanks for the context. I seem to recall either manually adding the bin to my path or restarting to have it there? I stopped using it after my above trial run.
I marked this as stale due to inactivity. → More info
This issue has been mentioned on NixOS Discourse. There might be relevant details there:
https://discourse.nixos.org/t/anyone-up-for-picking-at-some-nix-onboarding-improvements/13152/6
I marked this as stale due to inactivity. → More info
Closing as it seems to be outdated now. Feel free to chime in if you think it is still relevant
This issue has been mentioned on NixOS Discourse. There might be relevant details there:
https://discourse.nixos.org/t/2023-02-10-nix-team-meeting-minutes-31/25438/1
The multi-user install docs at https://nixos.org/nix/manual/#ssec-multi-user are great, but I think there is a point that could be made more explicit for the benefit of careful newbies like me: how does one install /nix?
Is the first step still to run
curl https://nixos.org/nix/install | sh
, but as root? The current language makes it unclear whether this is only usable for a single-user install.There is a warning emitted when run as root: