diff options
| author | Vaxry <43317083+vaxerski@users.noreply.github.com> | 2026-02-27 17:57:04 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-02-27 17:57:04 +0000 |
| commit | f624449c12f905669bc7ede446e913c3d5ca75f5 (patch) | |
| tree | f30180d354793fda2c1ce78075e97af9ee1c9e39 /start | |
| parent | 70cdd819e4bee3c4dcea6961d32e61e6afe4eeb0 (diff) | |
start: add --force-nixgl and check /run/opengl-driver (#13385)
Diffstat (limited to 'start')
| -rw-r--r-- | start/src/core/State.hpp | 3 | ||||
| -rw-r--r-- | start/src/helpers/Nix.cpp | 17 | ||||
| -rw-r--r-- | start/src/main.cpp | 5 |
3 files changed, 23 insertions, 2 deletions
diff --git a/start/src/core/State.hpp b/start/src/core/State.hpp index d00a1757..6a44c8d0 100644 --- a/start/src/core/State.hpp +++ b/start/src/core/State.hpp @@ -8,7 +8,8 @@ struct SState { std::span<const char*> rawArgvNoBinPath; std::optional<std::string> customPath; - bool noNixGl = false; + bool noNixGl = false; + bool forceNixGl = false; }; inline UP<SState> g_state = makeUnique<SState>();
\ No newline at end of file diff --git a/start/src/helpers/Nix.cpp b/start/src/helpers/Nix.cpp index 07cd2a4a..da66183e 100644 --- a/start/src/helpers/Nix.cpp +++ b/start/src/helpers/Nix.cpp @@ -82,6 +82,9 @@ std::expected<void, std::string> Nix::nixEnvironmentOk() { } bool Nix::shouldUseNixGL() { + if (g_state->forceNixGl) + return true; + if (g_state->noNixGl) return false; @@ -103,7 +106,19 @@ bool Nix::shouldUseNixGL() { if (IS_NIX) { const auto NAME = getFromEtcOsRelease("NAME"); - return !NAME || *NAME != "NixOS"; + + // Hyprland is nix: recommend nixGL iff !NIX && !NIX-OPENGL + + if (*NAME == "NixOS") + return false; + + std::error_code ec; + + if (std::filesystem::exists("/run/opengl-driver", ec) && !ec) // NOLINTNEXTLINE + return false; + + // we are not on nix / no nix opengl driver + return true; } return false; diff --git a/start/src/main.cpp b/start/src/main.cpp index e73fcfa5..45a78357 100644 --- a/start/src/main.cpp +++ b/start/src/main.cpp @@ -22,6 +22,7 @@ Any arguments after -- are passed to Hyprland. For Hyprland help, run start-hypr Additional arguments for start-hyprland: --path [path] -> Override Hyprland path --no-nixgl -> Force disable nixGL + --force-nixgl -> Force enable nixGL )#"; // @@ -79,6 +80,10 @@ int main(int argc, const char** argv, const char** envp) { g_state->noNixGl = true; continue; } + if (arg == "--force-nixgl") { + g_state->forceNixGl = true; + continue; + } } if (startArgv != -1) |
