mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-18 13:30:33 +00:00
Implement NixOS distro check (#12914)
(cherry picked from commit 148f6d9820)
This commit is contained in:
committed by
narimiran
parent
2f557f74e5
commit
cd28e01a1a
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user