From 33ebda5633a5dd8cba3189338ea641d01973ac3e Mon Sep 17 00:00:00 2001 From: Denys Pavlov Date: Sat, 16 Dec 2023 12:58:17 -0500 Subject: [PATCH 1/4] nix: teach direnv about flake.nix imports direnv now watches flake.nix dependencies in `nix/`, reloading the environment on any changes. --- .envrc | 1 + 1 file changed, 1 insertion(+) diff --git a/.envrc b/.envrc index 7ee2b88b4..c57ee1c4f 100644 --- a/.envrc +++ b/.envrc @@ -1,5 +1,6 @@ # If we are a computer with nix-shell available, then use that to setup # the build environment with exactly what we need. if has nix; then + watch_file nix/{devShell,package,wraptest}.nix use flake fi From 82f102224f48b85b88d248ad4e055debb43634f9 Mon Sep 17 00:00:00 2001 From: Denys Pavlov Date: Sat, 16 Dec 2023 13:04:54 -0500 Subject: [PATCH 2/4] nix: use wrapGAppsHook4 to package ghostty `wrapGAppsHook4` is recommended by nixpkgs for packaging GTK4 applications.[1] It ensures `XDG_DATA_DIRS` includes the nescessary icons and gsettings schemas. --- nix/package.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/nix/package.nix b/nix/package.nix index 734aa3b85..fccb0a143 100644 --- a/nix/package.nix +++ b/nix/package.nix @@ -17,6 +17,8 @@ glib, gtk4, libadwaita, + wrapGAppsHook4, + gsettings-desktop-schemas, git, ncurses, pkg-config, @@ -89,6 +91,7 @@ in ncurses pkg-config zig012Hook + wrapGAppsHook4 ]; buildInputs = @@ -113,6 +116,7 @@ in libadwaita gtk4 glib + gsettings-desktop-schemas ]; dontConfigure = true; From 212a95866aa222c3b260743d16e0d73a543e542a Mon Sep 17 00:00:00 2001 From: Denys Pavlov Date: Sat, 16 Dec 2023 13:05:42 -0500 Subject: [PATCH 3/4] nix: fix GTK icons for debug builds Set `XDG_DATA_DIRS` in `nix develop` shell to include default Gnome icon sets and gsettings schemas. Sourced from [nixos wiki](https://nixos.wiki/wiki/Development_environment_with_nix-shell#No_GSettings_schemas_are_installed_on_the_system). --- nix/devShell.nix | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/nix/devShell.nix b/nix/devShell.nix index 1c03c6a6c..a9c264aa8 100644 --- a/nix/devShell.nix +++ b/nix/devShell.nix @@ -31,6 +31,8 @@ glib, gtk4, libadwaita, + gnome, + hicolor-icon-theme, harfbuzz, libpng, libGL, @@ -142,4 +144,10 @@ in # This should be set onto the rpath of the ghostty binary if you want # it to be "portable" across the system. LD_LIBRARY_PATH = lib.makeLibraryPath rpathLibs; + + shellHook = '' + # Minimal subset of env set by wrapGAppsHook4 for icons and global settings + export XDG_DATA_DIRS=$XDG_DATA_DIRS:${hicolor-icon-theme}/share:${gnome.adwaita-icon-theme}/share + export XDG_DATA_DIRS=$XDG_DATA_DIRS:$GSETTINGS_SCHEMAS_PATH # from glib setup hook + ''; } From d796d1259b9ab177af6c0b8529d22004d636ffd6 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sat, 16 Dec 2023 14:14:53 -0800 Subject: [PATCH 4/4] nix: only add shellhook on linux --- nix/devShell.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/nix/devShell.nix b/nix/devShell.nix index a9c264aa8..00418c0a8 100644 --- a/nix/devShell.nix +++ b/nix/devShell.nix @@ -145,7 +145,9 @@ in # it to be "portable" across the system. LD_LIBRARY_PATH = lib.makeLibraryPath rpathLibs; - shellHook = '' + # On Linux we need to setup the environment so that all GTK data + # is available (namely icons). + shellHook = lib.optionalString stdenv.isLinux '' # Minimal subset of env set by wrapGAppsHook4 for icons and global settings export XDG_DATA_DIRS=$XDG_DATA_DIRS:${hicolor-icon-theme}/share:${gnome.adwaita-icon-theme}/share export XDG_DATA_DIRS=$XDG_DATA_DIRS:$GSETTINGS_SCHEMAS_PATH # from glib setup hook