This option users.users.<user> = can be stated multiple times for different users.
This should provide a solution to you for your problem, after a rebuild the bin’s should be available only to the profile they are installed under in the sys config.
I don’t use NixOS. Therefore I dont have ‘/etc/nixos’ directory.
I only installed nix package manager and I installed firefox. Firefox works properly. Firefox is just an example. I have installed another app. I just wrote firefox for example.
But my issue is that “profile” directory is empty. It was not empty when I had install before 1-2 years before.
I know my installation-pratice is not recommended, but you can think I will use nix packages only via “nix_user”. The result will not change. “Profile” is still empty.
You mentioned no daemon and you installed nix today, assuming you followed this >> Download | Nix & NixOS doc, im guessing you installed nix using the single user instance described with sh <(curl -L https://nixos.org/nix/install) --no-daemon
The flavor text underneath:
Above command will perform a single-user installation of Nix, meaning that nix is owned by the invoking user. You should run this under your usual user account, not as root. The script will invoke sudo to create /nix if it doesn’t already exist.
In this event, a single user install wouldnt include a per-user directory, or it would be empty as the only user capable of using nix is you. So it would get written to home directory.
You can try invoking the program you installed with nix with the debug flags, verbose flags, or running a which command on it to see where the command is being executed from, which should reveal the bin location.
I actually JUST found this.
This should be your answer, credit goes to this guy at unix stack exchange.
After having created a VM just to play with a fresh installation of nix (the package manager, not the distro), I finally figured it out. Apparently, the default profile, for a “–no-daemon” installation is ~/.local/state/nix/profiles/profile. I wish this was documented somewhere, but at least people can find it here.
Sorry I did not mention it before. Yes I already saw that directory. But I’m sure there were another copy of that directory under “/nix/var/nix/profiles/per-user”.
Something has been change
It would be really good because “/nix/var/nix/profiles/per-user” is accessible by all users on my OS as default. I would be able to run all apps from there I was using nix for a long time with that way without any error. Now all my dreams shattered
That looks to be the old way of doing things, but i can see why it was changed at least for the single user instance of nix. Reason being is its not suggested using root for a single user instance, and typically, for most production environments and especially managed corporate environments, you NEED root perms to write to the root / directory which isnt possible for non admin accounts.
A single instance install now installs the bin directory to ~/.local directory and updates your shell path which would be the correct way to step down permissions on a system level with minimal interference.
If you wish to continue using this older method, a simple solution is simply sim linking the whole profile directory to /nix/var/nix/profiles
Barring that, you would need to do a daemon install.
It is best not to change the Nix store from its default, since doing so makes it impossible to use pre-built binaries from the standard Nixpkgs channels — that is, all packages will need to be built from source.
If you are trying to install something for multiple users, another approach would be to install nix for each user individually. SU to the user you need to execute some nix installed software on, install nix to that profile, and then grant RW access to your admin account.
But this would be annoyingly tedious.
But ive been chewing on it for a while and there are older versions of nix you can install and pin instead of latest/stable version. If an older version of nix did what you wanted, it might be worth trying to roll back to those older version of nix.
Check out this:
Version-specific installation URLs for all Nix versions since 1.11.16 can be found at releases.nixos.org. The corresponding SHA-256 hash can be found in the directory for the given version.
These install scripts can be used the same as usual:
curl -L https://releases.nixos.org/nix/nix-<version>/install | sh
Version [2.25.3] for nix is the current version according to the nix downloads section.
I cant find a release schedule, but assuming the usual versioning practices, start with v 2.1.x, then 2.0.x and so on stepping down until you find a version that does what you remember it doing.