Using nix-managed software as root, on non-NixOS systems

What are the best, most nix-idiomatic ways for Nix package users, on non-NixOS system, to run software with sudo, or as root?

I would like to point root’s nix-profile to use my user’s nix-profile symlink, or copy the symlink to root as snapshots of the same target.

These questions do not directly relate, but the linked answers might address opinions related to my question.

Do a multi user installation and use nix.

If you want to have root use your users current profile, then you use sudo PATH=$PATH …

1 Like


  • sudo PATH=$PATH which ...

shows me the user-installed path to …, ~/.nix-profile/bin/...,

  • sudo env PATH=$PATH ...

is required to have the path used in executable lookups. Thank you for the quick answer, breaking my mental block.