Detect that bash script is running under NixOS

You can test whether the file /etc/NIXOS exists. From the manual:

/etc/NIXOS officializes that this is now a NixOS partition (the bootup scripts require its presence).

1 Like