Search code examples
nixos

Is it normal that root's nix-env is visible from non-root user?


When I install a package as root via sudo nix-env -i <pkg>, should the package be visible from non-root users?

Since this is not system-wide installation like nixos-rebuild, should the package be visible only for root?

Start with empty env for root and non-root

[wizzup@ ~] $ nix-env -q
[wizzup@ ~] $ sudo nix-env -q

Install buku via sudo

[wizzup@ ~] $ sudo nix-env -i buku
installing ‘buku-2.9’
building path(s) ‘/nix/store/a77imw0grmx4f7659ff07p5j5kxnnjw2-user-environment’
created 2 symlinks in user environment

No buku in non-root user env

[wizzup@ ~] $ nix-env -q

There is buku in root env

[wizzup@ ~] $ sudo nix-env -q
buku-2.9

But non-root user able to use it even it is not in his env

[wizzup@ ~] $ buku --version
2.9

To verify it is root env

$ sudo -i

[root@earth:~]# nix-env -q
buku-2.9

Solution

  • This is normal, it is a design choice of NixOS to consider that packages installed by root are packages that the administrator wants all users to have.