nixpkgs/pkgs/development/web/bun/default.nix
2022-12-09 10:18:53 +00:00

81 lines
2.8 KiB
Nix
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{ lib
, stdenvNoCC
, callPackage
, fetchurl
, autoPatchelfHook
, unzip
, openssl
, writeShellScript
, curl
, jq
, common-updater-scripts
}:
stdenvNoCC.mkDerivation rec {
version = "0.3.0";
pname = "bun";
src = passthru.sources.${stdenvNoCC.hostPlatform.system} or (throw "Unsupported system: ${stdenvNoCC.hostPlatform.system}");
strictDeps = true;
nativeBuildInputs = [ unzip ] ++ lib.optionals stdenvNoCC.isLinux [ autoPatchelfHook ];
buildInputs = [ openssl ];
dontConfigure = true;
dontBuild = true;
installPhase = ''
runHook preInstall
install -Dm 755 ./bun $out/bin/bun
runHook postInstall
'';
passthru = {
sources = {
"aarch64-darwin" = fetchurl {
url = "https://github.com/oven-sh/bun/releases/download/bun-v${version}/bun-darwin-aarch64.zip";
sha256 = "CPoSo8Kqu87c0bF4J2KSoamz6bsfS/DnkYqRi+XL8Qw=";
};
"aarch64-linux" = fetchurl {
url = "https://github.com/oven-sh/bun/releases/download/bun-v${version}/bun-linux-aarch64.zip";
sha256 = "0ymZ4cYJn3Qth4jiTeXuAAsY0wFrYO2OHumY5WLamME=";
};
"x86_64-darwin" = fetchurl {
url = "https://github.com/oven-sh/bun/releases/download/bun-v${version}/bun-darwin-x64.zip";
sha256 = "8f5w+wu1vId0R7UQsdbi/yopw1R00lR9ibEAOYwUglI=";
};
"x86_64-linux" = fetchurl {
url = "https://github.com/oven-sh/bun/releases/download/bun-v${version}/bun-linux-x64.zip";
sha256 = "bnuz+n8pAhBUgQKImCUKRZCwIqGHHaB3KtZOVfqy4Zw=";
};
};
updateScript = writeShellScript "update-bun" ''
set -o errexit
export PATH="${lib.makeBinPath [ curl jq common-updater-scripts ]}"
NEW_VERSION=$(curl --silent https://api.github.com/repos/oven-sh/bun/releases/latest | jq '.tag_name | ltrimstr("bun-v")' --raw-output)
if [[ "${version}" = "$NEW_VERSION" ]]; then
echo "The new version same as the old version."
exit 0
fi
for platform in ${lib.escapeShellArgs meta.platforms}; do
update-source-version "bun" "0" "${lib.fakeSha256}" --source-key="sources.$platform"
update-source-version "bun" "$NEW_VERSION" --source-key="sources.$platform"
done
'';
};
meta = with lib; {
homepage = "https://bun.sh";
changelog = "https://github.com/Jarred-Sumner/bun/releases/tag/bun-v${version}";
description = "Incredibly fast JavaScript runtime, bundler, transpiler and package manager all in one";
sourceProvenance = with sourceTypes; [ binaryNativeCode ];
longDescription = ''
All in one fast & easy-to-use tool. Instead of 1,000 node_modules for development, you only need bun.
'';
license = with licenses; [
mit # bun core
lgpl21Only # javascriptcore and webkit
];
maintainers = with maintainers; [ DAlperin jk ];
platforms = builtins.attrNames passthru.sources;
};
}