Skip to content

Instantly share code, notes, and snippets.

@cmrfrd
Created August 25, 2024 19:29
Show Gist options
  • Select an option

  • Save cmrfrd/db4353627ba6bf9ab713be84aa09c96c to your computer and use it in GitHub Desktop.

Select an option

Save cmrfrd/db4353627ba6bf9ab713be84aa09c96c to your computer and use it in GitHub Desktop.
cursor.nix
{pkgs, ...}: let
pname = "cursor";
version = "0.39.6";
src = pkgs.fetchurl {
url = "https://downloader.cursor.sh/linux/appImage/x64";
hash = "sha256-huZTzIZFAYtGRMhXGC+1sd0l2s5913QkWM+QjCtsEl0=";
# use this to update the hash
# nix hash to-sri --type sha256 $(nix-prefetch-url https://downloader.cursor.sh/linux/appImage/x64)
};
appimageContents = pkgs.appimageTools.extract {inherit pname version src;};
in
with pkgs;
appimageTools.wrapType2 {
inherit pname version src;
extraBwrapArgs = [
"--bind-try /etc/nixos/ /etc/nixos/"
];
dieWithParent = false;
extraPkgs = pkgs: [
unzip
autoPatchelfHook
asar
(buildPackages.wrapGAppsHook.override {inherit (buildPackages) makeWrapper;})
];
extraInstallCommands = ''
install -m 444 -D ${appimageContents}/${pname}.desktop -t $out/share/applications
substituteInPlace $out/share/applications/${pname}.desktop \
--replace 'Exec=AppRun' 'Exec=${pname}'
cp -r ${appimageContents}/usr/share/icons $out/share
# unless linked, the binary is placed in $out/bin/cursor-someVersion
ln -s $out/bin/${pname}-${version} $out/bin/${pname}
'';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment