2022-03-10 19:12:11 +00:00
|
|
|
{ lib, stdenv, fetchFromGitHub, python3Packages, libunistring
|
2022-06-16 17:23:12 +00:00
|
|
|
, harfbuzz, fontconfig, pkg-config, ncurses, imagemagick
|
2022-03-10 19:12:11 +00:00
|
|
|
, libstartup_notification, libGL, libX11, libXrandr, libXinerama, libXcursor
|
|
|
|
, libxkbcommon, libXi, libXext, wayland-protocols, wayland
|
|
|
|
, lcms2
|
|
|
|
, librsync
|
2022-10-06 18:32:54 +00:00
|
|
|
, openssl
|
2022-03-10 19:12:11 +00:00
|
|
|
, installShellFiles
|
|
|
|
, dbus
|
|
|
|
, Cocoa
|
|
|
|
, CoreGraphics
|
|
|
|
, Foundation
|
|
|
|
, IOKit
|
|
|
|
, Kernel
|
2023-01-11 07:51:40 +00:00
|
|
|
, UniformTypeIdentifiers
|
|
|
|
, UserNotifications
|
2022-03-10 19:12:11 +00:00
|
|
|
, OpenGL
|
|
|
|
, libcanberra
|
|
|
|
, libicns
|
|
|
|
, libpng
|
|
|
|
, python3
|
|
|
|
, zlib
|
|
|
|
, bashInteractive
|
|
|
|
, zsh
|
|
|
|
, fish
|
2022-03-30 09:31:56 +00:00
|
|
|
, nixosTests
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
with python3Packages;
|
|
|
|
buildPythonApplication rec {
|
|
|
|
pname = "kitty";
|
2023-01-11 07:51:40 +00:00
|
|
|
version = "0.26.5";
|
2020-04-24 23:36:52 +00:00
|
|
|
format = "other";
|
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "kovidgoyal";
|
|
|
|
repo = "kitty";
|
2023-01-11 07:51:40 +00:00
|
|
|
rev = "refs/tags/v${version}";
|
|
|
|
sha256 = "sha256-UloBlV26HnkvbzP/NynlPI77z09MBEVgtrg5SeTmwB4=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
buildInputs = [
|
|
|
|
harfbuzz
|
|
|
|
ncurses
|
2020-10-07 09:15:18 +00:00
|
|
|
lcms2
|
2022-01-19 23:45:15 +00:00
|
|
|
librsync
|
2022-10-06 18:32:54 +00:00
|
|
|
openssl.dev
|
2021-01-17 00:15:33 +00:00
|
|
|
] ++ lib.optionals stdenv.isDarwin [
|
2020-04-24 23:36:52 +00:00
|
|
|
Cocoa
|
|
|
|
CoreGraphics
|
|
|
|
Foundation
|
|
|
|
IOKit
|
|
|
|
Kernel
|
|
|
|
OpenGL
|
2023-01-11 07:51:40 +00:00
|
|
|
UniformTypeIdentifiers
|
|
|
|
UserNotifications
|
2020-04-24 23:36:52 +00:00
|
|
|
libpng
|
|
|
|
python3
|
|
|
|
zlib
|
2021-01-17 00:15:33 +00:00
|
|
|
] ++ lib.optionals stdenv.isLinux [
|
2020-04-24 23:36:52 +00:00
|
|
|
fontconfig libunistring libcanberra libX11
|
|
|
|
libXrandr libXinerama libXcursor libxkbcommon libXi libXext
|
2022-05-18 14:49:53 +00:00
|
|
|
wayland-protocols wayland dbus libGL
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
2020-11-15 13:44:38 +00:00
|
|
|
installShellFiles
|
2021-08-22 07:53:02 +00:00
|
|
|
ncurses
|
|
|
|
pkg-config
|
|
|
|
sphinx
|
|
|
|
furo
|
|
|
|
sphinx-copybutton
|
|
|
|
sphinxext-opengraph
|
|
|
|
sphinx-inline-tabs
|
2021-01-17 00:15:33 +00:00
|
|
|
] ++ lib.optionals stdenv.isDarwin [
|
2020-04-24 23:36:52 +00:00
|
|
|
imagemagick
|
|
|
|
libicns # For the png2icns tool.
|
|
|
|
];
|
|
|
|
|
2022-01-19 23:45:15 +00:00
|
|
|
outputs = [ "out" "terminfo" "shell_integration" ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-03-10 19:12:11 +00:00
|
|
|
patches = [
|
2022-10-06 18:32:54 +00:00
|
|
|
# Gets `test_ssh_env_vars` to pass when `bzip2` is in the output of `env`.
|
|
|
|
./fix-test_ssh_env_vars.patch
|
|
|
|
|
2022-06-16 17:23:12 +00:00
|
|
|
# Needed on darwin
|
|
|
|
|
|
|
|
# Gets `test_ssh_shell_integration` to pass for `zsh` when `compinit` complains about
|
|
|
|
# permissions.
|
|
|
|
./zsh-compinit.patch
|
|
|
|
|
|
|
|
# Skip `test_ssh_bootstrap_with_different_launchers` when launcher is `zsh` since it causes:
|
|
|
|
# OSError: master_fd is in error condition
|
|
|
|
./disable-test_ssh_bootstrap_with_different_launchers.patch
|
2022-03-10 19:12:11 +00:00
|
|
|
];
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
# Causes build failure due to warning
|
2021-01-17 00:15:33 +00:00
|
|
|
hardeningDisable = lib.optional stdenv.cc.isClang "strictoverflow";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2020-06-15 15:56:04 +00:00
|
|
|
dontConfigure = true;
|
|
|
|
|
2022-01-19 23:45:15 +00:00
|
|
|
buildPhase = let
|
|
|
|
commonOptions = ''
|
|
|
|
--update-check-interval=0 \
|
|
|
|
--shell-integration=enabled\ no-rc
|
|
|
|
'';
|
2022-10-06 18:32:54 +00:00
|
|
|
darwinOptions = ''
|
|
|
|
--disable-link-time-optimization \
|
|
|
|
${commonOptions}
|
|
|
|
'';
|
2022-01-19 23:45:15 +00:00
|
|
|
in ''
|
2021-06-28 23:13:55 +00:00
|
|
|
runHook preBuild
|
|
|
|
${if stdenv.isDarwin then ''
|
2022-10-06 18:32:54 +00:00
|
|
|
${python.interpreter} setup.py build ${darwinOptions}
|
|
|
|
make docs
|
|
|
|
${python.interpreter} setup.py kitty.app ${darwinOptions}
|
2021-06-28 23:13:55 +00:00
|
|
|
'' else ''
|
2022-10-06 18:32:54 +00:00
|
|
|
${python.interpreter} setup.py build-launcher
|
2021-06-28 23:13:55 +00:00
|
|
|
${python.interpreter} setup.py linux-package \
|
|
|
|
--egl-library='${lib.getLib libGL}/lib/libEGL.so.1' \
|
|
|
|
--startup-notification-library='${libstartup_notification}/lib/libstartup-notification-1.so' \
|
2022-01-19 23:45:15 +00:00
|
|
|
--canberra-library='${libcanberra}/lib/libcanberra.so' \
|
2022-06-16 17:23:12 +00:00
|
|
|
--fontconfig-library='${fontconfig.lib}/lib/libfontconfig.so' \
|
2022-01-19 23:45:15 +00:00
|
|
|
${commonOptions}
|
2021-06-28 23:13:55 +00:00
|
|
|
''}
|
|
|
|
runHook postBuild
|
2020-06-15 15:56:04 +00:00
|
|
|
'';
|
|
|
|
|
2022-03-10 19:12:11 +00:00
|
|
|
checkInputs = [
|
|
|
|
pillow
|
|
|
|
|
|
|
|
# Shells needed for shell integration tests
|
|
|
|
bashInteractive
|
|
|
|
zsh
|
|
|
|
fish
|
|
|
|
];
|
2020-06-15 15:56:04 +00:00
|
|
|
|
2022-08-12 12:06:08 +00:00
|
|
|
# skip failing tests due to darwin sandbox
|
2022-10-06 18:32:54 +00:00
|
|
|
preCheck = lib.optionalString stdenv.isDarwin ''
|
2022-08-12 12:06:08 +00:00
|
|
|
substituteInPlace kitty_tests/file_transmission.py \
|
|
|
|
--replace test_file_get dont_test_file_get \
|
|
|
|
--replace test_path_mapping_receive dont_test_path_mapping_receive
|
|
|
|
substituteInPlace kitty_tests/shell_integration.py \
|
|
|
|
--replace test_fish_integration dont_test_fish_integration
|
|
|
|
substituteInPlace kitty_tests/open_actions.py \
|
|
|
|
--replace test_parsing_of_open_actions dont_test_parsing_of_open_actions
|
|
|
|
substituteInPlace kitty_tests/ssh.py \
|
|
|
|
--replace test_ssh_connection_data dont_test_ssh_connection_data
|
|
|
|
substituteInPlace kitty_tests/fonts.py \
|
|
|
|
--replace 'class Rendering(BaseTest)' 'class Rendering'
|
2022-10-06 18:32:54 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
checkPhase = ''
|
2022-08-12 12:06:08 +00:00
|
|
|
runHook preCheck
|
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
# Fontconfig error: Cannot load default config file: No such file: (null)
|
|
|
|
export FONTCONFIG_FILE=${fontconfig.out}/etc/fonts/fonts.conf
|
|
|
|
|
2022-06-16 17:23:12 +00:00
|
|
|
# Required for `test_ssh_shell_integration` to pass.
|
|
|
|
export TERM=kitty
|
|
|
|
|
2022-10-06 18:32:54 +00:00
|
|
|
make test
|
|
|
|
runHook postCheck
|
2020-08-20 17:08:02 +00:00
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
|
|
|
mkdir -p $out
|
|
|
|
${if stdenv.isDarwin then ''
|
|
|
|
mkdir "$out/bin"
|
|
|
|
ln -s ../Applications/kitty.app/Contents/MacOS/kitty "$out/bin/kitty"
|
|
|
|
mkdir "$out/Applications"
|
|
|
|
cp -r kitty.app "$out/Applications/kitty.app"
|
|
|
|
|
|
|
|
installManPage 'docs/_build/man/kitty.1'
|
|
|
|
'' else ''
|
|
|
|
cp -r linux-package/{bin,share,lib} $out
|
|
|
|
''}
|
2022-06-16 17:23:12 +00:00
|
|
|
wrapProgram "$out/bin/kitty" --prefix PATH : "$out/bin:${lib.makeBinPath [ imagemagick ncurses.dev ]}"
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2020-11-15 13:44:38 +00:00
|
|
|
installShellCompletion --cmd kitty \
|
2022-03-10 19:12:11 +00:00
|
|
|
--bash <("$out/bin/kitty" +complete setup bash) \
|
|
|
|
--fish <("$out/bin/kitty" +complete setup fish2) \
|
|
|
|
--zsh <("$out/bin/kitty" +complete setup zsh)
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
terminfo_src=${if stdenv.isDarwin then
|
|
|
|
''"$out/Applications/kitty.app/Contents/Resources/terminfo"''
|
|
|
|
else
|
|
|
|
"$out/share/terminfo"}
|
|
|
|
|
|
|
|
mkdir -p $terminfo/share
|
|
|
|
mv "$terminfo_src" $terminfo/share/terminfo
|
|
|
|
|
|
|
|
mkdir -p $out/nix-support
|
|
|
|
echo "$terminfo" >> $out/nix-support/propagated-user-env-packages
|
2022-01-19 23:45:15 +00:00
|
|
|
|
|
|
|
cp -r 'shell-integration' "$shell_integration"
|
|
|
|
|
|
|
|
runHook postInstall
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2022-06-16 17:23:12 +00:00
|
|
|
# Patch shebangs that Nix can't automatically patch
|
|
|
|
preFixup =
|
|
|
|
let
|
|
|
|
pathComponent = if stdenv.isDarwin then "Applications/kitty.app/Contents/Resources" else "lib";
|
|
|
|
in
|
|
|
|
''
|
|
|
|
substituteInPlace $out/${pathComponent}/kitty/shell-integration/ssh/askpass.py \
|
|
|
|
--replace '/usr/bin/env -S ' $out/bin/
|
|
|
|
substituteInPlace $shell_integration/ssh/askpass.py \
|
|
|
|
--replace '/usr/bin/env -S ' $out/bin/
|
|
|
|
'';
|
|
|
|
|
2022-03-30 09:31:56 +00:00
|
|
|
passthru.tests.test = nixosTests.terminal-emulators.kitty;
|
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
homepage = "https://github.com/kovidgoyal/kitty";
|
|
|
|
description = "A modern, hackable, featureful, OpenGL based terminal emulator";
|
2021-05-03 20:48:10 +00:00
|
|
|
license = licenses.gpl3Only;
|
2021-08-22 07:53:02 +00:00
|
|
|
changelog = "https://sw.kovidgoyal.net/kitty/changelog/";
|
2020-04-24 23:36:52 +00:00
|
|
|
platforms = platforms.darwin ++ platforms.linux;
|
2023-01-11 07:51:40 +00:00
|
|
|
broken = (stdenv.isDarwin && stdenv.isx86_64);
|
|
|
|
maintainers = with maintainers; [ tex rvolosatovs Luflosi adamcstephens ];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|