Unverified Commit 625d3cc6 authored by Gaétan Lepage's avatar Gaétan Lepage Committed by GitHub
Browse files

vimPlugins.cord-nvim: 1.0.0 -> 2.2.3 (#394629)

parents 3e0daa11 bab2a9f5
Loading
Loading
Loading
Loading
+36 −35
Original line number Diff line number Diff line
{
  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 ];
  };
}