phpantom-lsp: init at 0.7.0

This commit is contained in:
nanoyaki
2026-05-14 19:39:13 +02:00
parent 5ac0a36fcc
commit 0b46bb1b0a
2 changed files with 85 additions and 0 deletions
+67
View File
@@ -0,0 +1,67 @@
{
lib,
rustPlatform,
fetchFromGitHub,
versionCheckHook,
_experimental-update-script-combinators,
nix-update-script,
}:
let
stubsSrc = fetchFromGitHub {
owner = "JetBrains";
repo = "phpstorm-stubs";
rev = "3327932472f512d2eb9e122b19702b335083fd9d";
hash = "sha256-WN5DAvaw4FfHBl2AqSo1OcEthUm3lOpikdB78qy3cyY=";
};
in
rustPlatform.buildRustPackage (finalAttrs: {
pname = "phpantom-lsp";
version = "0.7.0";
__structuredAttrs = true;
src = fetchFromGitHub {
owner = "AJenbo";
repo = "phpantom_lsp";
tag = finalAttrs.version;
hash = "sha256-ZmtOdoxXkwn2IDg7RyQ9KG0RNz5mrGDMcESfcOSR3Ig=";
};
postPatch = ''
mkdir -p stubs/jetbrains
cp -a ${finalAttrs.passthru.stubsSrc} stubs/jetbrains/phpstorm-stubs
chmod u+wx stubs/jetbrains/phpstorm-stubs
echo "${finalAttrs.passthru.stubsSrc.rev}" \
> stubs/jetbrains/phpstorm-stubs/.commit
'';
cargoHash = "sha256-pXP4qItYgmUXVx9XwMdS6WLVc5lP7P4VX9+0TbhYrUc=";
checkFlags = [
"--test"
"completion_inheritance"
];
nativeInstallCheckInputs = [ versionCheckHook ];
doInstallCheck = true;
passthru = {
inherit stubsSrc;
updateScript = _experimental-update-script-combinators.sequence [
(nix-update-script { })
./update-php-stubs.sh
];
};
meta = {
changelog = "https://github.com/AJenbo/phpantom_lsp/releases/tag/${finalAttrs.src.tag}";
description = "Fast, lightweight PHP language server written in Rust";
homepage = "https://github.com/AJenbo/phpantom_lsp";
license = lib.licenses.mit;
mainProgram = "phpantom_lsp";
maintainers = with lib.maintainers; [ nanoyaki ];
};
})
+18
View File
@@ -0,0 +1,18 @@
#! /usr/bin/env nix-shell
#! nix-shell -i bash -p bash curl gnused gnugrep nix-prefetch-github jq
file="./pkgs/by-name/ph/phpantom-lsp/package.nix"
version="$(grep -oP 'version = "\K[\d\.]+' "$file")"
curl -O "https://raw.githubusercontent.com/AJenbo/phpantom_lsp/refs/tags/$version/stubs.lock"
stubsVersion="$(grep -oP 'commit = "\K[^"]+' ./stubs.lock)"
rm stubs.lock
stubsHash="$(
nix-prefetch-github --rev "$stubsVersion" "JetBrains" "phpstorm-stubs" --json \
2> /dev/null \
| jq -r '.hash'
)"
sed -i 's/\(rev = "\)[^"]*/\1'"$stubsVersion"'/' "$file"
sed -i '/stubsSrc/,/}/ s#\(hash = "\)[^"]*#\1'"$stubsHash"'#' "$file"