about summary refs log tree commit diff
path: root/pkgs/by-name/me/mesonlsp/package.nix
blob: 8b525a5f57dee90069e72ce6c6132d82af32c7d5 (plain) (blame)
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
{
  lib,
  stdenv,
  fetchFromGitHub,

  gtest,
  makeWrapper,
  meson,
  ninja,
  pkg-config,
  python3,

  curl,
  libarchive,
  libossp_uuid,
  libpkgconf,
  libuuid,
  nlohmann_json,
  pkgsStatic,

  mesonlsp,
  nix-update-script,
  testers,
}:

stdenv.mkDerivation (finalAttrs: {
  pname = "mesonlsp";
  version = "4.2.2";

  src = fetchFromGitHub {
    owner = "JCWasmx86";
    repo = "mesonlsp";
    rev = "v${finalAttrs.version}";
    hash = "sha256-pN8MCqrRfVpmM8KWa7HPTghoegplM4bP/HRVJVs05iE=";
  };

  patches = [
    ./disable-tests-that-require-network-access.patch
    ./simplify-the-format-header-polyfill.patch
  ];

  nativeBuildInputs = [
    gtest
    makeWrapper
    meson
    ninja
    pkg-config
    python3
  ];

  buildInputs =
    [
      curl
      libarchive
      libpkgconf
      nlohmann_json
    ]
    ++ lib.optionals stdenv.isDarwin [
      libossp_uuid
      pkgsStatic.fmt
    ]
    ++ lib.optionals stdenv.isLinux [ libuuid ];

  mesonFlags = [ "-Dbenchmarks=false" ];

  mesonCheckFlags = [ "--print-errorlogs" ];

  doCheck = true;

  postUnpack =
    let
      ada = fetchFromGitHub {
        owner = "ada-url";
        repo = "ada";
        rev = "v2.7.4";
        hash = "sha256-V5LwL03x7/a9Lvg1gPvgGipo7IICU7xyO2D3GqP6Lbw=";
      };

      muon = fetchFromGitHub {
        owner = "JCWasmx86";
        repo = "muon";
        rev = "62af239567ec3b086bae7f02d4aed3a545949155";
        hash = "sha256-k883mKwuP35f0WtwX8ybl9uYbvA3y6Vxtv2EJMpZDEs=";
      };

      sha256 = fetchFromGitHub {
        owner = "amosnier";
        repo = "sha-2";
        rev = "49265c656f9b370da660531db8cc6bf0a2e110a6";
        hash = "sha256-X9M/ZATYXUiE4oGorPBnsdaKnKaObarnMRh6QEfkBls=";
      };

      tomlplusplus = fetchFromGitHub {
        owner = "marzer";
        repo = "tomlplusplus";
        rev = "v3.4.0";
        hash = "sha256-h5tbO0Rv2tZezY58yUbyRVpsfRjY3i+5TPkkxr6La8M=";
      };

      tree-sitter = fetchFromGitHub {
        owner = "tree-sitter";
        repo = "tree-sitter";
        rev = "v0.20.8";
        hash = "sha256-278zU5CLNOwphGBUa4cGwjBqRJ87dhHMzFirZB09gYM=";
      };

      tree-sitter-ini = fetchFromGitHub {
        owner = "JCWasmx86";
        repo = "tree-sitter-ini";
        rev = "20aa563306e9406ac55babb4474521060df90a30";
        hash = "sha256-1hHjtghBIf7lOPpupT1pUCZQCnzUi4Qt/yHSCdjMhCU=";
      };

      tree-sitter-meson = fetchFromGitHub {
        owner = "JCWasmx86";
        repo = "tree-sitter-meson";
        rev = "09665faff74548820c10d77dd8738cd76d488572";
        hash = "sha256-ice2NdK1/U3NylIQDnNCN41rK/G6uqFOX+OeNf3zm18=";
      };
    in
    ''
      (
        cd "$sourceRoot/subprojects"

        cp -R --no-preserve=mode,ownership ${ada} ada
        cp "packagefiles/ada/meson.build" ada

        cp -R --no-preserve=mode,ownership ${muon} muon

        cp -R --no-preserve=mode,ownership ${sha256} sha256
        cp "packagefiles/sha256/meson.build" sha256

        cp -R --no-preserve=mode,ownership ${tomlplusplus} tomlplusplus-3.4.0

        cp -R --no-preserve=mode,ownership ${tree-sitter} tree-sitter-0.20.8
        cp "packagefiles/tree-sitter-0.20.8/meson.build" tree-sitter-0.20.8

        cp -R --no-preserve=mode,ownership ${tree-sitter-ini} tree-sitter-ini
        cp "packagefiles/tree-sitter-ini/meson.build" tree-sitter-ini

        cp -R --no-preserve=mode,ownership ${tree-sitter-meson} tree-sitter-meson
        cp "packagefiles/tree-sitter-meson/meson.build" tree-sitter-meson
      )
    '';

  postPatch = ''
    substituteInPlace subprojects/muon/include/compilers.h \
      --replace-fail 'compiler_language new' 'compiler_language new_'

    patchShebangs src/libtypenamespace
  '';

  passthru = {
    updateScript = nix-update-script { };
    tests.version = testers.testVersion {
      package = mesonlsp;
      version = "v${finalAttrs.version}";
    };
  };

  meta = with lib; {
    description = "An unofficial, unendorsed language server for Meson written in C++";
    homepage = "https://github.com/JCWasmx86/mesonlsp";
    changelog = "https://github.com/JCWasmx86/mesonlsp/releases/tag/v${finalAttrs.version}";
    license = licenses.gpl3Plus;
    mainProgram = "mesonlsp";
    maintainers = with maintainers; [ paveloom ];
    platforms = platforms.unix;
  };
})