Skip to content

Instantly share code, notes, and snippets.

@nh2
Last active March 7, 2024 22:03
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nh2/7ff4b49272b5b6492d6713122f20104a to your computer and use it in GitHub Desktop.
Save nh2/7ff4b49272b5b6492d6713122f20104a to your computer and use it in GitHub Desktop.
How to determine if the nix sandbox is in effect on a system

How to determine if the nix sandbox is in effect on a system

Do the same as the nix-info script, which nix-builds this file and inspects the exit code.

Short version:

nix-build --no-out-link -E 'import <nixpkgs/pkgs/tools/nix/info/multiuser.nix>' 2> /dev/null

If and only if the exit code of that is 0, the sandbox is in use.

Note the above does not check for the relaxed sandbox, see the linked scripts for more detail on that.

Also relevant: Nix issue Add command that output system information like nix-info

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment