Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

code-cursor: add aarch64-linux #373536

Merged
merged 1 commit into from
Jan 14, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 64 additions & 27 deletions pkgs/by-name/co/code-cursor/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,32 @@
let
pname = "cursor";
version = "0.44.11";
appKey = "230313mzl4w4u92";
src = fetchurl {
url = "https://download.todesktop.com/230313mzl4w4u92/cursor-0.44.11-build-250103fqxdt5u9z-x86_64.AppImage";
hash = "sha256-eOZuofnpED9F6wic0S9m933Tb7Gq7cb/v0kRDltvFVg=";

sources = {
x86_64-linux = fetchurl {
url = "https://download.todesktop.com/230313mzl4w4u92/cursor-0.44.11-build-250103fqxdt5u9z-x86_64.AppImage";
hash = "sha256-eOZuofnpED9F6wic0S9m933Tb7Gq7cb/v0kRDltvFVg=";
};
aarch64-linux = fetchurl {
url = "https://download.todesktop.com/230313mzl4w4u92/cursor-0.44.11-build-250103fqxdt5u9z-arm64.AppImage";
hash = "sha256-mxq7tQJfDccE0QsZDZbaFUKO0Xc141N00ntX3oEYRcc=";
};
sarahec marked this conversation as resolved.
Show resolved Hide resolved
};
appimageContents = appimageTools.extractType2 { inherit version pname src; };
in
stdenvNoCC.mkDerivation {
inherit pname version;

src = appimageTools.wrapType2 { inherit version pname src; };
supportedPlatforms = [
"x86_64-linux"
"aarch64-linux"
];

nativeBuildInputs = [ makeWrapper ];
src = sources.${stdenvNoCC.hostPlatform.system};
sarahec marked this conversation as resolved.
Show resolved Hide resolved

installPhase = ''
appimageContents = appimageTools.extractType2 {
inherit version pname src;
};

wrappedAppImage = appimageTools.wrapType2 { inherit version pname src; };

appimageInstall = ''
runHook preInstall

mkdir -p $out/
Expand All @@ -43,21 +54,47 @@ stdenvNoCC.mkDerivation {
runHook postInstall
'';

passthru.updateScript = writeScript "update.sh" ''
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p curl yq coreutils gnused common-updater-scripts
set -eu -o pipefail
latestLinux="$(curl -s https://download.todesktop.com/${appKey}/latest-linux.yml)"
version="$(echo "$latestLinux" | yq -r .version)"
filename="$(echo "$latestLinux" | yq -r '.files[] | .url | select(. | endswith(".AppImage"))')"
url="https://download.todesktop.com/${appKey}/$filename"
currentVersion=$(nix-instantiate --eval -E "with import ./. {}; code-cursor.version or (lib.getVersion code-cursor)" | tr -d '"')

if [[ "$version" != "$currentVersion" ]]; then
hash=$(nix-hash --to-sri --type sha256 "$(nix-prefetch-url "$url")")
update-source-version code-cursor "$version" "$hash" "$url" --source-key=src.src
fi
'';
in
stdenvNoCC.mkDerivation {
inherit pname version;

src = wrappedAppImage;

nativeBuildInputs = [ makeWrapper ];

installPhase = appimageInstall;

passthru = {
inherit sources;
updateScript = writeScript "update.sh" ''
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p curl yq coreutils gnused common-updater-scripts
set -eu -o pipefail
baseUrl="https://download.todesktop.com/230313mzl4w4u92"
latestLinux="$(curl -s $baseUrl/latest-linux.yml)"
version="$(echo "$latestLinux" | yq -r .version)"
filename="$(echo "$latestLinux" | yq -r '.files[] | .url | select(. | endswith(".AppImage"))')"
linuxStem="$(echo "$filename" | sed -E s/^\(cursor-.+-build-.*\)-.+$/\\1/)"

currentVersion=$(nix-instantiate --eval -E "with import ./. {}; code-cursor.version or (lib.getVersion code-cursor)" | tr -d '"')

if [[ "$version" != "$currentVersion" ]]; then
for platform in ${lib.escapeShellArgs supportedPlatforms}; do
if [ $platform = "x86_64-linux" ]; then
url="$baseUrl/$linuxStem-x86_64.AppImage"
elif [ $platform = "aarch64-linux" ]; then
url="$baseUrl/$linuxStem-arm64.AppImage"
else
echo "Unsupported platform: $platform"
exit 1
fi

hash=$(nix-hash --to-sri --type sha256 "$(nix-prefetch-url "$url")")
update-source-version code-cursor $version $hash $url --system=$platform --ignore-same-version --source-key="sources.$platform"
done
fi
'';
};

meta = {
description = "AI-powered code editor built on vscode";
Expand All @@ -66,7 +103,7 @@ stdenvNoCC.mkDerivation {
license = lib.licenses.unfree;
sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
maintainers = with lib.maintainers; [ sarahec ];
platforms = [ "x86_64-linux" ];
platforms = lib.platforms.linux;
mainProgram = "cursor";
};
}