Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 328 lines 7.9 kB view raw
1{ 2 lib, 3 stdenv, 4 fetchFromGitHub, 5 python3Packages, 6 libunistring, 7 harfbuzz, 8 fontconfig, 9 pkg-config, 10 ncurses, 11 imagemagick, 12 libstartup_notification, 13 libGL, 14 libX11, 15 libXrandr, 16 libXinerama, 17 libXcursor, 18 libxkbcommon, 19 libXi, 20 libXext, 21 wayland-protocols, 22 wayland, 23 xxHash, 24 nerd-fonts, 25 lcms2, 26 librsync, 27 openssl, 28 installShellFiles, 29 dbus, 30 sudo, 31 libcanberra, 32 libicns, 33 wayland-scanner, 34 libpng, 35 python3, 36 zlib, 37 simde, 38 bashInteractive, 39 zsh, 40 fish, 41 nixosTests, 42 go_1_24, 43 buildGo124Module, 44 nix-update-script, 45 makeBinaryWrapper, 46 autoSignDarwinBinariesHook, 47 cairo, 48}: 49 50with python3Packages; 51buildPythonApplication rec { 52 pname = "kitty"; 53 version = "0.42.2"; 54 format = "other"; 55 56 src = fetchFromGitHub { 57 owner = "kovidgoyal"; 58 repo = "kitty"; 59 tag = "v${version}"; 60 hash = "sha256-YDfKYzj5LRx1XaKUpBKo97CMW4jPhVQq0aXx/Qfcdzo="; 61 }; 62 63 goModules = 64 (buildGo124Module { 65 pname = "kitty-go-modules"; 66 inherit src version; 67 vendorHash = "sha256-q5LMyogAqgUFfln7LVkhuXzYSMuYmOif5sj15KkOjB4="; 68 }).goModules; 69 70 buildInputs = [ 71 harfbuzz 72 ncurses 73 simde 74 lcms2 75 librsync 76 matplotlib 77 openssl.dev 78 xxHash 79 ] 80 ++ lib.optionals stdenv.hostPlatform.isDarwin [ 81 libpng 82 python3 83 zlib 84 ] 85 ++ lib.optionals stdenv.hostPlatform.isLinux [ 86 fontconfig 87 libunistring 88 libcanberra 89 libX11 90 libXrandr 91 libXinerama 92 libXcursor 93 libxkbcommon 94 libXi 95 libXext 96 wayland-protocols 97 wayland 98 dbus 99 libGL 100 cairo 101 ]; 102 103 nativeBuildInputs = [ 104 installShellFiles 105 ncurses 106 pkg-config 107 sphinx 108 furo 109 sphinx-copybutton 110 sphinxext-opengraph 111 sphinx-inline-tabs 112 go_1_24 113 fontconfig 114 makeBinaryWrapper 115 ] 116 ++ lib.optionals stdenv.hostPlatform.isDarwin [ 117 imagemagick 118 libicns # For the png2icns tool. 119 autoSignDarwinBinariesHook 120 ] 121 ++ lib.optionals stdenv.hostPlatform.isLinux [ 122 wayland-scanner 123 ]; 124 125 depsBuildBuild = [ pkg-config ]; 126 127 outputs = [ 128 "out" 129 "terminfo" 130 "shell_integration" 131 "kitten" 132 ]; 133 134 patches = [ 135 # Needed on darwin 136 137 # Gets `test_ssh_shell_integration` to pass for `zsh` when `compinit` complains about 138 # permissions. 139 ./zsh-compinit.patch 140 141 # Skip `test_ssh_bootstrap_with_different_launchers` when launcher is `zsh` since it causes: 142 # OSError: master_fd is in error condition 143 ./disable-test_ssh_bootstrap_with_different_launchers.patch 144 145 ]; 146 147 hardeningDisable = [ 148 # causes redefinition of _FORTIFY_SOURCE 149 "fortify3" 150 ]; 151 152 env.CGO_ENABLED = 0; 153 GOFLAGS = "-trimpath"; 154 155 configurePhase = '' 156 export GOCACHE=$TMPDIR/go-cache 157 export GOPATH="$TMPDIR/go" 158 export GOPROXY=off 159 cp -r --reflink=auto $goModules vendor 160 ''; 161 162 buildPhase = 163 let 164 commonOptions = '' 165 --update-check-interval=0 \ 166 --shell-integration=enabled\ no-rc 167 ''; 168 darwinOptions = '' 169 --disable-link-time-optimization \ 170 ${commonOptions} 171 ''; 172 in 173 '' 174 runHook preBuild 175 176 # Add the font by hand because fontconfig does not finds it in darwin 177 mkdir ./fonts/ 178 cp "${nerd-fonts.symbols-only}/share/fonts/truetype/NerdFonts/Symbols/SymbolsNerdFontMono-Regular.ttf" ./fonts/ 179 180 ${ 181 if stdenv.hostPlatform.isDarwin then 182 '' 183 ${python.pythonOnBuildForHost.interpreter} setup.py build ${darwinOptions} 184 make docs 185 ${python.pythonOnBuildForHost.interpreter} setup.py kitty.app ${darwinOptions} 186 '' 187 else 188 '' 189 ${python.pythonOnBuildForHost.interpreter} setup.py linux-package \ 190 --egl-library='${lib.getLib libGL}/lib/libEGL.so.1' \ 191 --startup-notification-library='${libstartup_notification}/lib/libstartup-notification-1.so' \ 192 --canberra-library='${libcanberra}/lib/libcanberra.so' \ 193 --fontconfig-library='${fontconfig.lib}/lib/libfontconfig.so' \ 194 ${commonOptions} 195 ${python.pythonOnBuildForHost.interpreter} setup.py build-launcher 196 '' 197 } 198 runHook postBuild 199 ''; 200 201 nativeCheckInputs = [ 202 pillow 203 204 # Shells needed for shell integration tests 205 bashInteractive 206 zsh 207 fish 208 ] 209 ++ lib.optionals (!stdenv.hostPlatform.isDarwin) [ 210 # integration tests need sudo 211 sudo 212 ]; 213 214 # skip failing tests due to darwin sandbox 215 preCheck = lib.optionalString stdenv.hostPlatform.isDarwin '' 216 217 substituteInPlace kitty_tests/file_transmission.py \ 218 --replace test_transfer_send dont_test_transfer_send 219 220 substituteInPlace kitty_tests/ssh.py \ 221 --replace test_ssh_connection_data no_test_ssh_connection_data \ 222 223 substituteInPlace kitty_tests/shell_integration.py \ 224 --replace test_fish_integration no_test_fish_integration 225 226 substituteInPlace kitty_tests/fonts.py \ 227 --replace test_fallback_font_not_last_resort no_test_fallback_font_not_last_resort 228 229 # theme collection test starts an http server 230 rm tools/themes/collection_test.go 231 # passwd_test tries to exec /usr/bin/dscl 232 rm tools/utils/passwd_test.go 233 ''; 234 235 checkPhase = '' 236 runHook preCheck 237 238 # Fontconfig error: Cannot load default config file: No such file: (null) 239 export FONTCONFIG_FILE=${fontconfig.out}/etc/fonts/fonts.conf 240 241 # Required for `test_ssh_shell_integration` to pass. 242 export TERM=kitty 243 244 make test 245 runHook postCheck 246 ''; 247 248 installPhase = '' 249 runHook preInstall 250 mkdir -p "$out" 251 mkdir -p "$kitten/bin" 252 ${ 253 if stdenv.hostPlatform.isDarwin then 254 '' 255 mkdir "$out/bin" 256 ln -s ../Applications/kitty.app/Contents/MacOS/kitty "$out/bin/kitty" 257 ln -s ../Applications/kitty.app/Contents/MacOS/kitten "$out/bin/kitten" 258 cp ./kitty.app/Contents/MacOS/kitten "$kitten/bin/kitten" 259 mkdir "$out/Applications" 260 cp -r kitty.app "$out/Applications/kitty.app" 261 262 installManPage 'docs/_build/man/kitty.1' 263 '' 264 else 265 '' 266 cp -r linux-package/{bin,share,lib} "$out" 267 cp linux-package/bin/kitten "$kitten/bin/kitten" 268 '' 269 } 270 271 # dereference the `kitty` symlink to make sure the actual executable 272 # is wrapped on macOS as well (and not just the symlink) 273 wrapProgram $(realpath "$out/bin/kitty") --suffix PATH : "$out/bin:${ 274 lib.makeBinPath [ 275 imagemagick 276 ncurses.dev 277 ] 278 }" 279 280 installShellCompletion --cmd kitty \ 281 --bash <("$out/bin/kitty" +complete setup bash) \ 282 --fish <("$out/bin/kitty" +complete setup fish2) \ 283 --zsh <("$out/bin/kitty" +complete setup zsh) 284 285 terminfo_src=${ 286 if stdenv.hostPlatform.isDarwin then 287 ''"$out/Applications/kitty.app/Contents/Resources/terminfo"'' 288 else 289 "$out/share/terminfo" 290 } 291 292 mkdir -p $terminfo/share 293 mv "$terminfo_src" $terminfo/share/terminfo 294 295 mkdir -p "$out/nix-support" 296 echo "$terminfo" >> $out/nix-support/propagated-user-env-packages 297 298 cp -r 'shell-integration' "$shell_integration" 299 300 runHook postInstall 301 ''; 302 303 passthru = { 304 tests = lib.optionalAttrs stdenv.hostPlatform.isLinux { 305 default = nixosTests.terminal-emulators.kitty; 306 }; 307 updateScript = nix-update-script { }; 308 }; 309 310 meta = with lib; { 311 homepage = "https://github.com/kovidgoyal/kitty"; 312 description = "Fast, feature-rich, GPU based terminal emulator"; 313 license = licenses.gpl3Only; 314 changelog = [ 315 "https://sw.kovidgoyal.net/kitty/changelog/" 316 "https://github.com/kovidgoyal/kitty/blob/v${version}/docs/changelog.rst" 317 ]; 318 platforms = platforms.darwin ++ platforms.linux; 319 mainProgram = "kitty"; 320 maintainers = with maintainers; [ 321 tex 322 rvolosatovs 323 Luflosi 324 kashw2 325 leiserfg 326 ]; 327 }; 328}