omarchy icon indicating copy to clipboard operation
omarchy copied to clipboard

4.0.x: user ~/.config/hypr/envs.lua is never loaded — user env overrides (and the updater's own iHD fix) are dead code

Open Makedayz opened this issue 3 months ago • 4 comments

System details

Intel UHD Graphics (Raptor Lake-P, iGPU-primary) + NVIDIA RTX 4050 hybrid laptop, Omarchy 4.0.1, Hyprland / Wayland

What's wrong?

~/.config/hypr/envs.lua — the personal counterpart of default/hypr/envs.lua — is never loaded. Nothing ever requires it, so env vars a user sets there are silently ignored.

Evidence

  1. Neither the migrated user config, the shipped template (config/hypr/hyprland.lua), nor current main requires hypr.envs. The personal requires are only hypr.monitors, hypr.input, hypr.bindings, hypr.looknfeel, hypr.autostart — and the comment block above them ("Put your personal overrides in these files") does not mention envs either.
  2. grep -rn 'hypr\.envs' /usr/share/omarchy ~/.config/hypr finds only default.hypr.envs (omarchy.lua:16). No reference to the user module.
  3. default/hypr/bootstrap.lua only adds ~/.config/?.lua to package.path (making the module requireable); it does not load it. require_all is used only for apps, bindings, toggles, and workspace-layouts — never for ~/.config/hypr.
  4. Meanwhile the defaults do set hardware envs: omarchy.lua → default.hypr.envs → default.hypr.nvidia → on a hybrid laptop with GSP, LIBVA_DRIVER_NAME=nvidia is what actually lands in the session.

Concrete failure on this hybrid laptop

An Omarchy update (Aug 29, 4.0.x) itself rewrote the user's envs.lua from LIBVA_DRIVER_NAME=nvidia to iHD, leaving a timestamped .bak and this comment:

-- Video decode (VAAPI) forced to Intel iGPU: the panel is wired to Intel,
-- so decoding on NVIDIA required an extra cross-GPU frame copy that caused
-- browser video glitches. NVIDIA still handles OpenGL/Vulkan (games) above.

But since nothing loads envs.lua, the updater's own fix never takes effect. Browsers inherit no LIBVA_DRIVER_NAME, libva auto-detects a driver per render node, selects the NVDEC VAAPI shim on the dGPU node, and hardware-decoded video in Chromium/Brave paints a checkerboard (or never paints at all).

Steps to reproduce

  1. Omarchy 4.0.1 on an iGPU-primary Intel+NVIDIA hybrid laptop.
  2. Set hl.env("LIBVA_DRIVER_NAME", "iHD") in ~/.config/hypr/envs.lua, relogin.
  3. systemctl --user show-environment | grep LIBVA → variable not applied; browser video still broken.
  4. Launch a browser directly with LIBVA_DRIVER_NAME=iHD brave → video plays fine (confirming the env is the whole fix).
  5. Add require("hypr.envs") to the personal block of hyprland.lua, relogin → LIBVA_DRIVER_NAME=iHD is exported and video works without the manual env.

Regression note: in 3.x the personal env file was loaded — hyprland.conf sourced ~/.config/hypr/envs.conf in the personal overrides section (see the load order in #6068). The 3.x → 4.x Lua migration dropped it from the personal require list, while the updater still patches the file as if it were live.

Suggested fix: add require_optional.module("hypr.envs") (or require("hypr.envs")) alongside the other personal requires in config/hypr/hyprland.lua, and have the updater insert that require into migrated hyprland.lua files that predate 4.0.

Related but distinct: #8989, #9890, #9096, #8328, #8215, #9708 report the video corruption caused by nvidia.lua forcing NVIDIA VA-API on hybrid laptops. This report is about the user env override channel itself being dead code — which also silently disables the updater's own envs.lua fix.

Makedayz avatar Sep 02 '26 23:09 Makedayz

Reproduced on a clean Omarchy 4.0 worker VM running a real Hyprland session, and traced the history in git. Reviewed by Opus 5 in Claude Code, with an independent second opinion from Codex (gpt-5.6-sol) at xhigh reasoning; where it changed the answer is noted below.

Confirmed: ~/.config/hypr/envs.lua is never loaded. On the worker I put hl.env("OMARCHY_TRIAGE_9902", ...) and hl.env("TERMINAL", "triage-marker-9902") into ~/.config/hypr/envs.lua, reloaded, and read /proc/<pid>/environ of a process the compositor spawned: neither variable was there, while XCURSOR_SIZE=24 and GDK_BACKEND=wayland,x11,* from default/hypr/envs.lua were. Adding require("hypr.envs") to the personal block of ~/.config/hypr/hyprland.lua and reloading made both appear. default/hypr/bootstrap.lua:33-39 only puts ~/.config/?.lua on package.path; nothing requires the module.

Two parts of the report do not hold up.

The removal was not the 3.x to 4.x Lua migration. source = ~/.config/hypr/envs.conf was dropped from config/hypr/hyprland.conf in 638e35fc ("Hyprland envs are superseeded by uwsm/env", 5 Nov 2025), first released in v3.2.0. The Lua swap (b9365099, May 2026) converted only default.hypr.envs, and its hyprland.lua never carried a personal envs require. Omarchy has also never shipped a config/hypr/envs.lua — git log --all -- config/hypr/envs.lua is empty — so this is not an abandoned personal counterpart; windows, qconsole and apps are default-only modules in the same way.

Nothing in Omarchy wrote iHD into your envs.lua. The string appears nowhere in the tree; the Aug 26-27 commits that mention it (4cb571b5, 6677d060, 22f0bbc2) only pick which Intel VA-API package to install, and neither Aug 29 migration (1788009111, 1788025225) touches Hyprland config. omarchy-refresh-config does write <file>.bak.<epoch>, which matches the backup shape you saw, but it refuses any path with no shipped config/ counterpart, so it cannot target envs.lua. The only code that ever wrote ~/.config/hypr/envs.lua was install/config/hardware/nvidia-user.sh, which existed for one day (53e26115 to b45e8464, 24-25 May 2026), appended only NVIDIA lines to a file that already existed, and shipped in no 4.0 release. So both the file and the iHD edit came from outside Omarchy.

What is a real 4.0.x defect, and the part worth acting on: the manual points at ~/.config/uwsm/env.d/* for session environment variables (manual/46-faq.md:57), and that channel cannot override anything Omarchy sets with hl.env. uwsm exports its environment before executing Hyprland, and Hyprland's env is applied afterwards into the compositor, which every client inherits. I proved that direction on the worker: TERMINAL is xdg-terminal-exec from default/uwsm/env.d/10-omarchy, and an hl.env("TERMINAL", ...) overrode it in a spawned child. On a GSP NVIDIA machine default/hypr/nvidia.lua:12-14 sets NVD_BACKEND, LIBVA_DRIVER_NAME and __GLX_VENDOR_LIBRARY_NAME, so the documented escape hatch does not work for exactly those three — which is the override the hybrid-GPU reports (#9890, #8328, #8989, #9096, #8215, #9708) all reach for.

A workaround that works today. Put the hl.env call directly at the bottom of ~/.config/hypr/hyprland.lua, under "Add any other personal Hyprland configuration below":

hl.env("LIBVA_DRIVER_NAME", "iHD")

That section is evaluated after require("default.hypr.omarchy"), so it wins. I verified the equivalent on the worker: an hl.env("XCURSOR_SIZE", "99") in a module required after the defaults replaced default/hypr/envs.lua:8's 24 in a spawned client.

No PR from this triage. Reinstating a personal env module reverses the decision recorded in 638e35fc, and a change to config/hypr/hyprland.lua reaches new installs only — updates deliberately do not rewrite ~/.config/hypr, so existing users would need a migration that edits a user file. Codex contributed two mechanics that rule out the suggested patch as written: require_optional is a local in default/hypr/omarchy.lua:4, so require_optional.module("hypr.envs") in hyprland.lua indexes a nil global, and a bare require("hypr.envs") aborts the rest of the config when the file is absent. I confirmed the second on the worker — with envs.lua deleted, hyprctl configerrors reported "module 'hypr.envs' not found" at hyprland.lua:24 and the requires below it never ran. Whether the answer is a personal envs.lua module, documenting the hyprland.lua tail as the env channel, or making nvidia.lua yield to a value already in the environment is a design call for the maintainer.

omarchybot avatar Sep 03 '26 12:09 omarchybot

I have some additional observations about applying the workaround on the machine described in my comment on #8215.

My ~/.config/hypr/hyprland.lua loads the personal monitors, input, bindings, looknfeel, and autostart modules, but has no require("hypr.envs"). I haven't independently tested an override placed in envs.lua.

I've put the override directly after the defaults in hyprland.lua:

hl.env("LIBVA_DRIVER_NAME", "iHD")

hyprctl reload succeeded and hyprctl configerrors was empty. I also found that my user manager retained LIBVA_DRIVER_NAME=nvidia. After applying:

systemctl --user set-environment LIBVA_DRIVER_NAME=iHD

I verified that systemctl --user show-environment reported LIBVA_DRIVER_NAME=iHD.

To correct my original comment: I've also restarted the shell and Chromium, but I haven't isolated whether both restarts were necessary or verified the decoder's loaded driver afterward. Reading Chromium's /proc/<pid>/environ returned NUL bytes, so I couldn't establish which value Chromium inherited from that check. I've confirmed the config and user-manager state; I still need to confirm successful Discord stream playback.

CompleteDotTech avatar Sep 04 '26 22:09 CompleteDotTech

Duplicate of #8215 — same root cause (nvidia.lua forces LIBVA_DRIVER_NAME=nvidia on hybrid laptops). See that issue for full details, regression history, and workaround.

Local fix: browser launchers export LIBVA_DRIVER_NAME=iHD + MESA_LOADER_DRIVER_OVERRIDE=iris scoped to browser processes only (system stays on NVIDIA for games/CUDA).

andyholst avatar Sep 22 '26 07:09 andyholst

Following up on the earlier triage now that quattro has moved. Checked by Opus 5.5 in Claude Code, with a second opinion from Codex at medium effort, which agreed on every point below; it read the same tree, so its agreement is not guaranteed to be independent.

The hybrid-laptop symptom is fixed on quattro, not yet released. #11690 (6ecf4bf2) makes default/hypr/nvidia.lua set LIBVA_DRIVER_NAME and __GLX_VENDOR_LIBRARY_NAME only when bin/omarchy-hw-nvidia-display finds NVIDIA driving the display, read from each GPU's boot_vga in sysfs. On a worker VM at quattro 98301428, I ran the real detectors and nvidia.lua against a simulated sysfs matching your machine (Intel Raptor Lake-P iGPU as the boot display, an RTX 4050 Laptop with boot_vga=0): NVD_BACKEND=direct is still set and neither of the other two is. test/shell.d/hw-nvidia-test.sh passed 11 of 11 there too. The latest release, v4.0.4, still sets both variables unconditionally, so the fix reaches you with the next release. Because the new code skips setting the variable rather than clearing it, a user manager that already holds LIBVA_DRIVER_NAME=nvidia from an earlier session (as @CompleteDotTech saw) keeps it until a reboot or systemctl --user unset-environment LIBVA_DRIVER_NAME.

This issue is not a duplicate of #8215. They share that symptom, but #8215 asks for the NVIDIA driver choice to be gated on the display GPU, which #11690 did. This issue asks for a personal ~/.config/hypr/envs.lua to be loaded, and #11690 leaves that exactly as it was: config/hypr/hyprland.lua:19-23 still requires only the five personal modules, and nothing else loads hypr.envs.

That part is unchanged and still waits on the maintainer. As the earlier comment said, the personal env file was removed on purpose in v3.2.0 (638e35fc), so bringing it back is a design decision rather than a defect fix. Until then, hl.env(...) at the bottom of ~/.config/hypr/hyprland.lua remains the way to override a variable Omarchy sets. A file in ~/.config/uwsm/env.d/ can't do it, because Hyprland's hl.env runs later and overwrites the value.

omarchybot avatar Oct 11 '26 02:10 omarchybot