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
14 , UniformTypeIdentifiers
31 buildPythonApplication rec {
36 src = fetchFromGitHub {
39 rev = "refs/tags/v${version}";
40 hash = "sha256-VWWuC4T0pyTgqPNm0gNL1j3FShU5b8S157C1dKLon1g=";
43 goModules = (buildGoModule {
44 pname = "kitty-go-modules";
46 vendorHash = "sha256-OyZAWefSIiLQO0icxMIHWH3BKgNas8HIxLcse/qWKcU=";
56 ] ++ lib.optionals stdenv.isDarwin [
59 UniformTypeIdentifiers
64 ] ++ lib.optionals (stdenv.isDarwin && stdenv.isx86_64) [
66 ] ++ lib.optionals stdenv.isLinux [
67 fontconfig libunistring libcanberra libX11
68 libXrandr libXinerama libXcursor libxkbcommon libXi libXext
69 wayland-protocols wayland dbus libGL
82 ] ++ lib.optionals stdenv.isDarwin [
84 libicns # For the png2icns tool.
87 outputs = [ "out" "terminfo" "shell_integration" "kitten" ];
90 # Gets `test_ssh_env_vars` to pass when `bzip2` is in the output of `env`.
91 ./fix-test_ssh_env_vars.patch
95 # Gets `test_ssh_shell_integration` to pass for `zsh` when `compinit` complains about
99 # Skip `test_ssh_bootstrap_with_different_launchers` when launcher is `zsh` since it causes:
100 # OSError: master_fd is in error condition
101 ./disable-test_ssh_bootstrap_with_different_launchers.patch
105 # causes redefinition of _FORTIFY_SOURCE
110 GOFLAGS = "-trimpath";
113 export GOCACHE=$TMPDIR/go-cache
114 export GOPATH="$TMPDIR/go"
116 cp -r --reflink=auto $goModules vendor
121 --update-check-interval=0 \
122 --shell-integration=enabled\ no-rc
125 --disable-link-time-optimization \
130 ${ lib.optionalString (stdenv.isDarwin && stdenv.isx86_64) "export MACOSX_DEPLOYMENT_TARGET=11" }
131 ${if stdenv.isDarwin then ''
132 ${python.pythonOnBuildForHost.interpreter} setup.py build ${darwinOptions}
134 ${python.pythonOnBuildForHost.interpreter} setup.py kitty.app ${darwinOptions}
136 ${python.pythonOnBuildForHost.interpreter} setup.py linux-package \
137 --egl-library='${lib.getLib libGL}/lib/libEGL.so.1' \
138 --startup-notification-library='${libstartup_notification}/lib/libstartup-notification-1.so' \
139 --canberra-library='${libcanberra}/lib/libcanberra.so' \
140 --fontconfig-library='${fontconfig.lib}/lib/libfontconfig.so' \
142 ${python.pythonOnBuildForHost.interpreter} setup.py build-launcher
147 nativeCheckInputs = [
150 # Shells needed for shell integration tests
154 ] ++ lib.optionals (!stdenv.isDarwin) [
155 # integration tests need sudo
159 # skip failing tests due to darwin sandbox
160 preCheck = lib.optionalString stdenv.isDarwin ''
161 substituteInPlace kitty_tests/file_transmission.py \
162 --replace test_file_get dont_test_file_get \
163 --replace test_path_mapping_receive dont_test_path_mapping_receive \
164 --replace test_transfer_send dont_test_transfer_send
165 substituteInPlace kitty_tests/shell_integration.py \
166 --replace test_fish_integration dont_test_fish_integration
167 substituteInPlace kitty_tests/shell_integration.py \
168 --replace test_bash_integration dont_test_bash_integration
169 substituteInPlace kitty_tests/open_actions.py \
170 --replace test_parsing_of_open_actions dont_test_parsing_of_open_actions
171 substituteInPlace kitty_tests/ssh.py \
172 --replace test_ssh_connection_data dont_test_ssh_connection_data
173 substituteInPlace kitty_tests/fonts.py \
174 --replace 'class Rendering(BaseTest)' 'class Rendering'
175 # theme collection test starts an http server
176 rm tools/themes/collection_test.go
177 # passwd_test tries to exec /usr/bin/dscl
178 rm tools/utils/passwd_test.go
184 # Fontconfig error: Cannot load default config file: No such file: (null)
185 export FONTCONFIG_FILE=${fontconfig.out}/etc/fonts/fonts.conf
187 # Required for `test_ssh_shell_integration` to pass.
197 mkdir -p "$kitten/bin"
198 ${if stdenv.isDarwin then ''
200 ln -s ../Applications/kitty.app/Contents/MacOS/kitty "$out/bin/kitty"
201 ln -s ../Applications/kitty.app/Contents/MacOS/kitten "$out/bin/kitten"
202 cp ./kitty.app/Contents/MacOS/kitten "$kitten/bin/kitten"
203 mkdir "$out/Applications"
204 cp -r kitty.app "$out/Applications/kitty.app"
206 installManPage 'docs/_build/man/kitty.1'
208 cp -r linux-package/{bin,share,lib} "$out"
209 cp linux-package/bin/kitten "$kitten/bin/kitten"
211 wrapProgram "$out/bin/kitty" --prefix PATH : "$out/bin:${lib.makeBinPath [ imagemagick ncurses.dev ]}"
213 installShellCompletion --cmd kitty \
214 --bash <("$out/bin/kitty" +complete setup bash) \
215 --fish <("$out/bin/kitty" +complete setup fish2) \
216 --zsh <("$out/bin/kitty" +complete setup zsh)
218 terminfo_src=${if stdenv.isDarwin then
219 ''"$out/Applications/kitty.app/Contents/Resources/terminfo"''
221 "$out/share/terminfo"}
223 mkdir -p $terminfo/share
224 mv "$terminfo_src" $terminfo/share/terminfo
226 mkdir -p "$out/nix-support"
227 echo "$terminfo" >> $out/nix-support/propagated-user-env-packages
229 cp -r 'shell-integration' "$shell_integration"
235 tests.test = nixosTests.terminal-emulators.kitty;
236 updateScript = nix-update-script {};
240 homepage = "https://github.com/kovidgoyal/kitty";
241 description = "A modern, hackable, featureful, OpenGL based terminal emulator";
242 license = licenses.gpl3Only;
243 changelog = "https://sw.kovidgoyal.net/kitty/changelog/";
244 platforms = platforms.darwin ++ platforms.linux;
245 mainProgram = "kitty";
246 maintainers = with maintainers; [ tex rvolosatovs Luflosi adamcstephens kashw2 ];