From 9da662e25f4885319499426f6f1f9d9d34386e92 Mon Sep 17 00:00:00 2001 From: "Jeffrey C. Ollie" Date: Thu, 26 Dec 2024 15:49:11 -0600 Subject: [PATCH] ghostty: init at 1.0.0 --- nixos/modules/config/terminfo.nix | 1 + pkgs/by-name/gh/ghostty/deps.nix | 351 ++++++++++++++++++++++++++++ pkgs/by-name/gh/ghostty/package.nix | 143 ++++++++++++ 3 files changed, 495 insertions(+) create mode 100644 pkgs/by-name/gh/ghostty/deps.nix create mode 100644 pkgs/by-name/gh/ghostty/package.nix diff --git a/nixos/modules/config/terminfo.nix b/nixos/modules/config/terminfo.nix index e61f10d4ec215..c81d9fe0d8e39 100644 --- a/nixos/modules/config/terminfo.nix +++ b/nixos/modules/config/terminfo.nix @@ -43,6 +43,7 @@ alacritty contour foot + ghostty kitty mtm rio diff --git a/pkgs/by-name/gh/ghostty/deps.nix b/pkgs/by-name/gh/ghostty/deps.nix new file mode 100644 index 0000000000000..2d9e8bcd711b9 --- /dev/null +++ b/pkgs/by-name/gh/ghostty/deps.nix @@ -0,0 +1,351 @@ +# generated by zon2nix (https://github.com/Cloudef/zig2nix) + +{ + lib, + linkFarm, + fetchurl, + fetchgit, + runCommandLocal, + zig, + name ? "zig-packages", +}: + +with builtins; +with lib; + +let + unpackZigArtifact = + { name, artifact }: + runCommandLocal name + { + nativeBuildInputs = [ zig ]; + } + '' + hash="$(zig fetch --global-cache-dir "$TMPDIR" ${artifact})" + mv "$TMPDIR/p/$hash" "$out" + chmod 755 "$out" + ''; + + fetchZig = + { + name, + url, + hash, + }: + let + artifact = fetchurl { inherit url hash; }; + in + unpackZigArtifact { inherit name artifact; }; + + fetchGitZig = + { + name, + url, + hash, + }: + let + parts = splitString "#" url; + url_base = elemAt parts 0; + url_without_query = elemAt (splitString "?" url_base) 0; + rev_base = elemAt parts 1; + rev = if match "^[a-fA-F0-9]{40}$" rev_base != null then rev_base else "refs/heads/${rev_base}"; + in + fetchgit { + inherit name rev hash; + url = url_without_query; + deepClone = false; + }; + + fetchZigArtifact = + { + name, + url, + hash, + }: + let + parts = splitString "://" url; + proto = elemAt parts 0; + path = elemAt parts 1; + fetcher = { + "git+http" = fetchGitZig { + inherit name hash; + url = "http://${path}"; + }; + "git+https" = fetchGitZig { + inherit name hash; + url = "https://${path}"; + }; + http = fetchZig { + inherit name hash; + url = "http://${path}"; + }; + https = fetchZig { + inherit name hash; + url = "https://${path}"; + }; + file = unpackZigArtifact { + inherit name; + artifact = /. + path; + }; + }; + in + fetcher.${proto}; +in +linkFarm name [ + { + name = "12206029de146b685739f69b10a6f08baee86b3d0a5f9a659fa2b2b66c9602078bbf"; + path = fetchZigArtifact { + name = "libxev"; + url = "https://github.com/mitchellh/libxev/archive/db6a52bafadf00360e675fefa7926e8e6c0e9931.tar.gz"; + hash = "sha256-4GT5wkfkZnIjNv20yDiWEzHAhbIiwHHJfS7A4u/LoNQ="; + }; + } + { + name = "12206ed982e709e565d536ce930701a8c07edfd2cfdce428683f3f2a601d37696a62"; + path = fetchZigArtifact { + name = "mach_glfw"; + url = "https://github.com/mitchellh/mach-glfw/archive/37c2995f31abcf7e8378fba68ddcf4a3faa02de0.tar.gz"; + hash = "sha256-HhXIvWUS8/CHWY4VXPG2ZEo+we8XOn3o5rYJCQ1n8Nk="; + }; + } + { + name = "1220736fa4ba211162c7a0e46cc8fe04d95921927688bff64ab5da7420d098a7272d"; + path = fetchZigArtifact { + name = "glfw"; + url = "https://github.com/mitchellh/glfw/archive/b552c6ec47326b94015feddb36058ea567b87159.tar.gz"; + hash = "sha256-IeBVAOQmtyFqVxzuXPek1onuPwIamcOyYtxqKpPEQjU="; + }; + } + { + name = "12202adbfecdad671d585c9a5bfcbd5cdf821726779430047742ce1bf94ad67d19cb"; + path = fetchZigArtifact { + name = "xcode_frameworks"; + url = "https://github.com/mitchellh/xcode-frameworks/archive/69801c154c39d7ae6129ea1ba8fe1afe00585fc8.tar.gz"; + hash = "sha256-mP/I2coL57UJm/3+4Q8sPAgQwk8V4zM+S4VBBTrX2To="; + }; + } + { + name = "122004bfd4c519dadfb8e6281a42fc34fd1aa15aea654ea8a492839046f9894fa2cf"; + path = fetchZigArtifact { + name = "vulkan_headers"; + url = "https://github.com/mitchellh/vulkan-headers/archive/04c8a0389d5a0236a96312988017cd4ce27d8041.tar.gz"; + hash = "sha256-K+zrRudgHFukOM6En1StRYRMNYkeRk+qHTXvrXaG+FU="; + }; + } + { + name = "1220b3164434d2ec9db146a40bf3a30f490590d68fa8529776a3138074f0da2c11ca"; + path = fetchZigArtifact { + name = "wayland_headers"; + url = "https://github.com/mitchellh/wayland-headers/archive/5f991515a29f994d87b908115a2ab0b899474bd1.tar.gz"; + hash = "sha256-uFilLZinKkZt6RdVTV3lUmJpzpswDdFva22FvwU/XQI="; + }; + } + { + name = "122089c326186c84aa2fd034b16abc38f3ebf4862d9ae106dc1847ac44f557b36465"; + path = fetchZigArtifact { + name = "x11_headers"; + url = "https://github.com/mitchellh/x11-headers/archive/2ffbd62d82ff73ec929dd8de802bc95effa0ef88.tar.gz"; + hash = "sha256-EhV2bmTY/OMYN1wEul35gD0hQgS/Al262jO3pVr0O+c="; + }; + } + { + name = "1220e17e64ef0ef561b3e4b9f3a96a2494285f2ec31c097721bf8c8677ec4415c634"; + path = fetchZigArtifact { + name = "zig_objc"; + url = "https://github.com/mitchellh/zig-objc/archive/9b8ba849b0f58fe207ecd6ab7c147af55b17556e.tar.gz"; + hash = "sha256-H+HIbh2T23uzrsg9/1/vl9Ir1HCAa2pzeTx6zktJH9Q="; + }; + } + { + name = "12205a66d423259567764fa0fc60c82be35365c21aeb76c5a7dc99698401f4f6fefc"; + path = fetchZigArtifact { + name = "zig_js"; + url = "https://github.com/mitchellh/zig-js/archive/d0b8b0a57c52fbc89f9d9fecba75ca29da7dd7d1.tar.gz"; + hash = "sha256-fyNeCVbC9UAaKJY6JhAZlT0A479M/AKYMPIWEZbDWD0="; + }; + } + { + name = "12207831bce7d4abce57b5a98e8f3635811cfefd160bca022eb91fe905d36a02cf25"; + path = fetchZigArtifact { + name = "ziglyph"; + url = "https://deps.files.ghostty.org/ziglyph-b89d43d1e3fb01b6074bc1f7fc980324b04d26a5.tar.gz"; + hash = "sha256-cse98+Ft8QUjX+P88yyYfaxJOJGQ9M7Ymw7jFxDz89k="; + }; + } + { + name = "12204358b2848ffd993d3425055bff0a5ba9b1b60bead763a6dea0517965d7290a6c"; + path = fetchZigArtifact { + name = "iterm2_themes"; + url = "https://github.com/mbadolato/iTerm2-Color-Schemes/archive/d6c42066b3045292e0b1154ad84ff22d6863ebf7.tar.gz"; + hash = "sha256-s6us3PkOPmQCtLS9QNPM7BDLt7x+37KbmYF9d4NMD/c="; + }; + } + { + name = "12200df4ebeaed45de26cb2c9f3b6f3746d8013b604e035dae658f86f586c8c91d2f"; + path = fetchZigArtifact { + name = "vaxis"; + url = "git+https://github.com/rockorager/libvaxis/?ref=main#6d729a2dc3b934818dffe06d2ba3ce02841ed74b"; + hash = "sha256-fFf79fCy4QQFVNcN722tSMjB6FyVEzCB36oH1olk9JQ="; + }; + } + { + name = "1220dd654ef941fc76fd96f9ec6adadf83f69b9887a0d3f4ee5ac0a1a3e11be35cf5"; + path = fetchZigArtifact { + name = "zigimg"; + url = "git+https://github.com/zigimg/zigimg#3a667bdb3d7f0955a5a51c8468eac83210c1439e"; + hash = "sha256-oLf3YH3yeg4ikVO/GahMCDRMTU31AHkfSnF4rt7xTKo="; + }; + } + { + name = "122055beff332830a391e9895c044d33b15ea21063779557024b46169fb1984c6e40"; + path = fetchZigArtifact { + name = "zg"; + url = "https://codeberg.org/atman/zg/archive/v0.13.2.tar.gz"; + hash = "sha256-2x9hT7bYq9KJYWLVOf21a+QvTG/F7HWT+YK15IMRzNY="; + }; + } + { + name = "1220edc3b8d8bedbb50555947987e5e8e2f93871ca3c8e8d4cc8f1377c15b5dd35e8"; + path = fetchZigArtifact { + name = "zf"; + url = "git+https://github.com/natecraddock/zf/?ref=main#ed99ca18b02dda052e20ba467e90b623c04690dd"; + hash = "sha256-t6QNrEJZ4GZZsYixjYvpdrYoCmNbG8TTUmGs2MFa4sU="; + }; + } + { + name = "1220c72c1697dd9008461ead702997a15d8a1c5810247f02e7983b9f74c6c6e4c087"; + path = fetchZigArtifact { + name = "vaxis"; + url = "git+https://github.com/rockorager/libvaxis/?ref=main#dc0a228a5544988d4a920cfb40be9cd28db41423"; + hash = "sha256-QWN4jOrA91KlbqmeEHHJ4HTnCC9nmfxt8DHUXJpAzLI="; + }; + } + { + name = "12201f0d542e7541cf492a001d4d0d0155c92f58212fbcb0d224e95edeba06b5416a"; + path = fetchZigArtifact { + name = "z2d"; + url = "git+https://github.com/vancluever/z2d?ref=v0.4.0#4638bb02a9dc41cc2fb811f092811f6a951c752a"; + hash = "sha256-YpWXn1J3JKQSCrWB25mAfzd1/T56QstEZnhPzBwxgoM="; + }; + } + { + name = "1220bc6b9daceaf7c8c60f3c3998058045ba0c5c5f48ae255ff97776d9cd8bfc6402"; + path = fetchZigArtifact { + name = "imgui"; + url = "https://github.com/ocornut/imgui/archive/e391fe2e66eb1c96b1624ae8444dc64c23146ef4.tar.gz"; + hash = "sha256-oF/QHgTPEat4Hig4fGIdLkIPHmBEyOJ6JeYD6pnveGA="; + }; + } + { + name = "1220b81f6ecfb3fd222f76cf9106fecfa6554ab07ec7fdc4124b9bb063ae2adf969d"; + path = fetchZigArtifact { + name = "freetype"; + url = "https://github.com/freetype/freetype/archive/refs/tags/VER-2-13-2.tar.gz"; + hash = "sha256-QnIB9dUVFnDQXB9bRb713aHy592XHvVPD+qqf/0quQw="; + }; + } + { + name = "1220aa013f0c83da3fb64ea6d327f9173fa008d10e28bc9349eac3463457723b1c66"; + path = fetchZigArtifact { + name = "libpng"; + url = "https://github.com/glennrp/libpng/archive/refs/tags/v1.6.43.tar.gz"; + hash = "sha256-/syVtGzwXo4/yKQUdQ4LparQDYnp/fF16U/wQcrxoDo="; + }; + } + { + name = "1220fed0c74e1019b3ee29edae2051788b080cd96e90d56836eea857b0b966742efb"; + path = fetchZigArtifact { + name = "zlib"; + url = "https://github.com/madler/zlib/archive/refs/tags/v1.3.1.tar.gz"; + hash = "sha256-F+iIY/NgBnKrSRgvIXKBtvxNPHYr3jYZNeQ2qVIU0Fw="; + }; + } + { + name = "12201149afb3326c56c05bb0a577f54f76ac20deece63aa2f5cd6ff31a4fa4fcb3b7"; + path = fetchZigArtifact { + name = "fontconfig"; + url = "https://deps.files.ghostty.org/fontconfig-2.14.2.tar.gz"; + hash = "sha256-O6LdkhWHGKzsXKrxpxYEO1qgVcJ7CB2RSvPMtA3OilU="; + }; + } + { + name = "122032442d95c3b428ae8e526017fad881e7dc78eab4d558e9a58a80bfbd65a64f7d"; + path = fetchZigArtifact { + name = "libxml2"; + url = "https://github.com/GNOME/libxml2/archive/refs/tags/v2.11.5.tar.gz"; + hash = "sha256-bCgFni4+60K1tLFkieORamNGwQladP7jvGXNxdiaYhU="; + }; + } + { + name = "1220b8588f106c996af10249bfa092c6fb2f35fbacb1505ef477a0b04a7dd1063122"; + path = fetchZigArtifact { + name = "harfbuzz"; + url = "https://github.com/harfbuzz/harfbuzz/archive/refs/tags/8.4.0.tar.gz"; + hash = "sha256-nxygiYE7BZRK0c6MfgGCEwJtNdybq0gKIeuHaDg5ZVY="; + }; + } + { + name = "12205c83b8311a24b1d5ae6d21640df04f4b0726e314337c043cde1432758cbe165b"; + path = fetchZigArtifact { + name = "highway"; + url = "https://github.com/google/highway/archive/refs/tags/1.1.0.tar.gz"; + hash = "sha256-NUqLRTm1iOcLmOxwhEJz4/J0EwLEw3e8xOgbPRhm98k="; + }; + } + { + name = "1220c15e72eadd0d9085a8af134904d9a0f5dfcbed5f606ad60edc60ebeccd9706bb"; + path = fetchZigArtifact { + name = "oniguruma"; + url = "https://github.com/kkos/oniguruma/archive/refs/tags/v6.9.9.tar.gz"; + hash = "sha256-ABqhIC54RI9MC/GkjHblVodrNvFtks4yB+zP1h2Z8qA="; + }; + } + { + name = "1220446be831adcca918167647c06c7b825849fa3fba5f22da394667974537a9c77e"; + path = fetchZigArtifact { + name = "sentry"; + url = "https://github.com/getsentry/sentry-native/archive/refs/tags/0.7.8.tar.gz"; + hash = "sha256-KsZJfMjWGo0xCT5HrduMmyxFsWsHBbszSoNbZCPDGN8="; + }; + } + { + name = "12207fd37bb8251919c112dcdd8f616a491857b34a451f7e4486490077206dc2a1ea"; + path = fetchZigArtifact { + name = "breakpad"; + url = "https://github.com/getsentry/breakpad/archive/b99f444ba5f6b98cac261cbb391d8766b34a5918.tar.gz"; + hash = "sha256-bMqYlD0amQdmzvYQd8Ca/1k4Bj/heh7+EijlQSttatk="; + }; + } + { + name = "1220d4d18426ca72fc2b7e56ce47273149815501d0d2395c2a98c726b31ba931e641"; + path = fetchZigArtifact { + name = "utfcpp"; + url = "https://github.com/nemtrif/utfcpp/archive/refs/tags/v4.0.5.tar.gz"; + hash = "sha256-/8ZooxDndgfTk/PBizJxXyI9oerExNbgV5oR345rWc8="; + }; + } + { + name = "12200984439edc817fbcbbaff564020e5104a0d04a2d0f53080700827052de700462"; + path = fetchZigArtifact { + name = "wuffs"; + url = "https://github.com/google/wuffs/archive/refs/tags/v0.4.0-alpha.8.tar.gz"; + hash = "sha256-P3fpKYaiOpZffe2uNDkC43MFntV38Cl2XpHFF50r80Q="; + }; + } + { + name = "12201278a1a05c0ce0b6eb6026c65cd3e9247aa041b1c260324bf29cee559dd23ba1"; + path = fetchZigArtifact { + name = "glslang"; + url = "https://github.com/KhronosGroup/glslang/archive/refs/tags/14.2.0.tar.gz"; + hash = "sha256-FKLtu1Ccs+UamlPj9eQ12/WXFgS0uDPmPmB26MCpl7U="; + }; + } + { + name = "1220fb3b5586e8be67bc3feb34cbe749cf42a60d628d2953632c2f8141302748c8da"; + path = fetchZigArtifact { + name = "spirv_cross"; + url = "https://github.com/KhronosGroup/SPIRV-Cross/archive/476f384eb7d9e48613c45179e502a15ab95b6b49.tar.gz"; + hash = "sha256-tStvz8Ref6abHwahNiwVVHNETizAmZVVaxVsU7pmV+M="; + }; + } +] diff --git a/pkgs/by-name/gh/ghostty/package.nix b/pkgs/by-name/gh/ghostty/package.nix new file mode 100644 index 0000000000000..e056115a69abf --- /dev/null +++ b/pkgs/by-name/gh/ghostty/package.nix @@ -0,0 +1,143 @@ +{ + lib, + stdenv, + bzip2, + callPackage, + expat, + fetchFromGitHub, + fontconfig, + freetype, + git, + glib, + gsettings-desktop-schemas, + gtk4, + harfbuzz, + libadwaita, + libGL, + libpng, + libX11, + libXcursor, + libXi, + libXrandr, + ncurses, + nix-update-script, + oniguruma, + pandoc, + pkg-config, + wrapGAppsHook4, + zig_0_13, + zlib, +}: +let + # Ghostty needs to be built with --release=fast, --release=debug and + # --release=safe enable too many runtime safety checks. + zig_hook = zig_0_13.hook.overrideAttrs { + zig_default_flags = "-Dcpu=baseline -Doptimize=ReleaseFast --color off"; + }; +in +stdenv.mkDerivation (final: { + pname = "ghostty"; + version = "1.0.0"; + + src = fetchFromGitHub { + owner = "ghostty-org"; + repo = "ghostty"; + tag = "v${final.version}"; + hash = "sha256-AHI1Z4mfgXkNwQA8xYq4tS0/BARbHL7gQUT41vCxQTM="; + }; + + nativeBuildInputs = [ + git + ncurses + pandoc + pkg-config + wrapGAppsHook4 + zig_hook + ]; + + buildInputs = [ + bzip2 + expat + fontconfig + freetype + glib + gsettings-desktop-schemas + gtk4 + harfbuzz + libadwaita + libGL + libpng + libX11 + libXcursor + libXi + libXrandr + oniguruma + zlib + ]; + + dontPatch = true; + dontConfigure = true; + # doCheck is set to false because unit tests currently fail inside the Nix sandbox. + doCheck = false; + + deps = callPackage ./deps.nix { name = "${final.pname}-cache-${final.version}"; }; + + zigBuildFlags = [ + "--system" + "${final.deps}" + "-Dversion-string=${final.version}" + ]; + + outputs = [ + "out" + "terminfo" + "shell_integration" + "vim" + ]; + + checkPhase = '' + runHook preCheck + zig build --verbose -Dcpu=baseline -Doptimize=Debug ${lib.strings.concatStringsSep " " final.zigBuildFlags} test + runHook postCheck + ''; + + postInstall = '' + mkdir -p "$terminfo/share" + mv "$out/share/terminfo" "$terminfo/share/terminfo" + ln -sf "$terminfo/share/terminfo" "$out/share/terminfo" + + mkdir -p "$shell_integration" + mv "$out/share/ghostty/shell-integration" "$shell_integration/shell-integration" + ln -sf "$shell_integration/shell-integration" "$out/share/ghostty/shell-integration" + + mv "$out/share/vim/vimfiles" "$vim" + ln -sf "$vim" "$out/share/vim/vimfiles" + ''; + + preFixup = '' + gappsWrapperArgs+=(--prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath [ libX11 ]}") + ''; + + passthru.updateScript = nix-update-script { }; + + meta = { + homepage = "https://ghostty.org/"; + description = "Fast, native, feature-rich terminal emulator pushing modern features"; + longDescription = '' + Ghostty is a terminal emulator that differentiates itself by being + fast, feature-rich, and native. While there are many excellent terminal + emulators available, they all force you to choose between speed, + features, or native UIs. Ghostty provides all three. + ''; + downloadPage = "https://ghostty.org/download"; + + license = lib.licenses.mit; + platforms = lib.platforms.linux; + mainProgram = "ghostty"; + outputsToInstall = final.outputs; + maintainers = with lib.maintainers; [ + jcollie + pluiedev + ]; + }; +})