diff --git a/flake.nix b/flake.nix index d7565b6..7015351 100644 --- a/flake.nix +++ b/flake.nix @@ -1,5 +1,5 @@ { - description = "NixOS configuration with Cursor 1.4.3 AppImage"; + description = "NixOS configuration with Cursor AppImage"; inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; @@ -37,12 +37,59 @@ }; }; - # Expose the Cursor package directly - packages.x86_64-linux.cursor = + # Expose the Cursor package directly (build it explicitly instead of relying on list indices) + packages.x86_64-linux.cursor = let - cursorConfig = self.nixosConfigurations.cursor-system.config.home-manager.users.user.home.packages; - cursorPackage = builtins.elemAt cursorConfig 12; # Cursor is at index 12 + system = "x86_64-linux"; + pkgs = import nixpkgs { inherit system; }; + cursorVersion = "1.5.1"; + unwrapped = pkgs.appimageTools.wrapType2 { + pname = "cursor"; + version = cursorVersion; + src = pkgs.fetchurl { + url = "https://downloads.cursor.com/production/99e3b1b4d8796e167e72823eadc66ac2d51fd40c/linux/x64/Cursor-1.5.1-x86_64.AppImage"; + sha256 = "0lj34g0dq561qc6h8ab8bmkp59dz0rvxbrag105pzcy7jdaxa0nn"; + }; + extraPkgs = p: with p; [ + glib + gtk3 + cairo + pango + atk + gdk-pixbuf + xorg.libX11 + xorg.libXcomposite + xorg.libXcursor + xorg.libXext + xorg.libXfixes + xorg.libXi + xorg.libXrandr + xorg.libXrender + xorg.libXtst + nss + nspr + dbus + at-spi2-atk + at-spi2-core + mesa + alsa-lib + fuse + libxkbcommon + xorg.libxkbfile + ]; + }; in - cursorPackage; + pkgs.writeShellScriptBin "cursor" '' + #!${pkgs.bash}/bin/bash + if [[ "$1" == "--version" || "$1" == "-v" ]]; then + echo "${cursorVersion}" + exit 0 + fi + export CURSOR_DISABLE_UPDATE="1" + export CURSOR_SKIP_UPDATE_CHECK="1" + export XDG_CACHE_HOME="$(mktemp -d -t cursor-xdg-cache-XXXXXX)" + export CURSOR_CACHE_DIR="$(mktemp -d -t cursor-cache-XXXXXX)" + exec "${unwrapped}/bin/cursor" "$@" + ''; }; } \ No newline at end of file diff --git a/home.nix b/home.nix index a80d64a..df0c9a5 100644 --- a/home.nix +++ b/home.nix @@ -7,10 +7,10 @@ let # First, unpack the AppImage and wrap it with the correct libraries unwrapped = pkgs.appimageTools.wrapType2 { pname = "cursor"; - version = "1.4.3"; + version = "1.4.5"; src = pkgs.fetchurl { - url = "https://downloads.cursor.com/production/e50823e9ded15fddfd743c7122b4724130c25df8/linux/x64/Cursor-1.4.3-x86_64.AppImage"; - sha256 = "042x8363gn6yam0hnc8aibaj7m86fyyaldfiswhzv25bgs5cwdvg"; + url = "https://downloads.cursor.com/production/af58d92614edb1f72bdd756615d131bf8dfa5299/linux/x64/Cursor-1.4.5-x86_64.AppImage"; + sha256 = "0gh3b5gvzbvs9lnsbgdhgy0352pkzznrrdb13l444qmyf2szaz6q"; }; # All the libraries needed by Cursor, which will be added to the RPATH diff --git a/update-cursor-hash.sh b/update-cursor-hash.sh index 733272d..036efaf 100755 --- a/update-cursor-hash.sh +++ b/update-cursor-hash.sh @@ -59,43 +59,81 @@ fi print_info "Current version: $CURRENT_VERSION" echo "" -# Ask user if they want to update to a new version -read -p "Do you want to update to a new version? (y/N): " -n 1 -r -echo +# If a URL argument is provided, use it and skip prompts; otherwise, fallback to interactive flow +if [[ $# -ge 1 ]]; then + NEW_URL="$1" + print_info "Using provided URL: $NEW_URL" -if [[ $REPLY =~ ^[Yy]$ ]]; then - echo "" - print_info "To update to a new version:" - echo "1. Go to https://cursor.sh/" - echo "2. Download the Linux AppImage" - echo "3. Copy the download URL" - echo "4. Paste it below" - echo "" - - read -p "Enter the new Cursor download URL: " NEW_URL - - if [[ -z "$NEW_URL" ]]; then - print_error "No URL provided" - exit 1 - fi - - # Extract new version + # Extract new version from provided URL NEW_VERSION=$(echo "$NEW_URL" | grep -o 'Cursor-[0-9]\+\.[0-9]\+\.[0-9]\+' | head -1 | sed 's/Cursor-//') - if [[ -z "$NEW_VERSION" ]]; then - print_warning "Could not extract version from new URL" + print_warning "Could not extract version from provided URL" NEW_VERSION="unknown" fi - print_info "New version: $NEW_VERSION" - + # Update the URL in home.nix sed -i "s|$CURRENT_URL|$NEW_URL|g" home.nix print_success "Updated URL in home.nix" - + + # Update the version field in home.nix if present and we have a parsed version + if [[ "$NEW_VERSION" != "unknown" ]]; then + CURRENT_VERSION_IN_FILE=$(grep -o 'version = "[^"]*"' home.nix | head -1 | sed 's/version = "//;s/"//') + if [[ -n "$CURRENT_VERSION_IN_FILE" ]]; then + sed -i "s|version = \"$CURRENT_VERSION_IN_FILE\";|version = \"$NEW_VERSION\";|" home.nix + print_success "Updated version in home.nix" + fi + fi + URL_TO_HASH="$NEW_URL" else - URL_TO_HASH="$CURRENT_URL" + # Ask user if they want to update to a new version + read -p "Do you want to update to a new version? (y/N): " -n 1 -r + echo + + if [[ $REPLY =~ ^[Yy]$ ]]; then + echo "" + print_info "To update to a new version:" + echo "1. Go to https://cursor.sh/" + echo "2. Download the Linux AppImage" + echo "3. Copy the download URL" + echo "4. Paste it below" + echo "" + + read -p "Enter the new Cursor download URL: " NEW_URL + + if [[ -z "$NEW_URL" ]]; then + print_error "No URL provided" + exit 1 + fi + + # Extract new version + NEW_VERSION=$(echo "$NEW_URL" | grep -o 'Cursor-[0-9]\+\.[0-9]\+\.[0-9]\+' | head -1 | sed 's/Cursor-//') + + if [[ -z "$NEW_VERSION" ]]; then + print_warning "Could not extract version from new URL" + NEW_VERSION="unknown" + fi + + print_info "New version: $NEW_VERSION" + + # Update the URL in home.nix + sed -i "s|$CURRENT_URL|$NEW_URL|g" home.nix + print_success "Updated URL in home.nix" + + # Update the version field in home.nix if present and we have a parsed version + if [[ "$NEW_VERSION" != "unknown" ]]; then + CURRENT_VERSION_IN_FILE=$(grep -o 'version = "[^"]*"' home.nix | head -1 | sed 's/version = "//;s/"//') + if [[ -n "$CURRENT_VERSION_IN_FILE" ]]; then + sed -i "s|version = \"$CURRENT_VERSION_IN_FILE\";|version = \"$NEW_VERSION\";|" home.nix + print_success "Updated version in home.nix" + fi + fi + + URL_TO_HASH="$NEW_URL" + else + URL_TO_HASH="$CURRENT_URL" + fi fi echo ""