From 2e61230a74473f359f25fc33cbfa16a32d89911c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damien=20Pl=C3=A9nard?= Date: Sat, 16 May 2026 17:49:32 +0200 Subject: [PATCH 1/4] fix(ghostty): wrap with GSK_RENDERER=gl to resolve OpenGL issues --- modules/home-manager/ghostty.nix | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/modules/home-manager/ghostty.nix b/modules/home-manager/ghostty.nix index d973e07..feb4978 100644 --- a/modules/home-manager/ghostty.nix +++ b/modules/home-manager/ghostty.nix @@ -1,8 +1,20 @@ { pkgs, ... }: +let + # This is the version that the user said worked for the UI. + ghostty-wrapped = pkgs.symlinkJoin { + name = "ghostty"; + paths = [ pkgs.ghostty ]; + nativeBuildInputs = [ pkgs.makeWrapper ]; + postBuild = '' + wrapProgram $out/bin/ghostty \ + --set GSK_RENDERER gl + ''; + }; +in { home.packages = [ - pkgs.ghostty + ghostty-wrapped ]; home.file.".config/ghostty/config".text = '' From 7428ea1f243f8f6bc5032988dddebfa22a7fbf4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damien=20Pl=C3=A9nard?= Date: Sat, 16 May 2026 17:52:11 +0200 Subject: [PATCH 2/4] refactor(ghostty): cleanup module and restrict wrapper to linux --- modules/home-manager/ghostty.nix | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/modules/home-manager/ghostty.nix b/modules/home-manager/ghostty.nix index feb4978..7cf78a2 100644 --- a/modules/home-manager/ghostty.nix +++ b/modules/home-manager/ghostty.nix @@ -1,20 +1,25 @@ -{ pkgs, ... }: +{ pkgs, lib, ... }: let - # This is the version that the user said worked for the UI. - ghostty-wrapped = pkgs.symlinkJoin { - name = "ghostty"; - paths = [ pkgs.ghostty ]; - nativeBuildInputs = [ pkgs.makeWrapper ]; - postBuild = '' - wrapProgram $out/bin/ghostty \ - --set GSK_RENDERER gl - ''; - }; + isLinux = pkgs.stdenv.isLinux; + + # Wrap ghostty on Linux to force the 'gl' renderer, fixing EGL display errors + # common in GTK4 environments on some distributions. + ghostty-pkg = if isLinux then + pkgs.symlinkJoin { + name = "ghostty"; + paths = [ pkgs.ghostty ]; + nativeBuildInputs = [ pkgs.makeWrapper ]; + postBuild = '' + wrapProgram $out/bin/ghostty \ + --set GSK_RENDERER gl + ''; + } + else pkgs.ghostty; in { home.packages = [ - ghostty-wrapped + ghostty-pkg ]; home.file.".config/ghostty/config".text = '' From 7d5929991fbbb0175b1d6bd5bc8c184edff0894e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damien=20Pl=C3=A9nard?= Date: Sat, 16 May 2026 18:09:00 +0200 Subject: [PATCH 3/4] fix(ghostty): robust dock support with dedicated launcher script --- modules/home-manager/ghostty.nix | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/modules/home-manager/ghostty.nix b/modules/home-manager/ghostty.nix index 7cf78a2..2e3e07e 100644 --- a/modules/home-manager/ghostty.nix +++ b/modules/home-manager/ghostty.nix @@ -16,10 +16,26 @@ let ''; } else pkgs.ghostty; + # Create a dedicated launcher script for Ghostty on Linux to handle nixGL and environment. + ghostty-launcher = pkgs.writeShellScriptBin "ghostty-launcher" '' + # Source nix profiles to ensure 'nix' and other tools are in PATH + if [ -e "$HOME/.nix-profile/etc/profile.d/nix.sh" ]; then + . "$HOME/.nix-profile/etc/profile.d/nix.sh" + elif [ -e /nix/var/nix/profiles/default/etc/profile.d/nix.sh ]; then + . /nix/var/nix/profiles/default/etc/profile.d/nix.sh + fi + + export NIXPKGS_ALLOW_UNFREE=1 + export GSK_RENDERER=gl + + # Execute ghostty via nixGL + exec /nix/var/nix/profiles/default/bin/nix run --impure github:nix-community/nixGL#nixGLNvidia -- ghostty "$@" + ''; in { home.packages = [ ghostty-pkg + (lib.mkIf isLinux ghostty-launcher) ]; home.file.".config/ghostty/config".text = '' @@ -27,4 +43,19 @@ in theme = dark:Dracula,light:Dracula font-size = 12 ''; + + # Enable XDG desktop entries to support launching from the Ubuntu dock + xdg.enable = true; + xdg.desktopEntries."com.mitchellh.ghostty" = lib.mkIf isLinux { + name = "Ghostty"; + genericName = "Terminal Emulator"; + exec = "${ghostty-launcher}/bin/ghostty-launcher"; + icon = "com.mitchellh.ghostty"; + terminal = false; + categories = [ "System" "TerminalEmulator" ]; + comment = "Ghostty terminal via nixGL"; + settings = { + StartupWMClass = "com.mitchellh.ghostty"; + }; + }; } From 7334c04aec51336cd0fb98f7f8b5c91d32c70912 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damien=20Pl=C3=A9nard?= Date: Sat, 16 May 2026 18:12:54 +0200 Subject: [PATCH 4/4] fix(ghostty): use absolute path for icon in desktop entry --- modules/home-manager/ghostty.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/home-manager/ghostty.nix b/modules/home-manager/ghostty.nix index 2e3e07e..a24eef4 100644 --- a/modules/home-manager/ghostty.nix +++ b/modules/home-manager/ghostty.nix @@ -50,7 +50,7 @@ in name = "Ghostty"; genericName = "Terminal Emulator"; exec = "${ghostty-launcher}/bin/ghostty-launcher"; - icon = "com.mitchellh.ghostty"; + icon = "${pkgs.ghostty}/share/icons/hicolor/512x512/apps/com.mitchellh.ghostty.png"; terminal = false; categories = [ "System" "TerminalEmulator" ]; comment = "Ghostty terminal via nixGL";