2022-09-30 11:47:45 +00:00
|
|
|
|
{ lib
|
|
|
|
|
, stdenvNoCC
|
|
|
|
|
, fetchurl
|
|
|
|
|
, autoPatchelfHook
|
|
|
|
|
, unzip
|
|
|
|
|
, openssl
|
|
|
|
|
, writeShellScript
|
|
|
|
|
, curl
|
|
|
|
|
, jq
|
|
|
|
|
, common-updater-scripts
|
|
|
|
|
}:
|
2022-07-14 12:49:19 +00:00
|
|
|
|
|
|
|
|
|
stdenvNoCC.mkDerivation rec {
|
2023-08-22 20:05:09 +00:00
|
|
|
|
version = "0.7.3";
|
2022-07-14 12:49:19 +00:00
|
|
|
|
pname = "bun";
|
|
|
|
|
|
2022-09-30 11:47:45 +00:00
|
|
|
|
src = passthru.sources.${stdenvNoCC.hostPlatform.system} or (throw "Unsupported system: ${stdenvNoCC.hostPlatform.system}");
|
2022-07-14 12:49:19 +00:00
|
|
|
|
|
|
|
|
|
strictDeps = true;
|
|
|
|
|
nativeBuildInputs = [ unzip ] ++ lib.optionals stdenvNoCC.isLinux [ autoPatchelfHook ];
|
|
|
|
|
buildInputs = [ openssl ];
|
|
|
|
|
|
|
|
|
|
dontConfigure = true;
|
|
|
|
|
dontBuild = true;
|
|
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
|
runHook preInstall
|
2023-08-10 07:59:29 +00:00
|
|
|
|
|
2022-07-14 12:49:19 +00:00
|
|
|
|
install -Dm 755 ./bun $out/bin/bun
|
2023-08-10 07:59:29 +00:00
|
|
|
|
ln -s $out/bin/bun $out/bin/bunx
|
|
|
|
|
|
2022-07-14 12:49:19 +00:00
|
|
|
|
runHook postInstall
|
|
|
|
|
'';
|
2022-09-30 11:47:45 +00:00
|
|
|
|
passthru = {
|
|
|
|
|
sources = {
|
|
|
|
|
"aarch64-darwin" = fetchurl {
|
|
|
|
|
url = "https://github.com/oven-sh/bun/releases/download/bun-v${version}/bun-darwin-aarch64.zip";
|
2023-08-22 20:05:09 +00:00
|
|
|
|
hash = "sha256-9gs5PIbYxhhUC+lw/iEIhjdMIUYVnhP7oYrRqmE3HcU=";
|
2022-09-30 11:47:45 +00:00
|
|
|
|
};
|
|
|
|
|
"aarch64-linux" = fetchurl {
|
|
|
|
|
url = "https://github.com/oven-sh/bun/releases/download/bun-v${version}/bun-linux-aarch64.zip";
|
2023-08-22 20:05:09 +00:00
|
|
|
|
hash = "sha256-CFio1bgsgND54BrklkCVjfDvMDFxpYe1h77nGMOJdsc=";
|
2022-09-30 11:47:45 +00:00
|
|
|
|
};
|
|
|
|
|
"x86_64-darwin" = fetchurl {
|
|
|
|
|
url = "https://github.com/oven-sh/bun/releases/download/bun-v${version}/bun-darwin-x64.zip";
|
2023-08-22 20:05:09 +00:00
|
|
|
|
hash = "sha256-j6NpHAqSBRe2Wa4ztA1Ao4JYTKTEIwlYMCMMICKqZv0=";
|
2022-09-30 11:47:45 +00:00
|
|
|
|
};
|
|
|
|
|
"x86_64-linux" = fetchurl {
|
|
|
|
|
url = "https://github.com/oven-sh/bun/releases/download/bun-v${version}/bun-linux-x64.zip";
|
2023-08-22 20:05:09 +00:00
|
|
|
|
hash = "sha256-05Duhv2WrYXWS6mKI3zB5QiIlitsysXwmuy+9XHBB9M=";
|
2022-09-30 11:47:45 +00:00
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
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
|
|
|
|
|
'';
|
|
|
|
|
};
|
2022-07-14 12:49:19 +00:00
|
|
|
|
meta = with lib; {
|
|
|
|
|
homepage = "https://bun.sh";
|
2023-08-04 22:07:22 +00:00
|
|
|
|
changelog = "https://bun.sh/blog/bun-v${version}";
|
2022-07-14 12:49:19 +00:00
|
|
|
|
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
|
|
|
|
|
];
|
2023-08-04 22:07:22 +00:00
|
|
|
|
maintainers = with maintainers; [ DAlperin jk thilobillerbeck cdmistman ];
|
2022-09-30 11:47:45 +00:00
|
|
|
|
platforms = builtins.attrNames passthru.sources;
|
2022-07-14 12:49:19 +00:00
|
|
|
|
};
|
|
|
|
|
}
|