f9d5c70fb1
- Simplified the cursor package selection by removing the deprecated `cursor-agent` option and retaining only `cursor-cli`. - Updated the activation script to remove the broken `cursor-agent` symlink, ensuring proper resolution to `cursor-cli`. - Adjusted the configuration to reflect these changes in the Nix IDE tools integration.
77 lines
2.5 KiB
Nix
77 lines
2.5 KiB
Nix
{ inputs, ... }: {
|
|
flake.homeManagerModules.wisdomEditorsCursor =
|
|
{ config, lib, pkgs, ... }:
|
|
let
|
|
root = config.chiasson.home;
|
|
cfg = config.chiasson.home.editors.cursor;
|
|
cursorPkgs = inputs.cursor.packages.${pkgs.stdenv.hostPlatform.system} or { };
|
|
cursorPkg =
|
|
if cursorPkgs ? cursor then
|
|
cursorPkgs.cursor
|
|
else if cursorPkgs ? default then
|
|
cursorPkgs.default
|
|
else
|
|
null;
|
|
cursorCli = if pkgs ? cursor-cli then pkgs.cursor-cli else null;
|
|
nixIdeTools = [ pkgs.nixd pkgs.nixfmt ];
|
|
cursorWithNixIde =
|
|
if cursorPkg == null then
|
|
null
|
|
else
|
|
pkgs.symlinkJoin {
|
|
name = "cursor-with-nix-ide";
|
|
paths = [ cursorPkg ];
|
|
buildInputs = [ pkgs.makeWrapper ];
|
|
postBuild = ''
|
|
for prog in $out/bin/*; do
|
|
if [ -x "$prog" ]; then
|
|
wrapProgram "$prog" --prefix PATH : "${lib.makeBinPath nixIdeTools}"
|
|
fi
|
|
done
|
|
'';
|
|
};
|
|
in
|
|
{
|
|
options.chiasson.home.editors.cursor = {
|
|
enable = lib.mkEnableOption "Cursor editor from the `cursor` flake input.";
|
|
setAsDefaultEditor = lib.mkOption {
|
|
type = lib.types.bool;
|
|
default = true;
|
|
description = "`EDITOR` / `VISUAL` → `cursor --wait`.";
|
|
};
|
|
nixIde = {
|
|
enable = lib.mkEnableOption ''
|
|
Nix IDE extension tooling (`nixd` LSP, `nixfmt` formatter).
|
|
|
|
Installs `nixd` / `nixfmt` and wraps Cursor so they are on the editor `PATH`
|
|
(the GUI does not inherit your shell profile).
|
|
'' // {
|
|
default = true;
|
|
};
|
|
};
|
|
};
|
|
|
|
config = lib.mkIf (root.enable && cfg.enable && cursorPkg != null) {
|
|
home.packages =
|
|
[
|
|
(if cfg.nixIde.enable && cursorWithNixIde != null then
|
|
cursorWithNixIde
|
|
else
|
|
cursorPkg)
|
|
]
|
|
++ lib.optionals (cursorCli != null) [ cursorCli ]
|
|
++ lib.optionals cfg.nixIde.enable nixIdeTools;
|
|
|
|
# Cursor's updater drops a generic-linux binary here; remove it so `cursor-agent` resolves to cursor-cli.
|
|
home.activation.removeBrokenCursorAgent = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
|
|
$DRY_RUN_CMD rm -f "$HOME/.local/bin/cursor-agent"
|
|
'';
|
|
|
|
home.sessionVariables = lib.mkIf cfg.setAsDefaultEditor {
|
|
EDITOR = "cursor --wait";
|
|
VISUAL = "cursor --wait";
|
|
};
|
|
};
|
|
};
|
|
}
|