Skip to content

Commit

Permalink
cursor -> add darwin, modify update script, add maintainer
Browse files Browse the repository at this point in the history
formatted nixfmt

cursor -> add darwin, modify update script, add maintainer

formatted nixfmt

Update pkgs/by-name/co/code-cursor/package.nix

Co-authored-by: Sarah Clark <[email protected]>

Update pkgs/by-name/co/code-cursor/package.nix

Co-authored-by: Sarah Clark <[email protected]>

Update pkgs/by-name/co/code-cursor/package.nix

Co-authored-by: Sarah Clark <[email protected]>

Update pkgs/by-name/co/code-cursor/package.nix

I missed that, thanks

Co-authored-by: Sarah Clark <[email protected]>

add myself as a maintainer

modify update script.

fix src = source;

cursor -> add darwin, modify update script, add maintainer

formatted nixfmt

cursor -> add darwin, modify update script, add maintainer

formatted nixfmt

Update pkgs/by-name/co/code-cursor/package.nix

Co-authored-by: Sarah Clark <[email protected]>

Update pkgs/by-name/co/code-cursor/package.nix

Co-authored-by: Sarah Clark <[email protected]>

Update pkgs/by-name/co/code-cursor/package.nix

Co-authored-by: Sarah Clark <[email protected]>

Update pkgs/by-name/co/code-cursor/package.nix

I missed that, thanks

Co-authored-by: Sarah Clark <[email protected]>

add myself as a maintainer

modify update script.

fix src = source;

tidying up the code

Co-authored-by: Sarah Clark <[email protected]>

set back to src instead of source

Co-authored-by: Sarah Clark <[email protected]>

tell it we don't need a build phase

Co-authored-by: Sarah Clark <[email protected]>

use singular form lib.optional and fix spelling

Co-authored-by: Sarah Clark <[email protected]>

inherit src

Co-authored-by: Sarah Clark <[email protected]>

Update pkgs/by-name/co/code-cursor/package.nix

Co-authored-by: Sarah Clark <[email protected]>

Update pkgs/by-name/co/code-cursor/package.nix

Co-authored-by: Sarah Clark <[email protected]>

Update pkgs/by-name/co/code-cursor/package.nix

Co-authored-by: Sarah Clark <[email protected]>

Update package.nix

Co-authored-by: Sarah Clark <[email protected]>

again, format
  • Loading branch information
aspauldingcode committed Jan 19, 2025
1 parent 0243bf6 commit 794bcfa
Showing 1 changed file with 67 additions and 12 deletions.
79 changes: 67 additions & 12 deletions pkgs/by-name/co/code-cursor/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@
appimageTools,
makeWrapper,
writeScript,
undmg,
}:

let
pname = "cursor";
version = "0.44.11";

inherit (stdenvNoCC) buildPlatform;

sources = {
x86_64-linux = fetchurl {
url = "https://download.todesktop.com/230313mzl4w4u92/cursor-0.44.11-build-250103fqxdt5u9z-x86_64.AppImage";
Expand All @@ -19,20 +23,32 @@ let
url = "https://download.todesktop.com/230313mzl4w4u92/cursor-0.44.11-build-250103fqxdt5u9z-arm64.AppImage";
hash = "sha256-mxq7tQJfDccE0QsZDZbaFUKO0Xc141N00ntX3oEYRcc=";
};
x86_64-darwin = fetchurl {
url = "https://download.todesktop.com/230313mzl4w4u92/Cursor%200.44.11%20-%20Build%20250103fqxdt5u9z-x64.dmg";
hash = "sha256-JKPClcUD2W3KWRlRTomDF4FOOA1DDw3iAQ+IH7yan+E=";
};
aarch64-darwin = fetchurl {
url = "https://download.todesktop.com/230313mzl4w4u92/Cursor%200.44.11%20-%20Build%20250103fqxdt5u9z-arm64.dmg";
hash = "sha256-0HDnRYfy+jKJy5dvaulQczAoFqYmGGWcdhIkaFZqEPA=";
};
};

supportedPlatforms = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];

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

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

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

appimageInstall = ''
runHook preInstall
Expand All @@ -54,41 +70,77 @@ let
runHook postInstall
'';

darwinInstallPhase = ''
runHook preInstall
mkdir -p $out/Applications
cp -r *.app $out/Applications/
mkdir -p "$out/bin"
cat << EOF > "$out/bin/cursor"
open -na '$APP_DIR' --args "\$@"
EOF
chmod +x "$out/bin/cursor"
runHook postInstall
'';

in
stdenvNoCC.mkDerivation {
inherit pname version;

src = wrappedAppImage;
src = if buildPlatform.isLinux then wrappedAppImage else null;

dontBuild = buildPlatform.isDarwin;

nativeBuildInputs = [ makeWrapper ] ++ lib.optional buildPlatform.isDarwin undmg;

nativeBuildInputs = [ makeWrapper ];
sourceRoot = ".";

installPhase = appimageInstall;
installPhase = if buildPlatform.isDarwin then darwinInstallPhase else 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
#!nix-shell -i bash -p curl yq coreutils gnused trurl 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/)"
latestDarwin="$(curl -s $baseUrl/latest-mac.yml)"
linuxVersion="$(echo "$latestLinux" | yq -r .version)"
currentVersion=$(nix-instantiate --eval -E "with import ./. {}; code-cursor.version or (lib.getVersion code-cursor)" | tr -d '"')
if [[ "$version" != "$currentVersion" ]]; then
if [[ "$linuxVersion" != "$currentVersion" ]]; then
darwinVersion="$(echo "$latestDarwin" | yq -r .version)"
if [ "$linuxVersion" != "$darwinVersion" ]; then
echo "Linux version ($linuxVersion) and Darwin version ($darwinVersion) do not match"
exit 1
fi
version="$linuxVersion"
linuxFilename="$(echo "$latestLinux" | yq -r '.files[] | .url | select(. | endswith(".AppImage"))' | head -n 1)"
linuxStem="$(echo "$linuxFilename" | sed -E s/^\(.+build.+\)-[^-]+AppImage$/\\1/)"
darwinFilename="$(echo "$latestDarwin" | yq -r '.files[] | .url | select(. | endswith(".dmg"))' | head -n 1)"
darwinStem="$(echo "$darwinFilename" | sed -E s/^\(.+Build[^-]+\)-.+dmg$/\\1/)"
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"
elif [ $platform = "x86_64-darwin" ]; then
url="$baseUrl/$darwinStem-x64.dmg"
elif [ $platform = "aarch64-darwin" ]; then
url="$baseUrl/$darwinStem-arm64.dmg"
else
echo "Unsupported platform: $platform"
exit 1
fi
url=$(trurl --accept-space "$url")
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
Expand All @@ -102,8 +154,11 @@ stdenvNoCC.mkDerivation {
changelog = "https://cursor.com/changelog";
license = lib.licenses.unfree;
sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
maintainers = with lib.maintainers; [ sarahec ];
platforms = lib.platforms.linux;
maintainers = with lib.maintainers; [
sarahec
aspauldingcode
];
platforms = supportedPlatforms;
mainProgram = "cursor";
};
}

0 comments on commit 794bcfa

Please sign in to comment.