How do I check if I’m running on NixOS (vs a different Linux distribution) in a bash script?
You can test whether the file
/etc/NIXOS exists. From the manual:
/etc/NIXOSofficializes that this is now a NixOS partition (the bootup scripts require its presence).
You could read
ID might be of interest.
grep ‘NAME=NixOS’ /etc/os-release
that does not work with the docker images:
docker run -it nixpkgs/nix:nixos-23.11 cat /etx/os-release
Because that’s not a NixOS image. It’s the nix package manager.