From 1842c4aaa409e4731d355aa1f77ed817dd3939a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vask=C3=B3=20L=C3=A1szl=C3=B3?= Date: Sat, 20 Oct 2018 16:06:03 +0200 Subject: [PATCH 1/2] kitty: fix locating libstartup-notification-1 Startup notification doesn't work in recent versions of Kitty: > Traceback (most recent call last): > File "/nix/store/3a3b0xd952gp8jw70k5kh3a4zhgzf0p7-kitty-0.12.3/bin/../lib/kitty/kitty/utils.py", line 216, in init_startup_notification > return init_startup_notification_x11(window_handle, startup_id) > File "/nix/store/3a3b0xd952gp8jw70k5kh3a4zhgzf0p7-kitty-0.12.3/bin/../lib/kitty/kitty/utils.py", line 201, in init_startup_notification_x11 > return init_x11_startup_notification(display, window_handle, sid) > OSError: Failed to load libstartup-notification-1.so with error: libstartup-notification-1.so: cannot open shared object file: No such file or directory Apparently dispatching of startup notification has been moved to a C binding in kitty 0.6.0 [1] so the substituion had to be modified to reflect that. Without this fix Kitty still works except that window managers which depend on startup notifications to be fired (e.g. Awesome) cannot apply special placement rules. The substitution mechanism is also changed to use a patch file to detect this kind of mistakes in the future. [1]: https://github.com/kovidgoyal/kitty/commit/b08f4ab5937199187581aa20e3a7aba7b2a34ac6 --- pkgs/applications/misc/kitty/default.nix | 14 +++++++++----- pkgs/applications/misc/kitty/fix-paths.patch | 11 +++++++++++ 2 files changed, 20 insertions(+), 5 deletions(-) create mode 100644 pkgs/applications/misc/kitty/fix-paths.patch diff --git a/pkgs/applications/misc/kitty/default.nix b/pkgs/applications/misc/kitty/default.nix index 4febac10806..2bdcd78b6e1 100644 --- a/pkgs/applications/misc/kitty/default.nix +++ b/pkgs/applications/misc/kitty/default.nix @@ -1,5 +1,5 @@ -{ stdenv, fetchFromGitHub, python3Packages, glfw, libunistring, harfbuzz, - fontconfig, pkgconfig, ncurses, imagemagick, xsel, +{ stdenv, substituteAll, fetchFromGitHub, python3Packages, glfw, libunistring, + harfbuzz, fontconfig, pkgconfig, ncurses, imagemagick, xsel, libstartup_notification, libX11, libXrandr, libXinerama, libXcursor, libxkbcommon, libXi, libXext, wayland-protocols, wayland, which, dbus @@ -28,10 +28,14 @@ buildPythonApplication rec { outputs = [ "out" "terminfo" ]; - postPatch = '' - substituteInPlace kitty/utils.py \ - --replace "find_library('startup-notification-1')" "'${libstartup_notification}/lib/libstartup-notification-1.so'" + patches = [ + (substituteAll { + src = ./fix-paths.patch; + libstartup_notification = "${libstartup_notification}/lib/libstartup-notification-1.so"; + }) + ]; + postPatch = '' substituteInPlace docs/Makefile \ --replace 'python3 .. +launch :sphinx-build' \ 'PYTHONPATH=$PYTHONPATH:.. HOME=$TMPDIR/nowhere sphinx-build' diff --git a/pkgs/applications/misc/kitty/fix-paths.patch b/pkgs/applications/misc/kitty/fix-paths.patch new file mode 100644 index 00000000000..dad6c949839 --- /dev/null +++ b/pkgs/applications/misc/kitty/fix-paths.patch @@ -0,0 +1,11 @@ +--- a/kitty/desktop.c ++++ b/kitty/desktop.c +@@ -30,7 +30,7 @@ + static PyObject* + init_x11_startup_notification(PyObject UNUSED *self, PyObject *args) { + static bool done = false; +- static const char* libname = "libstartup-notification-1.so"; ++ static const char* libname = "@libstartup_notification@"; + if (!done) { + done = true; + From 2fdfa2115df58895ad32641df01b31b5815b075f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vask=C3=B3=20L=C3=A1szl=C3=B3?= Date: Sat, 20 Oct 2018 20:40:20 +0200 Subject: [PATCH 2/2] kitty: fixing environment variable substituition in docs/Makefile The previous substitutution only worked by accident as make requires environment variables to be enclosed in curly brackets as shown in this excerpt from the build output: > PYTHONPATH=YTHONPATH:.. HOME=MPDIR/nowhere sphinx-build -M html "." "_build" -T The substituition is moved to the existing patch file to simplify the builder expression. --- pkgs/applications/misc/kitty/default.nix | 6 ------ pkgs/applications/misc/kitty/fix-paths.patch | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/pkgs/applications/misc/kitty/default.nix b/pkgs/applications/misc/kitty/default.nix index 2bdcd78b6e1..8cff766371e 100644 --- a/pkgs/applications/misc/kitty/default.nix +++ b/pkgs/applications/misc/kitty/default.nix @@ -35,12 +35,6 @@ buildPythonApplication rec { }) ]; - postPatch = '' - substituteInPlace docs/Makefile \ - --replace 'python3 .. +launch :sphinx-build' \ - 'PYTHONPATH=$PYTHONPATH:.. HOME=$TMPDIR/nowhere sphinx-build' - ''; - buildPhase = '' python3 setup.py linux-package ''; diff --git a/pkgs/applications/misc/kitty/fix-paths.patch b/pkgs/applications/misc/kitty/fix-paths.patch index dad6c949839..e22f4570a4b 100644 --- a/pkgs/applications/misc/kitty/fix-paths.patch +++ b/pkgs/applications/misc/kitty/fix-paths.patch @@ -9,3 +9,19 @@ if (!done) { done = true; +--- a/docs/Makefile ++++ b/docs/Makefile +@@ -3,7 +3,7 @@ +# Patching is needed here for the following reasons: +# * `sphinx-build` in nixpkgs is not a Python file but a wrapper shell script +# * importing the `constants` package from Kitty has a side effect that it +# creates the user configuration directory. This package gets imported +# while sphinx scans the code for documentation strings. +# + # You can set these variables from the command line. + SPHINXOPTS = -T $(FAIL_WARN) +-SPHINXBUILD = python3 .. +launch :sphinx-build ++SPHINXBUILD = PYTHONPATH=${PYTHONPATH}:.. HOME=${TMPDIR}/kitty-build-home sphinx-build + SPHINXPROJ = kitty + SOURCEDIR = . + BUILDDIR = _build