1 { lib, stdenv, fetchFromGitHub, python3Packages, libunistring
2 , harfbuzz, fontconfig, pkg-config, ncurses, imagemagick
3 , libstartup_notification, libGL, libX11, libXrandr, libXinerama, libXcursor
4 , libxkbcommon, libXi, libXext, wayland-protocols, wayland, xxHash
15 , UniformTypeIdentifiers
32 , autoSignDarwinBinariesHook
36 buildPythonApplication rec {
41 src = fetchFromGitHub {
44 rev = "refs/tags/v${version}";
45 hash = "sha256-xxM5nqEr7avtJUlcsrA/KXOTxSajIg7kDQM6Q4V+6WM=";
48 goModules = (buildGo123Module {
49 pname = "kitty-go-modules";
51 vendorHash = "sha256-d5jRhOm53HDGnsU5Lg5tVGU/9z8RGqORzS53hOyIKBk=";
63 ] ++ lib.optionals stdenv.hostPlatform.isDarwin [
66 UniformTypeIdentifiers
71 ] ++ lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isx86_64) [
73 ] ++ lib.optionals stdenv.hostPlatform.isLinux [
74 fontconfig libunistring libcanberra libX11
75 libXrandr libXinerama libXcursor libxkbcommon libXi libXext
76 wayland-protocols wayland dbus libGL
91 ] ++ lib.optionals stdenv.hostPlatform.isDarwin [
93 libicns # For the png2icns tool.
94 autoSignDarwinBinariesHook
95 ] ++ lib.optionals stdenv.hostPlatform.isLinux [
99 depsBuildBuild = [ pkg-config ];
101 outputs = [ "out" "terminfo" "shell_integration" "kitten" ];
104 # Gets `test_ssh_env_vars` to pass when `bzip2` is in the output of `env`.
105 ./fix-test_ssh_env_vars.patch
109 # Gets `test_ssh_shell_integration` to pass for `zsh` when `compinit` complains about
113 # Skip `test_ssh_bootstrap_with_different_launchers` when launcher is `zsh` since it causes:
114 # OSError: master_fd is in error condition
115 ./disable-test_ssh_bootstrap_with_different_launchers.patch
119 # causes redefinition of _FORTIFY_SOURCE
124 GOFLAGS = "-trimpath";
127 export GOCACHE=$TMPDIR/go-cache
128 export GOPATH="$TMPDIR/go"
130 cp -r --reflink=auto $goModules vendor
135 --update-check-interval=0 \
136 --shell-integration=enabled\ no-rc
139 --disable-link-time-optimization \
145 # Add the font by hand because fontconfig does not finds it in darwin
147 cp "${nerd-fonts.symbols-only}/share/fonts/truetype/NerdFonts/Symbols/SymbolsNerdFontMono-Regular.ttf" ./fonts/
149 ${ lib.optionalString (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isx86_64) "export MACOSX_DEPLOYMENT_TARGET=11" }
150 ${if stdenv.hostPlatform.isDarwin then ''
151 ${python.pythonOnBuildForHost.interpreter} setup.py build ${darwinOptions}
153 ${python.pythonOnBuildForHost.interpreter} setup.py kitty.app ${darwinOptions}
155 ${python.pythonOnBuildForHost.interpreter} setup.py linux-package \
156 --egl-library='${lib.getLib libGL}/lib/libEGL.so.1' \
157 --startup-notification-library='${libstartup_notification}/lib/libstartup-notification-1.so' \
158 --canberra-library='${libcanberra}/lib/libcanberra.so' \
159 --fontconfig-library='${fontconfig.lib}/lib/libfontconfig.so' \
161 ${python.pythonOnBuildForHost.interpreter} setup.py build-launcher
166 nativeCheckInputs = [
169 # Shells needed for shell integration tests
173 ] ++ lib.optionals (!stdenv.hostPlatform.isDarwin) [
174 # integration tests need sudo
178 # skip failing tests due to darwin sandbox
179 preCheck = lib.optionalString stdenv.hostPlatform.isDarwin ''
180 # can be re-enabled with the next kitty release, see https://github.com/kovidgoyal/kitty/pull/7939
181 substituteInPlace kitty_tests/file_transmission.py \
182 --replace test_transfer_send dont_test_transfer_send
183 # theme collection test starts an http server
184 rm tools/themes/collection_test.go
185 # passwd_test tries to exec /usr/bin/dscl
186 rm tools/utils/passwd_test.go
192 # Fontconfig error: Cannot load default config file: No such file: (null)
193 export FONTCONFIG_FILE=${fontconfig.out}/etc/fonts/fonts.conf
195 # Required for `test_ssh_shell_integration` to pass.
205 mkdir -p "$kitten/bin"
206 ${if stdenv.hostPlatform.isDarwin then ''
208 ln -s ../Applications/kitty.app/Contents/MacOS/kitty "$out/bin/kitty"
209 ln -s ../Applications/kitty.app/Contents/MacOS/kitten "$out/bin/kitten"
210 cp ./kitty.app/Contents/MacOS/kitten "$kitten/bin/kitten"
211 mkdir "$out/Applications"
212 cp -r kitty.app "$out/Applications/kitty.app"
214 installManPage 'docs/_build/man/kitty.1'
216 cp -r linux-package/{bin,share,lib} "$out"
217 cp linux-package/bin/kitten "$kitten/bin/kitten"
220 # dereference the `kitty` symlink to make sure the actual executable
221 # is wrapped on macOS as well (and not just the symlink)
222 wrapProgram $(realpath "$out/bin/kitty") --prefix PATH : "$out/bin:${lib.makeBinPath [ imagemagick ncurses.dev ]}"
224 installShellCompletion --cmd kitty \
225 --bash <("$out/bin/kitty" +complete setup bash) \
226 --fish <("$out/bin/kitty" +complete setup fish2) \
227 --zsh <("$out/bin/kitty" +complete setup zsh)
229 terminfo_src=${if stdenv.hostPlatform.isDarwin then
230 ''"$out/Applications/kitty.app/Contents/Resources/terminfo"''
232 "$out/share/terminfo"}
234 mkdir -p $terminfo/share
235 mv "$terminfo_src" $terminfo/share/terminfo
237 mkdir -p "$out/nix-support"
238 echo "$terminfo" >> $out/nix-support/propagated-user-env-packages
240 cp -r 'shell-integration' "$shell_integration"
246 tests = lib.optionalAttrs stdenv.hostPlatform.isLinux {
247 default = nixosTests.terminal-emulators.kitty;
249 updateScript = nix-update-script {};
253 homepage = "https://github.com/kovidgoyal/kitty";
254 description = "Modern, hackable, featureful, OpenGL based terminal emulator";
255 license = licenses.gpl3Only;
257 "https://sw.kovidgoyal.net/kitty/changelog/"
258 "https://github.com/kovidgoyal/kitty/blob/v${version}/docs/changelog.rst"
260 platforms = platforms.darwin ++ platforms.linux;
261 mainProgram = "kitty";
262 maintainers = with maintainers; [ tex rvolosatovs Luflosi kashw2 ];