summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMalo Bourgon <mbourgon@gmail.com>2022-04-26 18:23:02 -0700
committergithub-actions[bot] <github-actions[bot]@users.noreply.github.com>2022-05-28 01:27:13 +0000
commit9f7197cff37c48fc9e83abe46f12740c68e86ea4 (patch)
treef55870b664471c452f8538ea6f552fcb658c2e44
parentostinato: fix desktop file (diff)
downloadnixpkgs-origin/backport-170545-to-release-22.05.tar.gz
(cherry picked from commit 41d4a169616531a090f8ed15bc5b754a3245f8a0)
-rw-r--r--pkgs/applications/terminal-emulators/kitty/default.nix50
-rw-r--r--pkgs/applications/terminal-emulators/kitty/disable-test_ssh_bootstrap_with_different_launchers.patch13
-rw-r--r--pkgs/applications/terminal-emulators/kitty/disable-test_ssh_login_shell_detection.patch13
-rw-r--r--pkgs/applications/terminal-emulators/kitty/tarball-restore-write-permissions.patch27
-rw-r--r--pkgs/applications/terminal-emulators/kitty/zsh-compinit.patch13
5 files changed, 101 insertions, 15 deletions
diff --git a/pkgs/applications/terminal-emulators/kitty/default.nix b/pkgs/applications/terminal-emulators/kitty/default.nix
index efd853b82b42..a1246ce73c1c 100644
--- a/pkgs/applications/terminal-emulators/kitty/default.nix
+++ b/pkgs/applications/terminal-emulators/kitty/default.nix
@@ -28,14 +28,14 @@
with python3Packages;
buildPythonApplication rec {
pname = "kitty";
- version = "0.24.4";
+ version = "0.25.0";
format = "other";
src = fetchFromGitHub {
owner = "kovidgoyal";
repo = "kitty";
rev = "v${version}";
- sha256 = "sha256-c6XM/xeGZ68srf8xQJA1iYCUR3kXNceTMxsZAnbFmug=";
+ sha256 = "sha256-RYQVcbyKIv/FlrtROoQywWR+iF+4KYiYrrzErUrOCWM=";
};
buildInputs = [
@@ -78,21 +78,26 @@ buildPythonApplication rec {
outputs = [ "out" "terminfo" "shell_integration" ];
patches = [
+ # Required to get `test_ssh_env_vars` to pass.
(fetchpatch {
- name = "fix-zsh-completion-test-1.patch";
- url = "https://github.com/kovidgoyal/kitty/commit/297592242c290a81ca4ba08802841f4c33a4de25.patch";
- sha256 = "sha256-/V6y/4AaJsZvx1KS5UFZ+0zyAoZuLgbgFORZ1dX/1qE=";
- })
- (fetchpatch {
- name = "fix-zsh-completion-test-2.patch";
- url = "https://github.com/kovidgoyal/kitty/commit/d8ed42ae8e014d9abf9550a65ae203468f8bfa43.patch";
- sha256 = "sha256-Azgzqf5atW999FVn9rSGKMyZLsI692dYXhJPx07GBO0=";
- })
- (fetchpatch {
- name = "fix-build-with-non-framework-python-on-darwin.patch";
- url = "https://github.com/kovidgoyal/kitty/commit/57cffc71b78244e6a9d49f4c9af24d1a88dbf537.patch";
- sha256 = "sha256-1IGONSVCVo5SmLKw90eqxaI5Mwc764O1ur+aMsc7h94=";
+ name = "increase-pty-lines.patch";
+ url = "https://github.com/kovidgoyal/kitty/commit/eb84990f5a8edc458e04d24cc1cda05316d74ceb.patch";
+ sha256 = "sha256-eOANfhGPMoN4FqxtIGDBu5X0O3RPLABDnL+LKqSLROI=";
})
+ # Fix to ensure that files in tar files used by SSH kitten have write permissions.
+ ./tarball-restore-write-permissions.patch
+
+ # Needed on darwin
+
+ # Gets `test_ssh_shell_integration` to pass for `zsh` when `compinit` complains about
+ # permissions.
+ ./zsh-compinit.patch
+ # Skip `test_ssh_login_shell_detection` in some cases, build users have their shell set to
+ # `/sbin/nologin` which causes issues.
+ ./disable-test_ssh_login_shell_detection.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
];
# Causes build failure due to warning
@@ -141,6 +146,9 @@ buildPythonApplication rec {
# Fontconfig error: Cannot load default config file: No such file: (null)
export FONTCONFIG_FILE=${fontconfig.out}/etc/fonts/fonts.conf
+ # Required for `test_ssh_shell_integration` to pass.
+ export TERM=kitty
+
env PATH="${buildBinPath}:$PATH" ${python.interpreter} test.py
'';
@@ -180,6 +188,18 @@ buildPythonApplication rec {
runHook postInstall
'';
+ # 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/
+ '';
+
passthru.tests.test = nixosTests.terminal-emulators.kitty;
meta = with lib; {
diff --git a/pkgs/applications/terminal-emulators/kitty/disable-test_ssh_bootstrap_with_different_launchers.patch b/pkgs/applications/terminal-emulators/kitty/disable-test_ssh_bootstrap_with_different_launchers.patch
new file mode 100644
index 000000000000..584815b9e07a
--- /dev/null
+++ b/pkgs/applications/terminal-emulators/kitty/disable-test_ssh_bootstrap_with_different_launchers.patch
@@ -0,0 +1,13 @@
+diff --git a/kitty_tests/ssh.py b/kitty_tests/ssh.py
+index 1f424146..d3cc191b 100644
+--- a/kitty_tests/ssh.py
++++ b/kitty_tests/ssh.py
+@@ -166,7 +166,7 @@ def test_ssh_bootstrap_with_different_launchers(self):
+ for sh in self.all_possible_sh:
+ if sh == 'sh' or 'python' in sh:
+ q = shutil.which(launcher)
+- if q:
++ if q and not 'zsh' in q:
+ with self.subTest(sh=sh, launcher=q), tempfile.TemporaryDirectory() as tdir:
+ self.check_bootstrap(sh, tdir, test_script='env; exit 0', SHELL_INTEGRATION_VALUE='', launcher=q)
+
diff --git a/pkgs/applications/terminal-emulators/kitty/disable-test_ssh_login_shell_detection.patch b/pkgs/applications/terminal-emulators/kitty/disable-test_ssh_login_shell_detection.patch
new file mode 100644
index 000000000000..c6301f0de72f
--- /dev/null
+++ b/pkgs/applications/terminal-emulators/kitty/disable-test_ssh_login_shell_detection.patch
@@ -0,0 +1,13 @@
+diff --git a/kitty_tests/ssh.py b/kitty_tests/ssh.py
+index 1f424146..57620334 100644
+--- a/kitty_tests/ssh.py
++++ b/kitty_tests/ssh.py
+@@ -197,7 +197,7 @@ def test_ssh_login_shell_detection(self):
+ expected_login_shell = pwd.getpwuid(os.geteuid()).pw_shell
+ for m in methods:
+ for sh in self.all_possible_sh:
+- if 'python' in sh:
++ if 'python' in sh or '/sbin/nologin' in expected_login_shell:
+ continue
+ with self.subTest(sh=sh, method=m), tempfile.TemporaryDirectory() as tdir:
+ pty = self.check_bootstrap(sh, tdir, test_script=f'{m}; echo "$login_shell"; exit 0', SHELL_INTEGRATION_VALUE='')
diff --git a/pkgs/applications/terminal-emulators/kitty/tarball-restore-write-permissions.patch b/pkgs/applications/terminal-emulators/kitty/tarball-restore-write-permissions.patch
new file mode 100644
index 000000000000..59253bbc4d33
--- /dev/null
+++ b/pkgs/applications/terminal-emulators/kitty/tarball-restore-write-permissions.patch
@@ -0,0 +1,27 @@
+From 59f6876187da2c01b35e696e169ca98239c08a41 Mon Sep 17 00:00:00 2001
+From: Jason Felice <jason.m.felice@gmail.com>
+Date: Tue, 24 May 2022 07:54:25 -0400
+Subject: [PATCH] Restore write permissions in tarball
+
+In Nix, the source files are stored in an immutable store and
+therefore have been stripped of write permissions. When the SSH
+kitten makes the tarfile, the files contained in it are also missing
+the write permissions, causing commands on the remote side to fail.
+---
+ kittens/ssh/main.py | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/kittens/ssh/main.py b/kittens/ssh/main.py
+index 0b50d5ff..f80ac13d 100644
+--- a/kittens/ssh/main.py
++++ b/kittens/ssh/main.py
+@@ -123,6 +123,7 @@ def make_tarfile(ssh_opts: SSHOptions, base_env: Dict[str, str], compression: st
+ def normalize_tarinfo(tarinfo: tarfile.TarInfo) -> tarfile.TarInfo:
+ tarinfo.uname = tarinfo.gname = ''
+ tarinfo.uid = tarinfo.gid = 0
++ tarinfo.mode |= 0o200
+ return tarinfo
+
+ def add_data_as_file(tf: tarfile.TarFile, arcname: str, data: Union[str, bytes]) -> tarfile.TarInfo:
+--
+2.36.0
diff --git a/pkgs/applications/terminal-emulators/kitty/zsh-compinit.patch b/pkgs/applications/terminal-emulators/kitty/zsh-compinit.patch
new file mode 100644
index 000000000000..168f80cb6733
--- /dev/null
+++ b/pkgs/applications/terminal-emulators/kitty/zsh-compinit.patch
@@ -0,0 +1,13 @@
+diff --git a/kitty_tests/ssh.py b/kitty_tests/ssh.py
+index 1f424146..d9a65d25 100644
+--- a/kitty_tests/ssh.py
++++ b/kitty_tests/ssh.py
+@@ -268,6 +268,8 @@ def check_untar_or_fail():
+ return 'UNTAR_DONE' in q
+ pty.wait_till(check_untar_or_fail)
+ self.assertTrue(os.path.exists(os.path.join(home_dir, '.terminfo/kitty.terminfo')))
++ if login_shell == 'zsh':
++ pty.send_cmd_to_child('y')
+ if SHELL_INTEGRATION_VALUE != 'enabled':
+ pty.wait_till(lambda: len(pty.screen_contents().splitlines()) > 1)
+ self.assertEqual(pty.screen.cursor.shape, 0)