Skip to content

Commit

Permalink
Implement NixOS distro check (nim-lang#12914)
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmry authored and Araq committed Dec 18, 2019
1 parent 3f6df5c commit 148f6d9
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/pure/distros.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -105,7 +106,7 @@ type
Clonezilla
SteamOS
Absolute
NixOS
NixOS ## NixOS or a Nix build environment
AUSTRUMI
Arya
Porteus
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 148f6d9

Please sign in to comment.