summaryrefslogtreecommitdiffstats
path: root/flake/pkgs/by-name/cord-nvim/package.nix
blob: f1030267246135a44557aa33d7cbe5386c7fa87e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
{
  lib,
  pins,
  fetchFromGitHub,
  rustPlatform,
  stdenv,
  vimUtils,
}: let
  pin = pins.cord-nvim;

  pname = "cord";
  version = pin.revision;
  src = fetchFromGitHub {
    inherit (pin.repository) owner repo;
    rev = pin.revision;
    sha256 = pin.hash;
  };

  cord-server = rustPlatform.buildRustPackage {
    inherit pname version src;

    postPatch = ''
      substituteInPlace .github/server-version.txt \
        --replace-fail "2.3.13" "${version}"
    '';

    cargoHash = "sha256-3/qY+KS6TPyj9IwG2Ade2psqyQX1eTXU/CmxN9j4CyI=";

    doCheck = false;

    env.RUSTFLAGS = lib.optionalString stdenv.hostPlatform.isDarwin "-C link-arg=-undefined -C link-arg=dynamic_lookup";

    meta.mainProgram = "cord";
  };
in
  vimUtils.buildVimPlugin {
    pname = "cord-nvim";
    inherit version src;

    doCheck = false;

    postPatch = ''
      substituteInPlace lua/cord/server/fs/init.lua \
        --replace-fail "or M.get_data_path()" "or '${cord-server}'"

      substituteInPlace lua/cord/api/config/init.lua \
        --replace-fail "update = 'fetch'," "update = 'none'," \
        --replace-fail "auto_update = true," "auto_update = false,"
    '';

    meta = {
      description = "Discord rich presence plugin for Neovim";
      homepage = "https://github.com/vyfor/cord.nvim";
      license = lib.licenses.asl20;
    };
  }