From 86768ad452c6bfa75d4e127e416653a5889a3d70 Mon Sep 17 00:00:00 2001 From: keyboard-slayer Date: Thu, 25 Jan 2024 15:34:08 +0100 Subject: [PATCH] fix: NixOS will use clang and not clang-xx --- cutekit/shell.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/cutekit/shell.py b/cutekit/shell.py index b9cb85d..fe3697a 100644 --- a/cutekit/shell.py +++ b/cutekit/shell.py @@ -22,6 +22,7 @@ _logger = logging.getLogger(__name__) @dt.dataclass class Uname: sysname: str + distrib: str nodename: str release: str version: str @@ -30,7 +31,13 @@ class Uname: def uname() -> Uname: un = platform.uname() - result = Uname(un.system, un.node, un.release, un.version, un.machine) + + if hasattr(platform, "freedesktop_os_release"): + distrib = platform.freedesktop_os_release() + else: + distrib = {"NAME": "Unknown"} + + result = Uname(un.system, distrib['NAME'], un.node, un.release, un.version, un.machine) match result.machine: case "aarch64": @@ -316,6 +323,12 @@ def latest(cmd: str) -> str: if cmd in LATEST_CACHE: return LATEST_CACHE[cmd] + if "IN_NIX_SHELL" in os.environ: + # By default, NixOS symlinks tools automatically + # to their latest version. Also, if the user uses + # clang-xx, the std libraries will not be accessible. + return cmd + _logger.debug(f"Finding latest version of {cmd}") regex: re.Pattern[str]