nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 195 lines 4.8 kB view raw
1{ 2 lib, 3 stdenv, 4 blueprint-compiler, 5 bzip2, 6 callPackage, 7 fetchFromGitHub, 8 fetchpatch2, 9 fontconfig, 10 freetype, 11 glib, 12 glslang, 13 gtk4-layer-shell, 14 harfbuzz, 15 libGL, 16 libX11, 17 libadwaita, 18 ncurses, 19 nixosTests, 20 oniguruma, 21 pandoc, 22 pkg-config, 23 removeReferencesTo, 24 versionCheckHook, 25 wrapGAppsHook4, 26 zig_0_14, 27 28 # Upstream recommends a non-default level 29 # https://github.com/ghostty-org/ghostty/blob/4b4d4062dfed7b37424c7210d1230242c709e990/PACKAGING.md#build-options 30 optimizeLevel ? "ReleaseFast", 31}: 32 33stdenv.mkDerivation (finalAttrs: { 34 pname = "ghostty"; 35 version = "1.2.3"; 36 37 outputs = [ 38 "out" 39 "man" 40 "shell_integration" 41 "terminfo" 42 "vim" 43 ]; 44 45 src = fetchFromGitHub { 46 owner = "ghostty-org"; 47 repo = "ghostty"; 48 tag = "v${finalAttrs.version}"; 49 hash = "sha256-0tmLOJCrrEnVc/ZCp/e646DTddXjv249QcSwkaukL30="; 50 }; 51 52 # Replace the defunct iTerm2 themes dependency with a newer version 53 # Remove when 1.2.4 or 1.3.0 is released 54 patches = [ 55 (fetchpatch2 { 56 name = "fix-iterm2-themes-ref.patch"; 57 url = "https://github.com/pluiedev/ghostty/commit/dc51adc52661bbcacebe5e70b62b5041e3ee56a5.patch"; 58 hash = "sha256-0DrP4zN26pjeBawoi9U8y6VM/NlfhPmo27Iy5OsMj0s="; 59 }) 60 ]; 61 62 deps = callPackage ./deps.nix { 63 name = "${finalAttrs.pname}-cache-${finalAttrs.version}"; 64 }; 65 66 strictDeps = true; 67 68 nativeBuildInputs = [ 69 ncurses 70 pandoc 71 pkg-config 72 removeReferencesTo 73 zig_0_14 74 75 # GTK frontend 76 glib # Required for `glib-compile-schemas` 77 wrapGAppsHook4 78 blueprint-compiler 79 ]; 80 81 buildInputs = [ 82 oniguruma 83 84 # GTK frontend 85 libadwaita 86 libX11 87 gtk4-layer-shell 88 89 # OpenGL renderer 90 glslang 91 libGL 92 93 # Font backend 94 bzip2 95 fontconfig 96 freetype 97 harfbuzz 98 ]; 99 100 dontSetZigDefaultFlags = true; 101 102 zigBuildFlags = [ 103 "--system" 104 "${finalAttrs.deps}" 105 "-Dversion-string=${finalAttrs.version}" 106 "-Dcpu=baseline" 107 "-Doptimize=${optimizeLevel}" 108 ] 109 ++ lib.mapAttrsToList (name: package: "-fsys=${name} --search-prefix ${lib.getLib package}") { 110 inherit glslang; 111 }; 112 113 zigCheckFlags = finalAttrs.zigBuildFlags; 114 115 doCheck = true; 116 117 /** 118 Ghostty really likes all of it's resources to be in the same directory, so link them back after we split them 119 120 - https://github.com/ghostty-org/ghostty/blob/4b4d4062dfed7b37424c7210d1230242c709e990/src/os/resourcesdir.zig#L11-L52 121 - https://github.com/ghostty-org/ghostty/blob/4b4d4062dfed7b37424c7210d1230242c709e990/src/termio/Exec.zig#L745-L750 122 - https://github.com/ghostty-org/ghostty/blob/4b4d4062dfed7b37424c7210d1230242c709e990/src/termio/Exec.zig#L818-L834 123 124 terminfo and shell integration should also be installable on remote machines 125 126 ```nix 127 { pkgs, ... }: { 128 environment.systemPackages = [ pkgs.ghostty.terminfo ]; 129 130 programs.bash = { 131 interactiveShellInit = '' 132 if [[ "$TERM" == "xterm-ghostty" ]]; then 133 builtin source ${pkgs.ghostty.shell_integration}/bash/ghostty.bash 134 fi 135 ''; 136 }; 137 } 138 ``` 139 */ 140 postFixup = '' 141 ln -s $man/share/man $out/share/man 142 143 moveToOutput share/terminfo $terminfo 144 ln -s $terminfo/share/terminfo $out/share/terminfo 145 146 mv $out/share/ghostty/shell-integration $shell_integration 147 ln -s $shell_integration $out/share/ghostty/shell-integration 148 149 mv $out/share/vim/vimfiles $vim 150 rmdir $out/share/vim 151 ln -s $vim $out/share/vim-plugins 152 153 remove-references-to -t ${finalAttrs.deps} $out/bin/.ghostty-wrapped 154 ''; 155 156 nativeInstallCheckInputs = [ 157 versionCheckHook 158 ]; 159 160 doInstallCheck = true; 161 162 passthru = { 163 tests = lib.optionalAttrs stdenv.hostPlatform.isLinux { 164 inherit (nixosTests) allTerminfo; 165 nixos = nixosTests.terminal-emulators.ghostty; 166 }; 167 updateScript = ./update.nu; 168 }; 169 170 meta = { 171 description = "Fast, native, feature-rich terminal emulator pushing modern features"; 172 longDescription = '' 173 Ghostty is a terminal emulator that differentiates itself by being 174 fast, feature-rich, and native. While there are many excellent terminal 175 emulators available, they all force you to choose between speed, 176 features, or native UIs. Ghostty provides all three. 177 ''; 178 homepage = "https://ghostty.org/"; 179 downloadPage = "https://ghostty.org/download"; 180 changelog = "https://ghostty.org/docs/install/release-notes/${ 181 builtins.replaceStrings [ "." ] [ "-" ] finalAttrs.version 182 }"; 183 license = lib.licenses.mit; 184 mainProgram = "ghostty"; 185 maintainers = with lib.maintainers; [ 186 jcollie 187 pluiedev 188 getchoo 189 ]; 190 outputsToInstall = [ 191 "out" 192 ]; 193 platforms = lib.platforms.linux; 194 }; 195})