-
Notifications
You must be signed in to change notification settings - Fork 95
feat: native Wayland support and NixOS dev setup #22
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
base: main
Are you sure you want to change the base?
Changes from all commits
b22ef03
59f3e23
706df67
d1d2445
c58f312
4a9b352
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| use flake . |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| { | ||
| inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; | ||
|
|
||
| outputs = | ||
| { nixpkgs, ... }: | ||
| let | ||
| systems = [ | ||
| "x86_64-linux" | ||
| "aarch64-linux" | ||
| ]; | ||
| forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f nixpkgs.legacyPackages.${system}); | ||
| in | ||
| { | ||
| devShells = forAllSystems (pkgs: { | ||
| default = pkgs.mkShell { | ||
| packages = [ pkgs.nodejs pkgs.electron ]; | ||
| # Use the NixOS-patched Electron instead of the pre-built npm binary. | ||
| # pkgs.electron has correct RPATHs baked in, supports native Wayland | ||
| # (ozone/Chromium), and needs no LD_LIBRARY_PATH workarounds. | ||
| # electron-vite reads ELECTRON_EXEC_PATH before falling back to | ||
| # node_modules/electron/dist/electron. | ||
| ELECTRON_EXEC_PATH = "${pkgs.electron}/bin/electron"; | ||
| }; | ||
| }); | ||
| }; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,15 @@ import { electronApp, optimizer } from "@electron-toolkit/utils"; | |
| import { WindowManager } from "./window-manager"; | ||
| import { MenuManager } from "./menu-manager"; | ||
|
|
||
| // Fix GBM buffer object creation failures with DRM format modifiers on Wayland. | ||
| // These switches must be set before app.whenReady(). | ||
| if (process.platform === 'linux' && (process.env.WAYLAND_DISPLAY || process.env.XDG_SESSION_TYPE === 'wayland')) { | ||
| app.commandLine.appendSwitch('disable-features', 'UseChromeOSDirectVideoDecoder,VaapiVideoDecoder'); | ||
| // Disable DMA-buf zero-copy scanout path that triggers GBM BO modifier allocation failures | ||
| // on some GPU/driver combinations when Electron resizes GPU-backed surfaces on Wayland. | ||
| app.commandLine.appendSwitch('disable-zero-copy'); | ||
| } | ||
|
Comment on lines
+7
to
+14
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🌐 Web query:
💡 Result: They do not guarantee it. On Linux, Electron’s choice between native Wayland and X11/XWayland depends on Ozone platform selection (historically via flags and/or environment variables), and environment variables like WAYLAND_DISPLAY and XDG_SESSION_TYPE=wayland can be insufficient by themselves. 1) What the env vars do (and don’t) do - WAYLAND_DISPLAY and/or XDG_SESSION_TYPE=wayland indicate you are in a Wayland session, but they are not, on their own, a contractual “Electron must use the native Wayland Ozone backend” guarantee. - Electron’s backend selection is controlled by Ozone platform settings (e.g. --ozone-platform=wayland or --ozone-platform=x11), and/or Ozone platform “hint” logic that inspects XDG_SESSION_TYPE (or had similar behavior historically). 2) Native Wayland in Electron depends on Ozone/flags (and can still fall back to XWayland) - Electron documents that running on Wayland sessions historically did not automatically mean native Wayland; instead apps could use X11 via Xwayland unless the Ozone/Wayland platform path is selected. It explicitly contrasts “native Wayland” vs “running inside an invisible X server called Xwayland.” - Electron 38.0.0+ introduced native Wayland by default in Wayland sessions, but you can still force X11 compatibility mode with --ozone-platform=x11. 3) Evidence that “setting WAYLAND/XDG vars” alone can still result in XWayland - Real-world reports show Electron apps can choose XWayland even when started in a Wayland session, due to launchers/packaging setting Ozone hints to auto (or using other launcher logic), or due to Electron/version-specific Wayland detection issues. Practical conclusion - If you need to ensure native Wayland (no XWayland), set Electron explicitly to Wayland using Ozone flags, e.g. --enable-features=UseOzonePlatform --ozone-platform=wayland (or set the relevant Ozone hint/auto logic if your Electron version supports it as the default). - Do not assume that merely having WAYLAND_DISPLAY set or exporting XDG_SESSION_TYPE=wayland will always force native Wayland in Electron; Electron can still run via X11/XWayland unless its Ozone platform selection is aligned with Wayland. How to verify at runtime - Check whether the window is registered as an X11/XWayland surface (e.g., using tools like xwininfo/xprop/xlsclients) rather than relying solely on session env vars. - If you see X11/XWayland indicators, you’ll need to adjust Electron launch options (Ozone flags/hints) for your specific app/version. Citations:
🏁 Script executed: rg -n "WAYLAND_DISPLAY|XDG_SESSION_TYPE" src/main/window-manager.ts -A 3 -B 3Repository: Open-LLM-VTuber/Open-LLM-VTuber-Web Length of output: 352 🏁 Script executed: rg -n "isWayland" src/main/window-manager.ts -A 2 -B 2Repository: Open-LLM-VTuber/Open-LLM-VTuber-Web Length of output: 471 Gate these switches on Electron's actual backend, not just the desktop session.
🤖 Prompt for AI Agents |
||
|
|
||
| let windowManager: WindowManager; | ||
| let menuManager: MenuManager; | ||
| let isQuitting = false; | ||
|
|
@@ -71,6 +80,7 @@ function setupIPC(): void { | |
| const sources = await desktopCapturer.getSources({ types: ['screen'] }); | ||
| return sources[0].id; | ||
| }); | ||
|
|
||
| } | ||
|
|
||
| app.whenReady().then(() => { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix env var name mismatch in docs (
ELECTRON_OVERRIDE_DIST_PATHvsELECTRON_EXEC_PATH).Line 29 currently documents
ELECTRON_OVERRIDE_DIST_PATH, butflake.nixexportsELECTRON_EXEC_PATH. This will send users to the wrong knob.Suggested doc fix
📝 Committable suggestion
🤖 Prompt for AI Agents