nixpkgs/pkgs/by-name/me/mesonlsp/package.nix
Artturin e0464e4788 treewide: replace stdenv.is with stdenv.hostPlatform.is
In preparation for the deprecation of `stdenv.isX`.

These shorthands are not conducive to cross-compilation because they
hide the platforms.

Darwin might get cross-compilation for which the continued usage of `stdenv.isDarwin` will get in the way

One example of why this is bad and especially affects compiler packages
https://www.github.com/NixOS/nixpkgs/pull/343059

There are too many files to go through manually but a treewide should
get users thinking when they see a `hostPlatform.isX` in a place where it
doesn't make sense.

```
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv.is" "stdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv'.is" "stdenv'.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "clangStdenv.is" "clangStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "gccStdenv.is" "gccStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenvNoCC.is" "stdenvNoCC.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "inherit (stdenv) is" "inherit (stdenv.hostPlatform) is"
fd --type f "\.nix" | xargs sd --fixed-strings "buildStdenv.is" "buildStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "effectiveStdenv.is" "effectiveStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "originalStdenv.is" "originalStdenv.hostPlatform.is"
```
2024-09-25 00:04:37 +03:00

168 lines
4.2 KiB
Nix

{
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.3.5";
src = fetchFromGitHub {
owner = "JCWasmx86";
repo = "mesonlsp";
rev = "v${finalAttrs.version}";
hash = "sha256-E2XKnvARq45AjAc0iBVyb2ssNyJOUye4MWOofZV2ahs=";
};
patches = [ ./disable-tests-that-require-network-access.patch ];
nativeBuildInputs = [
gtest
makeWrapper
meson
ninja
pkg-config
python3
];
buildInputs =
[
curl
libarchive
libpkgconf
nlohmann_json
]
++ lib.optionals stdenv.hostPlatform.isDarwin [
libossp_uuid
pkgsStatic.fmt
]
++ lib.optionals stdenv.hostPlatform.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;
};
})