Cursor AI-powered editor setup and configuration on NixOS including AppImage extraction, version updates, cursor-agent patching, and troubleshooting
Cursor is an AI-powered code editor built on VSCode. On NixOS, we use a custom package that extracts and patches the AppImage to work properly with the NixOS environment.
Cursor is installed via the NixOS system configuration:
# nixos/configuration.nix
environment.systemPackages = with pkgs; [
(pkgs.callPackage ./packages/cursor/extracted.nix { })
];
Visit the Cursor Downloads page or check the changelog for the latest version.
Edit nixos/packages/cursor/extracted.nix:
let
pname = "cursor";
version = "1.6.45"; # Update this version number
src = fetchurl {
url = "https://downloads.cursor.com/production/COMMIT_HASH/linux/x64/Cursor-${version}-x86_64.AppImage";
hash = "sha256-PLACEHOLDER"; # This will be updated in the next step
};
Finding the download URL:
https://downloads.cursor.com/production/{commit}/linux/x64/Cursor-{version}-x86_64.AppImageUse nix-prefetch-url to download and calculate the hash:
# Download and get SHA256 hash
nix-prefetch-url https://downloads.cursor.com/production/COMMIT_HASH/linux/x64/Cursor-1.6.45-x86_64.AppImage
# Convert to SRI format (sha256-...)
nix --extra-experimental-features 'nix-command' hash convert --hash-algo sha256 --to sri HASH_FROM_ABOVE
Update the hash field in extracted.nix with the SRI format hash (e.g., sha256-ABC123...=).
# Build the new package
sudo nixos-rebuild switch --flake .#desktop
# Or for testing without system changes
nix build .#nixosConfigurations.desktop.config.environment.systemPackages -L
cursor --version
Claude Code / Gemini / Codex CLI と異なり、Cursor にはホームディレクトリ配下のグローバル指示ファイルという仕組みが存在しない(~/.cursor/AGENTS.md のようなパスは Cursor が読まない)。modules/home/claude/config/AGENTS.md を dotfiles から自動配備する対象に Cursor は含まれていない。理由と回避策は以下の通り。
AGENTS.md(フロントマターなしのプレーン Markdown)を自動的に読む。このリポジトリのようにルートに AGENTS.md があるプロジェクトでは、追加設定なしで人格・行動原則が反映される。.cursor/rules/*.mdc も同様にプロジェクト単位(<repo>/.cursor/rules/)で、$HOME/.cursor/rules/ はスコープ外。modules/home/claude/config/AGENTS.md の内容をコピーして貼り付ける(自動同期の仕組みはなく、内容を更新したら手動で再度貼り直す必要がある)。なお ai-guardrails が生成する ~/.cursor/rules/ai-guardrails.mdc(ホームディレクトリ直下への配置)も、上記と同じ理由でおそらく Cursor に読み込まれない。dotfiles では programs.ai-guardrails.installInstructionFiles = false により、この生成自体を無効化している。
The Cursor package includes an automatic patcher for the cursor-agent node binaries. This is necessary because Cursor downloads its own Node.js binaries to ~/.local/share/cursor-agent/versions/, which are dynamically linked and won't work on NixOS without patching.
How it works:
node binary:.patched marker file to avoid re-patchingLocation: nixos/packages/cursor/extracted.nix:130-161
If cursor-agent fails to run, you can manually patch the node binary:
# Get the NixOS dynamic linker path
INTERPRETER=$(nix --extra-experimental-features 'nix-command flakes' eval --raw 'nixpkgs#stdenv.cc.bintools.dynamicLinker')
# Get the library path
LIBPATH=$(nix --extra-experimental-features 'nix-command flakes' eval --raw 'nixpkgs#stdenv.cc.cc.lib.outPath')/lib
# Patch the binary
nix --extra-experimental-features 'nix-command flakes' run nixpkgs#patchelf -- \
--set-interpreter "$INTERPRETER" \
--set-rpath "$LIBPATH" \
~/.local/share/cursor-agent/versions/*/node
Could not start dynamically linked executableError message:
Could not start dynamically linked executable: /home/user/.local/share/cursor-agent/versions/.../node
NixOS cannot run dynamically linked executables intended for generic linux environments out of the box.
Solution:
.patched marker file exists in the cursor-agent version directory.patched file and restart Cursor to trigger re-patching/nix/store/.../bin/cursormakeCWrapper: Unknown argument --runThis error occurred in older versions when using makeWrapper --run. The current implementation uses a simple bash script wrapper instead.
Solution:
Ensure you're using the latest version of nixos/packages/cursor/extracted.nix from this repository.
Warning messages:
Warning: 'ozone-platform-hint' is not in the list of known options
Warning: 'enable-features' is not in the list of known options
Status: These warnings are harmless and can be ignored. They appear because we pass Wayland-specific flags to enable proper Wayland support. Cursor functions correctly despite these warnings.
Checklist:
ls -la /nix/store/*-cursor-*/file $(which cursor)cursor --verbosesudo nixos-rebuild switch --flake .#desktop --show-tracenix log /nix/store/...-cursor-*.drvIf Cursor attempts to update cursor-agent but fails:
rm -rf ~/.local/share/cursor-agent
nixos/packages/cursor/
├── extracted.nix # Main package definition (AppImage extraction approach)
└── default.nix # Alternative package (AppImage wrapper approach - not used)
We use the extracted.nix approach because:
autoPatchelfHook: Automatically patches ELF binariesasar: Unpacks/repacks VSCode's asar archiveswrapGAppsHook: Sets up GTK/GLib environment variablespatchelf: Runtime patching of cursor-agent binariesripgrep: Replaced with Nix version for consistencyappimageTools.extractautoPatchelfHook and wrapGAppsHook process the binaries