start: add --force-nixgl and check /run/opengl-driver (#13385)

This commit is contained in:
Vaxry 2026-02-27 17:57:04 +00:00 committed by GitHub
parent 70cdd819e4
commit f624449c12
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 23 additions and 2 deletions

View file

@ -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>();

View file

@ -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;

View file

@ -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)