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
29 buildPythonApplication rec {
34 src = fetchFromGitHub {
38 sha256 = "sha256-IqXRkKzOfqWolH/534nmM2R/69olhFOk6wbbF4ifRd0=";
47 ] ++ lib.optionals stdenv.isDarwin [
57 ] ++ lib.optionals (stdenv.isDarwin && (builtins.hasAttr "UserNotifications" darwin.apple_sdk.frameworks)) [
58 darwin.apple_sdk.frameworks.UserNotifications
59 ] ++ lib.optionals stdenv.isLinux [
60 fontconfig libunistring libcanberra libX11
61 libXrandr libXinerama libXcursor libxkbcommon libXi libXext
62 wayland-protocols wayland dbus libGL
74 ] ++ lib.optionals stdenv.isDarwin [
76 libicns # For the png2icns tool.
79 outputs = [ "out" "terminfo" "shell_integration" ];
82 # Gets `test_ssh_env_vars` to pass when `bzip2` is in the output of `env`.
83 ./fix-test_ssh_env_vars.patch
87 # Gets `test_ssh_shell_integration` to pass for `zsh` when `compinit` complains about
91 # Skip `test_ssh_bootstrap_with_different_launchers` when launcher is `zsh` since it causes:
92 # OSError: master_fd is in error condition
93 ./disable-test_ssh_bootstrap_with_different_launchers.patch
96 # Causes build failure due to warning
97 hardeningDisable = lib.optional stdenv.cc.isClang "strictoverflow";
103 --update-check-interval=0 \
104 --shell-integration=enabled\ no-rc
107 --disable-link-time-optimization \
112 ${if stdenv.isDarwin then ''
113 ${python.interpreter} setup.py build ${darwinOptions}
115 ${python.interpreter} setup.py kitty.app ${darwinOptions}
117 ${python.interpreter} setup.py build-launcher
118 ${python.interpreter} setup.py linux-package \
119 --egl-library='${lib.getLib libGL}/lib/libEGL.so.1' \
120 --startup-notification-library='${libstartup_notification}/lib/libstartup-notification-1.so' \
121 --canberra-library='${libcanberra}/lib/libcanberra.so' \
122 --fontconfig-library='${fontconfig.lib}/lib/libfontconfig.so' \
131 # Shells needed for shell integration tests
137 # skip failing tests due to darwin sandbox
138 preCheck = lib.optionalString stdenv.isDarwin ''
139 substituteInPlace kitty_tests/file_transmission.py \
140 --replace test_file_get dont_test_file_get \
141 --replace test_path_mapping_receive dont_test_path_mapping_receive
142 substituteInPlace kitty_tests/shell_integration.py \
143 --replace test_fish_integration dont_test_fish_integration
144 substituteInPlace kitty_tests/open_actions.py \
145 --replace test_parsing_of_open_actions dont_test_parsing_of_open_actions
146 substituteInPlace kitty_tests/ssh.py \
147 --replace test_ssh_connection_data dont_test_ssh_connection_data
148 substituteInPlace kitty_tests/fonts.py \
149 --replace 'class Rendering(BaseTest)' 'class Rendering'
155 # Fontconfig error: Cannot load default config file: No such file: (null)
156 export FONTCONFIG_FILE=${fontconfig.out}/etc/fonts/fonts.conf
158 # Required for `test_ssh_shell_integration` to pass.
168 ${if stdenv.isDarwin then ''
170 ln -s ../Applications/kitty.app/Contents/MacOS/kitty "$out/bin/kitty"
171 mkdir "$out/Applications"
172 cp -r kitty.app "$out/Applications/kitty.app"
174 installManPage 'docs/_build/man/kitty.1'
176 cp -r linux-package/{bin,share,lib} $out
178 wrapProgram "$out/bin/kitty" --prefix PATH : "$out/bin:${lib.makeBinPath [ imagemagick ncurses.dev ]}"
180 installShellCompletion --cmd kitty \
181 --bash <("$out/bin/kitty" +complete setup bash) \
182 --fish <("$out/bin/kitty" +complete setup fish2) \
183 --zsh <("$out/bin/kitty" +complete setup zsh)
185 terminfo_src=${if stdenv.isDarwin then
186 ''"$out/Applications/kitty.app/Contents/Resources/terminfo"''
188 "$out/share/terminfo"}
190 mkdir -p $terminfo/share
191 mv "$terminfo_src" $terminfo/share/terminfo
193 mkdir -p $out/nix-support
194 echo "$terminfo" >> $out/nix-support/propagated-user-env-packages
196 cp -r 'shell-integration' "$shell_integration"
201 # Patch shebangs that Nix can't automatically patch
204 pathComponent = if stdenv.isDarwin then "Applications/kitty.app/Contents/Resources" else "lib";
207 substituteInPlace $out/${pathComponent}/kitty/shell-integration/ssh/askpass.py \
208 --replace '/usr/bin/env -S ' $out/bin/
209 substituteInPlace $shell_integration/ssh/askpass.py \
210 --replace '/usr/bin/env -S ' $out/bin/
213 passthru.tests.test = nixosTests.terminal-emulators.kitty;
216 homepage = "https://github.com/kovidgoyal/kitty";
217 description = "A modern, hackable, featureful, OpenGL based terminal emulator";
218 license = licenses.gpl3Only;
219 changelog = "https://sw.kovidgoyal.net/kitty/changelog/";
220 platforms = platforms.darwin ++ platforms.linux;
221 maintainers = with maintainers; [ tex rvolosatovs Luflosi ];