diff --git a/pkgs/applications/editors/vim/plugins/non-generated/cord-nvim/default.nix b/pkgs/applications/editors/vim/plugins/non-generated/cord-nvim/default.nix index 5f0298311d5b..7b48ef9f427d 100644 --- a/pkgs/applications/editors/vim/plugins/non-generated/cord-nvim/default.nix +++ b/pkgs/applications/editors/vim/plugins/non-generated/cord-nvim/default.nix @@ -1,58 +1,57 @@ { lib, - stdenv, fetchFromGitHub, - nix-update-script, rustPlatform, + versionCheckHook, + nix-update-script, vimUtils, }: let - version = "1.0.0"; + version = "2.2.3"; src = fetchFromGitHub { owner = "vyfor"; repo = "cord.nvim"; tag = "v${version}"; - hash = "sha256-rA3R9SO3QRLGBVHlT5NZLtQw+EmkkmSDO/K6DdNtfBI="; + hash = "sha256-MhUjQxwATAGxIC8ACNDFDm249GzX4Npq3S+sHoUMuos="; }; - extension = if stdenv.hostPlatform.isDarwin then "dylib" else "so"; - cord-nvim-rust = rustPlatform.buildRustPackage { - pname = "cord.nvim-rust"; - inherit version src; + cord-server = rustPlatform.buildRustPackage { + pname = "cord"; + version = "2.2.3"; + inherit src; + + # The version in .github/server-version.txt differs from the one in Cargo.toml + postPatch = '' + substituteInPlace .github/server-version.txt \ + --replace-fail "2.0.0-beta.30" "${version}" + ''; useFetchCargoVendor = true; - cargoHash = "sha256-UJdSQNaYaZxvmfuHwePzGhQ3Pv+Cm7YaRK1L0CJhtEc="; + cargoHash = "sha256-hKt9d2u/tlD7bgo49O8oHDLljRvad9dEpGdFt+LH6Ec="; - installPhase = - let - cargoTarget = stdenv.hostPlatform.rust.cargoShortTarget; - in - '' - install -D target/${cargoTarget}/release/libcord.${extension} $out/lib/cord.${extension} - ''; + # cord depends on nightly features + RUSTC_BOOTSTRAP = 1; + + nativeInstallCheckInputs = [ + versionCheckHook + ]; + versionCheckProgramArg = "--version"; + doInstallCheck = false; + + meta.mainProgram = "cord"; }; in vimUtils.buildVimPlugin { pname = "cord.nvim"; inherit version src; - nativeBuildInputs = [ - cord-nvim-rust - ]; - - buildPhase = '' - runHook preBuild - - install -D ${cord-nvim-rust}/lib/cord.${extension} cord.${extension} - - runHook postBuild - ''; - - installPhase = '' - runHook preInstall - - install -D cord $out/lua/cord.${extension} - - runHook postInstall + # Patch the logic used to find the path to the cord server + # This still lets the user set config.advanced.server.executable_path + # https://github.com/vyfor/cord.nvim/blob/v2.2.3/lua/cord/server/fs/init.lua#L10-L15 + postPatch = '' + substituteInPlace lua/cord/server/fs/init.lua \ + --replace-fail \ + "or M.get_data_path()" \ + "'${cord-server}'" ''; passthru = { @@ -61,11 +60,13 @@ vimUtils.buildVimPlugin { }; # needed for the update script - inherit cord-nvim-rust; + inherit cord-server; }; meta = { homepage = "https://github.com/vyfor/cord.nvim"; license = lib.licenses.asl20; + changelog = "https://github.com/vyfor/cord.nvim/releases/tag/v${version}"; + maintainers = with lib.maintainers; [ GaetanLepage ]; }; }