jetbrains-toolbox: support more platforms (#397675)
This commit is contained in:
@@ -1,89 +1,114 @@
|
||||
{
|
||||
stdenv,
|
||||
lib,
|
||||
fetchzip,
|
||||
copyDesktopItems,
|
||||
makeWrapper,
|
||||
runCommand,
|
||||
stdenv,
|
||||
appimageTools,
|
||||
fetchzip,
|
||||
fetchurl,
|
||||
makeWrapper,
|
||||
icu,
|
||||
genericUpdater,
|
||||
writeShellScript,
|
||||
jq,
|
||||
undmg,
|
||||
}:
|
||||
|
||||
let
|
||||
pname = "jetbrains-toolbox";
|
||||
version = "2.5.4.38621";
|
||||
|
||||
src = fetchzip {
|
||||
url = "https://download.jetbrains.com/toolbox/jetbrains-toolbox-${version}.tar.gz";
|
||||
hash = "sha256-FQTw6LPLJV+lV546rFOi/503PuErJs4T5q9MNWwGYEs=";
|
||||
stripRoot = false;
|
||||
};
|
||||
|
||||
appimageContents =
|
||||
runCommand "${pname}-extracted"
|
||||
{
|
||||
nativeBuildInputs = [ appimageTools.appimage-exec ];
|
||||
}
|
||||
''
|
||||
appimage-exec.sh -x $out ${src}/jetbrains-toolbox-${version}/jetbrains-toolbox
|
||||
|
||||
# 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 {
|
||||
inherit pname version;
|
||||
src = appimageContents;
|
||||
};
|
||||
in
|
||||
stdenv.mkDerivation {
|
||||
inherit
|
||||
pname
|
||||
version
|
||||
src
|
||||
appimage
|
||||
;
|
||||
|
||||
nativeBuildInputs = [
|
||||
makeWrapper
|
||||
copyDesktopItems
|
||||
];
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
install -Dm644 ${appimageContents}/.DirIcon $out/share/icons/hicolor/scalable/apps/jetbrains-toolbox.svg
|
||||
makeWrapper ${appimage}/bin/jetbrains-toolbox $out/bin/jetbrains-toolbox \
|
||||
--append-flags "--update-failed" \
|
||||
--prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath [ icu ]}
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
desktopItems = [ "${appimageContents}/jetbrains-toolbox.desktop" ];
|
||||
|
||||
# Disabling the tests, this seems to be very difficult to test this app.
|
||||
doCheck = false;
|
||||
|
||||
passthru.updateScript = genericUpdater {
|
||||
versionLister = writeShellScript "jetbrains-toolbox-versionLister" ''
|
||||
curl -Ls 'https://data.services.jetbrains.com/products?code=TBA&release.type=release' \
|
||||
| ${lib.getExe jq} -r '.[] | .releases | flatten[] | .build'
|
||||
'';
|
||||
};
|
||||
passthru.updateScript = ./update.sh;
|
||||
|
||||
meta = {
|
||||
description = "Jetbrains Toolbox";
|
||||
homepage = "https://jetbrains.com/";
|
||||
license = lib.licenses.unfree;
|
||||
maintainers = with lib.maintainers; [ AnatolyPopov ];
|
||||
platforms = [ "x86_64-linux" ];
|
||||
platforms = [
|
||||
"aarch64-linux"
|
||||
"aarch64-darwin"
|
||||
"x86_64-linux"
|
||||
"x86_64-darwin"
|
||||
];
|
||||
mainProgram = "jetbrains-toolbox";
|
||||
};
|
||||
}
|
||||
|
||||
selectSystem =
|
||||
attrs:
|
||||
attrs.${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}");
|
||||
|
||||
linux = appimageTools.wrapAppImage rec {
|
||||
inherit
|
||||
pname
|
||||
version
|
||||
passthru
|
||||
meta
|
||||
;
|
||||
|
||||
src = appimageTools.extractType2 {
|
||||
inherit pname version;
|
||||
src =
|
||||
let
|
||||
arch = selectSystem {
|
||||
x86_64-linux = "";
|
||||
aarch64-linux = "-arm64";
|
||||
};
|
||||
in
|
||||
fetchzip {
|
||||
url = "https://download.jetbrains.com/toolbox/jetbrains-toolbox-${version}${arch}.tar.gz";
|
||||
hash = selectSystem {
|
||||
x86_64-linux = "sha256-rq0Hn9g+/u9C8vbEVH2mv62c1dvxr+t9tBhf26swQgI=";
|
||||
aarch64-linux = "sha256-52wFejaKBSg/eeJu3NDGl1AdZLsJdi/838YeROD4Loc=";
|
||||
};
|
||||
}
|
||||
+ "/jetbrains-toolbox";
|
||||
postExtract = ''
|
||||
patchelf --add-rpath ${lib.makeLibraryPath [ icu ]} $out/jetbrains-toolbox
|
||||
'';
|
||||
};
|
||||
|
||||
nativeBuildInputs = [ makeWrapper ];
|
||||
|
||||
extraInstallCommands = ''
|
||||
install -Dm644 ${src}/jetbrains-toolbox.desktop $out/share/applications/jetbrains-toolbox.desktop
|
||||
install -Dm644 ${src}/.DirIcon $out/share/icons/hicolor/scalable/apps/jetbrains-toolbox.svg
|
||||
wrapProgram $out/bin/jetbrains-toolbox \
|
||||
--append-flags "--update-failed"
|
||||
'';
|
||||
};
|
||||
|
||||
darwin = stdenv.mkDerivation (finalAttrs: {
|
||||
inherit
|
||||
pname
|
||||
version
|
||||
passthru
|
||||
meta
|
||||
;
|
||||
|
||||
src =
|
||||
let
|
||||
arch = selectSystem {
|
||||
x86_64-darwin = "";
|
||||
aarch64-darwin = "-arm64";
|
||||
};
|
||||
in
|
||||
fetchurl {
|
||||
url = "https://download.jetbrains.com/toolbox/jetbrains-toolbox-${finalAttrs.version}${arch}.dmg";
|
||||
hash = selectSystem {
|
||||
x86_64-darwin = "sha256-y0zXQEqY5lj/e440dRtyBfaw8CwqqgzO3Ujreb37Z/I=";
|
||||
aarch64-darwin = "sha256-9Bj5puG9NUHO53oXBRlB5DvX9jGTmrkDgjV2QPH9qg0=";
|
||||
};
|
||||
};
|
||||
|
||||
nativeBuildInputs = [ undmg ];
|
||||
|
||||
sourceRoot = "JetBrains Toolbox.app";
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
mkdir -p $out/Applications $out/bin
|
||||
cp -r . $out/Applications/"JetBrains Toolbox.app"
|
||||
ln -s $out/Applications/"JetBrains Toolbox.app"/Contents/MacOS/jetbrains-toolbox $out/bin/jetbrains-toolbox
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
});
|
||||
in
|
||||
if stdenv.hostPlatform.isDarwin then darwin else linux
|
||||
|
||||
Executable
+41
@@ -0,0 +1,41 @@
|
||||
#!/usr/bin/env nix-shell
|
||||
#!nix-shell -i bash -p bash nix curl coreutils jq common-updater-scripts
|
||||
|
||||
set -eou pipefail
|
||||
|
||||
latestVersion=$(curl -Ls 'https://data.services.jetbrains.com/products?code=TBA&release.type=release' | jq -r '.[0].releases | flatten | .[0].build')
|
||||
currentVersion=$(nix-instantiate --eval -E "with import ./. {}; jetbrains-toolbox.version or (lib.getVersion jetbrains-toolbox)" | tr -d '"')
|
||||
|
||||
echo "latest version: $latestVersion"
|
||||
echo "current version: $currentVersion"
|
||||
|
||||
if [[ "$latestVersion" == "$currentVersion" ]]; then
|
||||
echo "package is up-to-date"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
linux_systems=(
|
||||
"x86_64-linux:"
|
||||
"aarch64-linux:-arm64"
|
||||
)
|
||||
|
||||
for entry in "${linux_systems[@]}"; do
|
||||
arch="${entry%%:*}"
|
||||
suffix="${entry#*:}"
|
||||
prefetch=$(nix-prefetch-url --unpack "https://download.jetbrains.com/toolbox/jetbrains-toolbox-$latestVersion$suffix.tar.gz")
|
||||
hash=$(nix hash convert --hash-algo sha256 --to sri $prefetch)
|
||||
update-source-version jetbrains-toolbox $latestVersion $hash --system=$arch --ignore-same-version
|
||||
done
|
||||
|
||||
darwin_systems=(
|
||||
"x86_64-darwin:"
|
||||
"aarch64-darwin:-arm64"
|
||||
)
|
||||
|
||||
for entry in "${darwin_systems[@]}"; do
|
||||
arch="${entry%%:*}"
|
||||
suffix="${entry#*:}"
|
||||
prefetch=$(nix-prefetch-url "https://download.jetbrains.com/toolbox/jetbrains-toolbox-$latestVersion$suffix.dmg")
|
||||
hash=$(nix hash convert --hash-algo sha256 --to sri $prefetch)
|
||||
update-source-version jetbrains-toolbox $latestVersion $hash --system=$arch --ignore-same-version
|
||||
done
|
||||
Reference in New Issue
Block a user