starpls: 0.1.21 -> 0.1.21 built from source (#429706)

This commit is contained in:
Morgan Jones 2025-08-08 19:18:40 +00:00 committed by GitHub
commit 2cbe754f69
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 21 additions and 118 deletions

View File

@ -1,21 +0,0 @@
{
"version": "0.1.21",
"assets": {
"x86_64-linux": {
"url": "https://github.com/withered-magic/starpls/releases/download/v0.1.21/starpls-linux-amd64",
"hash": "sha256-RWkuy52UoZoVseeyQKzf9XAveM0iGI2sQeGHnLi9zc8="
},
"aarch64-linux": {
"url": "https://github.com/withered-magic/starpls/releases/download/v0.1.21/starpls-linux-aarch64",
"hash": "sha256-SIyHNl0O4HrNtA3561Np4ROtfZbA+OwS/qjIDp4S54E="
},
"x86_64-darwin": {
"url": "https://github.com/withered-magic/starpls/releases/download/v0.1.21/starpls-darwin-amd64",
"hash": "sha256-cfAITd3t1Z9EUbgf6jyMl9xRpIUpKTN4C+zJL315AjQ="
},
"aarch64-darwin": {
"url": "https://github.com/withered-magic/starpls/releases/download/v0.1.21/starpls-darwin-arm64",
"hash": "sha256-gtcb9sFQOKHGQtzVsm0iUCcoMA5B9ZrwZDzQdiXhakc="
}
}
}

View File

@ -1,57 +1,47 @@
{
rustPlatform,
lib,
stdenv,
fetchurl,
autoPatchelfHook,
testers,
starpls,
fetchFromGitHub,
protobuf,
}:
let
manifest = lib.importJSON ./manifest.json;
in
stdenv.mkDerivation (finalAttrs: {
rustPlatform.buildRustPackage (finalAttrs: {
pname = "starpls";
version = manifest.version;
version = "0.1.21";
src =
let
system = stdenv.hostPlatform.system;
in
fetchurl (manifest.assets.${system} or (throw "Unsupported system: ${system}"));
src = fetchFromGitHub {
owner = "withered-magic";
repo = "starpls";
# https://github.com/withered-magic/starpls/commit/96ef5d0548748745756c421960e0ebb5cfbef963
rev = "96ef5d0548748745756c421960e0ebb5cfbef963";
hash = "sha256-PymdSITGeSxKwcLnsJPKc73E8VDS8SSRBRRNQSKvnbU=";
};
dontUnpack = true;
dontConfigure = true;
dontBuild = true;
cargoHash = "sha256-yovv8ox7TtSOxGW+YKYr/ED4cq7P7T7vSqoXBFhFGb4=";
nativeBuildInputs = lib.optionals stdenv.hostPlatform.isElf [
autoPatchelfHook
nativeBuildInputs = [
protobuf
];
buildInputs = lib.optionals stdenv.hostPlatform.isElf [
(lib.getLib stdenv.cc.cc)
];
installPhase = ''
install -D $src $out/bin/starpls
'';
# The tests assume Bazel build and environment variables set like
# RUNFILES_DIR which don't have an equivalent in Cargo.
doCheck = false;
passthru = {
tests.version = testers.testVersion {
package = starpls;
package = finalAttrs.finalPackage;
command = "starpls version";
version = "v${finalAttrs.version}";
};
updateScript = ./update.py;
};
meta = {
description = "Language server for Starlark";
homepage = "https://github.com/withered-magic/starpls";
license = lib.licenses.asl20;
platforms = builtins.attrNames manifest.assets;
platforms = lib.platforms.all;
maintainers = with lib.maintainers; [ aaronjheng ];
sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
sourceProvenance = with lib.sourceTypes; [ fromSource ];
mainProgram = "starpls";
};
})

View File

@ -1,66 +0,0 @@
#!/usr/bin/env nix-shell
#! nix-shell -i python -p "python3.withPackages (ps: with ps; [ ps.httpx ps.socksio ])"
import json
import os
import pathlib
import subprocess
import httpx
platforms = {
"x86_64-linux": "linux-amd64",
"aarch64-linux": "linux-aarch64",
"x86_64-darwin": "darwin-amd64",
"aarch64-darwin": "darwin-arm64",
}
if __name__ == "__main__":
headers = {}
token = os.getenv("GITHUB_TOKEN")
if token is not None:
headers["Authorization"] = "Bearer {}".format(token)
resp = httpx.get(
"https://api.github.com/repos/withered-magic/starpls/releases/latest",
headers=headers,
)
latest_release = resp.json().get("tag_name")
version = latest_release.removeprefix("v")
assets = {
"version": version,
"assets": {},
}
for k, v in platforms.items():
url = "https://github.com/withered-magic/starpls/releases/download/v{}/starpls-{}".format(
version, v
)
process = subprocess.run(
["nix-prefetch-url", "--type", "sha256", url],
capture_output=True,
text=True,
)
process.check_returncode()
process = subprocess.run(
["nix-hash", "--type", "sha256", "--to-sri", process.stdout.rstrip()],
capture_output=True,
text=True,
)
process.check_returncode()
hash = process.stdout.rstrip()
assets["assets"][k] = {
"url": url,
"hash": hash,
}
(pathlib.Path(__file__).parent / "manifest.json").write_text(
json.dumps(assets, indent=2) + "\n"
)