mise run install builds a release binary and installs it into ~/.local with a desktop entry and a hicolor icon. Two wrinkles specific to a Nix-built GTK app installed outside the dev shell: the launcher is a generated script rather than a symlink, because a desktop launcher provides a minimal environment and GTK still needs to be pointed at its GSettings schemas and icon themes; and install registers Nix GC roots for every store path in the binary's RPATH, so nix-collect-garbage cannot delete GTK out from under the installed app. The runtime paths are exported from the flake's shellHook and read back at install time, so they cannot drift from what the binary was built against.
108 lines
3.3 KiB
Nix
108 lines
3.3 KiB
Nix
{
|
|
description = "Vertical-tab terminal built on libghostty-vt";
|
|
|
|
inputs = {
|
|
# Ghostty tracks nixpkgs-unstable to get GTK 4.20 / GNOME 49. We follow
|
|
# suit so that our zig-gobject bindings (shared with Ghostty) match the
|
|
# GObject introspection data of the GTK we link against.
|
|
nixpkgs.url = "https://channels.nixos.org/nixpkgs-unstable/nixexprs.tar.xz";
|
|
|
|
flake-compat = {
|
|
url = "github:edolstra/flake-compat";
|
|
flake = false;
|
|
};
|
|
|
|
systems = {
|
|
url = "github:nix-systems/default";
|
|
flake = false;
|
|
};
|
|
|
|
# Zig 0.16.0 is not in nixpkgs yet; libghostty-vt requires it.
|
|
zig = {
|
|
url = "github:mitchellh/zig-overlay";
|
|
inputs = {
|
|
nixpkgs.follows = "nixpkgs";
|
|
flake-compat.follows = "flake-compat";
|
|
systems.follows = "systems";
|
|
};
|
|
};
|
|
};
|
|
|
|
outputs = {
|
|
self,
|
|
nixpkgs,
|
|
zig,
|
|
systems,
|
|
...
|
|
}: let
|
|
inherit (nixpkgs) lib legacyPackages;
|
|
|
|
forAllSystems = f:
|
|
lib.genAttrs (import systems) (system: f legacyPackages.${system} system);
|
|
in {
|
|
devShells = forAllSystems (pkgs: system: {
|
|
default = pkgs.mkShell {
|
|
name = "vtabs";
|
|
|
|
nativeBuildInputs = [
|
|
zig.packages.${system}."0.16.0"
|
|
pkgs.pkg-config
|
|
pkgs.gdb
|
|
|
|
# Used by ./shot.sh to run the app inside a throwaway headless
|
|
# compositor and screenshot it, so UI can be checked without
|
|
# touching the developer's real session.
|
|
pkgs.sway
|
|
pkgs.grim
|
|
pkgs.wtype
|
|
];
|
|
|
|
buildInputs = with pkgs; [
|
|
# GTK4 + libadwaita, the same native UI stack Ghostty uses on Linux.
|
|
gtk4
|
|
libadwaita
|
|
glib
|
|
gobject-introspection
|
|
pango
|
|
cairo
|
|
harfbuzz
|
|
gdk-pixbuf
|
|
graphene
|
|
|
|
# Windowing backends GTK links against.
|
|
wayland
|
|
libxkbcommon
|
|
libx11
|
|
|
|
# Font stack used by Pango for glyph rasterization.
|
|
fontconfig
|
|
freetype
|
|
|
|
# Icon themes so the app doesn't render missing-image icons.
|
|
adwaita-icon-theme
|
|
hicolor-icon-theme
|
|
];
|
|
|
|
shellHook = ''
|
|
# The runtime data GTK needs to find at startup: its own GSettings
|
|
# schemas and the icon themes our widgets pull symbolic icons from.
|
|
#
|
|
# These are exported under their own names, rather than only folded
|
|
# into XDG_DATA_DIRS, because `mise run install` reads them back out
|
|
# to bake into the installed launcher. The built binary already has
|
|
# an RPATH into the Nix store and runs fine outside this shell, but
|
|
# it still has to be pointed at this data or GTK aborts on a missing
|
|
# schema and falls back to broken-image icons.
|
|
export VTABS_GSETTINGS_SCHEMA_DIR="${pkgs.gtk4}/share/gsettings-schemas/${pkgs.gtk4.name}/glib-2.0/schemas"
|
|
export VTABS_RUNTIME_DATA_DIRS="${pkgs.gtk4}/share/gsettings-schemas/${pkgs.gtk4.name}:${pkgs.adwaita-icon-theme}/share:${pkgs.hicolor-icon-theme}/share"
|
|
|
|
export GSETTINGS_SCHEMA_DIR="$VTABS_GSETTINGS_SCHEMA_DIR"
|
|
export XDG_DATA_DIRS="$VTABS_RUNTIME_DATA_DIRS:$XDG_DATA_DIRS"
|
|
'';
|
|
};
|
|
});
|
|
|
|
formatter = forAllSystems (pkgs: _: pkgs.alejandra);
|
|
};
|
|
}
|