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/NIXOS
officializes that this is now a NixOS partition (the bootup scripts require its presence).
1 Like
You could read /etc/os-release
, especially NAME
and ID
might be of interest.
1 Like
grep ‘NAME=NixOS’ /etc/os-release
1 Like
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.
2 Likes