starpls-bin: 0.1.14 -> 0.1.15

This commit is contained in:
Aaron Jheng 2024-10-19 07:02:04 +00:00
parent b075b4ea42
commit f7e6035cfe
No known key found for this signature in database
GPG Key ID: F6A547A869D050A3
3 changed files with 114 additions and 17 deletions

View File

@ -0,0 +1,17 @@
{
"version": "0.1.15",
"assets": {
"x86_64-linux": {
"url": "https://github.com/withered-magic/starpls/releases/download/v0.1.15/starpls-linux-amd64",
"hash": "sha256-6rLYCRg7K36xKxW0nI86w6u1MjAPGTtJQbY5HCSukTE="
},
"aarch64-linux": {
"url": "https://github.com/withered-magic/starpls/releases/download/v0.1.15/starpls-linux-aarch64",
"hash": "sha256-sHyPcaBlhZrepfnVGE5CxvZZOrBMT0qDP9hHj78CXJQ="
},
"aarch64-darwin": {
"url": "https://github.com/withered-magic/starpls/releases/download/v0.1.15/starpls-darwin-arm64",
"hash": "sha256-Q8U+Vagwb9F63N5UA8sAOd+tfCvyZMdtAmZcNgtwiSo="
}
}
}

View File

@ -1,19 +1,24 @@
{ lib, stdenv, fetchurl, autoPatchelfHook }:
{
lib,
stdenv,
fetchurl,
autoPatchelfHook,
testers,
starpls-bin,
}:
let
manifest = lib.importJSON ./manifest.json;
in
stdenv.mkDerivation (finalAttrs: {
pname = "starpls-bin";
version = "0.1.14";
version = manifest.version;
src = {
x86_64-linux = fetchurl {
url = "https://github.com/withered-magic/starpls/releases/download/v${finalAttrs.version}/starpls-linux-amd64";
hash = "sha256-PYU+Jv3uaJqJKw6zSNOPl+NlIQgfm38cOrRqTdNXY+8=";
};
aarch64-darwin = fetchurl {
url = "https://github.com/withered-magic/starpls/releases/download/v${finalAttrs.version}/starpls-darwin-arm64";
hash = "sha256-9d1ybebguEUJu2PvMcToQEd8M4ajRrQUvBZqS6o0sbw=";
};
}.${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}");
src =
let
system = stdenv.hostPlatform.system;
in
fetchurl (manifest.assets.${system} or (throw "Unsupported system: ${system}"));
dontUnpack = true;
dontConfigure = true;
@ -31,12 +36,22 @@ stdenv.mkDerivation (finalAttrs: {
install -D $src $out/bin/starpls
'';
meta = with lib; {
passthru = {
tests.version = testers.testVersion {
package = starpls-bin;
command = "starpls version";
version = "v${finalAttrs.version}";
};
updateScript = ./update.py;
};
meta = {
description = "Language server for Starlark";
homepage = "https://github.com/withered-magic/starpls";
description = "A language server for Starlark";
license = licenses.asl20;
platforms = [ "aarch64-darwin" "x86_64-linux" ];
maintainers = with maintainers; [ aaronjheng ];
license = lib.licenses.asl20;
platforms = builtins.attrNames manifest.assets;
maintainers = with lib.maintainers; [ aaronjheng ];
sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
mainProgram = "starpls";
sourceProvenance = [ lib.sourceTypes.binaryNativeCode ];
};

View File

@ -0,0 +1,65 @@
#!/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",
"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"
)