diff --git a/pkgs/by-name/st/starpls-bin/package.nix b/pkgs/by-name/st/starpls-bin/package.nix deleted file mode 100644 index 98ae3ffa31c5..000000000000 --- a/pkgs/by-name/st/starpls-bin/package.nix +++ /dev/null @@ -1,43 +0,0 @@ -{ lib, stdenv, fetchurl, autoPatchelfHook }: - -stdenv.mkDerivation (finalAttrs: { - pname = "starpls-bin"; - version = "0.1.14"; - - 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}"); - - dontUnpack = true; - dontConfigure = true; - dontBuild = true; - - nativeBuildInputs = lib.optionals stdenv.hostPlatform.isElf [ - autoPatchelfHook - ]; - - buildInputs = lib.optionals stdenv.hostPlatform.isElf [ - (lib.getLib stdenv.cc.cc) - ]; - - installPhase = '' - install -D $src $out/bin/starpls - ''; - - meta = with lib; { - 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 ]; - mainProgram = "starpls"; - sourceProvenance = [ lib.sourceTypes.binaryNativeCode ]; - }; -}) diff --git a/pkgs/by-name/st/starpls/manifest.json b/pkgs/by-name/st/starpls/manifest.json new file mode 100644 index 000000000000..99de0529906f --- /dev/null +++ b/pkgs/by-name/st/starpls/manifest.json @@ -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=" + } + } +} diff --git a/pkgs/by-name/st/starpls/package.nix b/pkgs/by-name/st/starpls/package.nix new file mode 100644 index 000000000000..7cbe984d31c7 --- /dev/null +++ b/pkgs/by-name/st/starpls/package.nix @@ -0,0 +1,57 @@ +{ + lib, + stdenv, + fetchurl, + autoPatchelfHook, + testers, + starpls, +}: + +let + manifest = lib.importJSON ./manifest.json; +in +stdenv.mkDerivation (finalAttrs: { + pname = "starpls"; + version = manifest.version; + + src = + let + system = stdenv.hostPlatform.system; + in + fetchurl (manifest.assets.${system} or (throw "Unsupported system: ${system}")); + + dontUnpack = true; + dontConfigure = true; + dontBuild = true; + + nativeBuildInputs = lib.optionals stdenv.hostPlatform.isElf [ + autoPatchelfHook + ]; + + buildInputs = lib.optionals stdenv.hostPlatform.isElf [ + (lib.getLib stdenv.cc.cc) + ]; + + installPhase = '' + install -D $src $out/bin/starpls + ''; + + passthru = { + tests.version = testers.testVersion { + package = starpls; + 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; + maintainers = with lib.maintainers; [ aaronjheng ]; + sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ]; + mainProgram = "starpls"; + }; +}) diff --git a/pkgs/by-name/st/starpls/update.py b/pkgs/by-name/st/starpls/update.py new file mode 100755 index 000000000000..c019a893d189 --- /dev/null +++ b/pkgs/by-name/st/starpls/update.py @@ -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" + ) diff --git a/pkgs/top-level/aliases.nix b/pkgs/top-level/aliases.nix index bce5bec825c7..5173b3dc0dda 100644 --- a/pkgs/top-level/aliases.nix +++ b/pkgs/top-level/aliases.nix @@ -1147,6 +1147,7 @@ mapAliases { sqldeveloper = throw "sqldeveloper was dropped due to being severely out-of-date and having a dependency on JavaFX for Java 8, which we do not support"; # Added 2024-11-02 srvc = throw "'srvc' has been removed, as it was broken and unmaintained"; # Added 2024-09-09 ssm-agent = amazon-ssm-agent; # Added 2023-10-17 + starpls-bin = starpls; starspace = throw "starspace has been removed from nixpkgs, as it was broken"; # Added 2024-07-15 steamPackages = { steamArch = throw "`steamPackages.steamArch` has been removed as it's no longer applicable";