Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement NixOS distro check #12914

Merged
merged 1 commit into from
Dec 18, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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