Skip to content

Commit

Permalink
code-cursor: prepare for Darwin
Browse files Browse the repository at this point in the history
  • Loading branch information
sarahec committed Jan 14, 2025
1 parent c89b16f commit ae1c300
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions pkgs/by-name/co/code-cursor/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
let
pname = "cursor";
version = "0.44.11";
appKey = "230313mzl4w4u92";

sources = {
x86_64-linux = fetchurl {
Expand All @@ -27,22 +26,15 @@ let
"aarch64-linux"
];


src = sources.${stdenvNoCC.hostPlatform.system};

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

in
stdenvNoCC.mkDerivation {
inherit pname version;

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

nativeBuildInputs = [ makeWrapper ];
wrappedAppImage = appimageTools.wrapType2 { inherit version pname src; };

installPhase = ''
appimageInstall = ''
runHook preInstall
mkdir -p $out/
Expand All @@ -62,25 +54,36 @@ stdenvNoCC.mkDerivation {
runHook postInstall
'';

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
latestLinux="$(curl -s https://download.todesktop.com/${appKey}/latest-linux.yml)"
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"))')"
build="$(echo "$filename" | sed -E s/^cursor-.+-build-\(.+\)-.+\.AppImage$/\\1/)"
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="https://download.todesktop.com/${appKey}/cursor-$version-build-$build-x86_64.AppImage"
url="$baseUrl/$linuxStem-x86_64.AppImage"
elif [ $platform = "aarch64-linux" ]; then
url="https://download.todesktop.com/${appKey}/cursor-$version-build-$build-arm64.AppImage"
url="$baseUrl/$linuxStem-arm64.AppImage"
else
echo "Unsupported platform: $platform"
exit 1
Expand Down

0 comments on commit ae1c300

Please sign in to comment.