diff options
author | Emery Hemingway <ehmry@posteo.net> | 2019-12-18 07:01:58 +0000 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2019-12-18 08:01:58 +0100 |
commit | 148f6d98204f36a718cb61e9aab01299f06f711b (patch) | |
tree | de5a7a6574c4f02ae64c2e74fe15251bf11f8a75 /lib/pure | |
parent | 3f6df5cc3475573807fae9854fe1616535f93412 (diff) | |
download | Nim-148f6d98204f36a718cb61e9aab01299f06f711b.tar.gz |
Implement NixOS distro check (#12914)
Diffstat (limited to 'lib/pure')
-rw-r--r-- | lib/pure/distros.nim | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/pure/distros.nim b/lib/pure/distros.nim index 9e3d41026..033543c3a 100644 --- a/lib/pure/distros.nim +++ b/lib/pure/distros.nim @@ -29,6 +29,7 @@ from strutils import contains, toLowerAscii when not defined(nimscript): from osproc import execProcess + from os import existsEnv type Distribution* {.pure.} = enum ## the list of known distributions @@ -105,7 +106,7 @@ type Clonezilla SteamOS Absolute - NixOS + NixOS ## NixOS or a Nix build environment AUSTRUMI Arya Porteus @@ -161,6 +162,9 @@ proc detectOsImpl(d: Distribution): bool = of Distribution.BSD: result = defined(bsd) of Distribution.ArchLinux: result = "arch" in toLowerAscii(uname()) + of Distribution.NixOS: + result = existsEnv("NIX_BUILD_TOP") or existsEnv("__NIXOS_SET_ENVIRONMENT_DONE") + # Check if this is a Nix build or NixOS environment of Distribution.OpenSUSE: result = "suse" in toLowerAscii(uname()) or "suse" in toLowerAscii(release()) of Distribution.GoboLinux: |