From 9ff5c93ecf516e4222a4bfa0968e43c720df6f9d Mon Sep 17 00:00:00 2001 From: V Date: Thu, 22 Feb 2024 05:07:36 +0100 Subject: [PATCH] jetbrains-toolbox: fix login flow This does two things: Switch to the upstream desktop file. There's no reason to be using our own, and overriding theirs means we'll miss out on potential changes and improvements. Their desktop file also registers the application as a handler for `jetbrains://` URLs, which was previously missing from ours. Fix the desktop file so that URLs are passed to the application. This argument was erroneously absent from both their and our `Exec=`, meaning that even with the scheme handler, it wouldn't actually see any URLs. `jetbrains://` URLs are used by the application for, among other things, callbacks during the login flow. Without them, it's not possible to smoothly log in; instead requiring the user to paste in an auth token. Change-Id: Ic20469f63c0c3cfbb87f0670afbf5cd68ad7f7c5 --- .../misc/jetbrains-toolbox/default.nix | 23 +++++++------------ 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/pkgs/applications/misc/jetbrains-toolbox/default.nix b/pkgs/applications/misc/jetbrains-toolbox/default.nix index aae85f1e4384..1cb77d4e05f6 100644 --- a/pkgs/applications/misc/jetbrains-toolbox/default.nix +++ b/pkgs/applications/misc/jetbrains-toolbox/default.nix @@ -2,7 +2,6 @@ , lib , fetchzip , copyDesktopItems -, makeDesktopItem , makeWrapper , runCommand , appimageTools @@ -24,6 +23,13 @@ let } '' appimage-exec.sh -x $out ${src}/${pname}-${version}/${pname} + + # JetBrains ship a broken desktop file. Despite registering a custom + # scheme handler for jetbrains:// URLs, they never mark the command as + # being suitable for passing URLs to. Ergo, the handler never receives + # its payload. This causes various things to break, including login. + # Reported upstream at: https://youtrack.jetbrains.com/issue/TBX-11478/ + sed -Ei '/^Exec=/s/( %U)?$/ %U/' $out/jetbrains-toolbox.desktop ''; appimage = appimageTools.wrapAppImage { @@ -31,19 +37,6 @@ let src = appimageContents; extraPkgs = pkgs: (appimageTools.defaultFhsEnvArgs.targetPkgs pkgs); }; - - desktopItem = makeDesktopItem { - name = "JetBrains Toolbox"; - exec = "jetbrains-toolbox"; - comment = "JetBrains Toolbox"; - desktopName = "JetBrains Toolbox"; - type = "Application"; - icon = "jetbrains-toolbox"; - terminal = false; - categories = [ "Development" ]; - startupWMClass = "jetbrains-toolbox"; - startupNotify = false; - }; in stdenv.mkDerivation { inherit pname version src appimage; @@ -61,7 +54,7 @@ stdenv.mkDerivation { runHook postInstall ''; - desktopItems = [ desktopItem ]; + desktopItems = [ "${appimageContents}/jetbrains-toolbox.desktop" ]; # Disabling the tests, this seems to be very difficult to test this app. doCheck = false;