What is the simplest way to check if one has single or multi-user Nix installed?

As far as I can tell, one can just issue

cat /etc/group | grep nixbld

and if there is an output then it is a multi-user install, right?

Hehe. I’m not sure there’s a good way. I recall seeing this general need come up in Unified profile script that detects single-user vs multi-user · Issue #3630 · NixOS/nix · GitHub

This is a probably a decent signal for some purposes, but it would be wrong if someone had an old multi-user install that hasn’t been completely cleaned.

(aside, you can just grep nixbld /etc/group)

1 Like

Yeah, my solution sounded too simple to be true…:slight_smile: Thanks for the issue (at least I know I’m not alone) and also for the CLI-golf; I keep forgetting this form of grep.

(Off-topic, but also thank you for compiling this list of Nix issues!)

1 Like

What I settled on was to test if /nix/store is owned by root with the sticky bit. There’s a long explanatory comment in this code

Also to note, checking for the nixbld group won’t work if a multi-user install was replaced with a single-user install without fully cleaning it up first. This is true of testing pretty much anything outside of /nix/store.

nix-shell -p nix-info --run "nix-info -m"

shouldn’t this simple information be part of nix doctor ? (as well as the rest of nix-info)

what about sudo systemctl status nix-daemon.service, since only multi user setups install the daemon, would not this option also be valid?

1 Like

The presence of Nix doesn’t imply or require the presence of systemd.