2022-09-22 08:17:00 +02:00
|
|
|
|
{ lib
|
|
|
|
|
, stdenvNoCC
|
|
|
|
|
, fetchurl
|
|
|
|
|
, autoPatchelfHook
|
|
|
|
|
, unzip
|
2023-09-09 05:44:48 +02:00
|
|
|
|
, installShellFiles
|
2022-09-22 08:17:00 +02:00
|
|
|
|
, openssl
|
|
|
|
|
, writeShellScript
|
|
|
|
|
, curl
|
|
|
|
|
, jq
|
|
|
|
|
, common-updater-scripts
|
|
|
|
|
}:
|
2022-07-06 04:02:41 +02:00
|
|
|
|
|
|
|
|
|
stdenvNoCC.mkDerivation rec {
|
2023-12-16 14:01:57 +01:00
|
|
|
|
version = "1.0.18";
|
2022-07-06 04:02:41 +02:00
|
|
|
|
pname = "bun";
|
|
|
|
|
|
2022-09-21 18:57:59 +02:00
|
|
|
|
src = passthru.sources.${stdenvNoCC.hostPlatform.system} or (throw "Unsupported system: ${stdenvNoCC.hostPlatform.system}");
|
2022-07-06 04:02:41 +02:00
|
|
|
|
|
|
|
|
|
strictDeps = true;
|
2023-09-09 05:44:48 +02:00
|
|
|
|
nativeBuildInputs = [ unzip installShellFiles ] ++ lib.optionals stdenvNoCC.isLinux [ autoPatchelfHook ];
|
2022-07-06 04:02:41 +02:00
|
|
|
|
buildInputs = [ openssl ];
|
|
|
|
|
|
|
|
|
|
dontConfigure = true;
|
|
|
|
|
dontBuild = true;
|
|
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
|
runHook preInstall
|
2023-08-03 09:55:36 +02:00
|
|
|
|
|
2022-07-06 04:02:41 +02:00
|
|
|
|
install -Dm 755 ./bun $out/bin/bun
|
2023-08-03 09:55:36 +02:00
|
|
|
|
ln -s $out/bin/bun $out/bin/bunx
|
|
|
|
|
|
2022-07-06 04:02:41 +02:00
|
|
|
|
runHook postInstall
|
|
|
|
|
'';
|
2023-09-09 05:44:48 +02:00
|
|
|
|
|
|
|
|
|
postPhases = [ "postPatchelf" ];
|
|
|
|
|
postPatchelf = lib.optionalString (stdenvNoCC.buildPlatform.canExecute stdenvNoCC.hostPlatform) ''
|
|
|
|
|
completions_dir=$(mktemp -d)
|
|
|
|
|
|
|
|
|
|
SHELL="bash" $out/bin/bun completions $completions_dir
|
|
|
|
|
SHELL="zsh" $out/bin/bun completions $completions_dir
|
|
|
|
|
SHELL="fish" $out/bin/bun completions $completions_dir
|
|
|
|
|
|
|
|
|
|
installShellCompletion --name bun \
|
|
|
|
|
--bash $completions_dir/bun.completion.bash \
|
|
|
|
|
--zsh $completions_dir/_bun \
|
|
|
|
|
--fish $completions_dir/bun.fish
|
|
|
|
|
'';
|
|
|
|
|
|
2022-09-21 18:57:59 +02:00
|
|
|
|
passthru = {
|
|
|
|
|
sources = {
|
|
|
|
|
"aarch64-darwin" = fetchurl {
|
|
|
|
|
url = "https://github.com/oven-sh/bun/releases/download/bun-v${version}/bun-darwin-aarch64.zip";
|
2023-12-16 14:01:57 +01:00
|
|
|
|
hash = "sha256-z3C6V8jG/et+CizWHHx6zN56JBe4QBhEKbDQgx67dmc=";
|
2022-09-21 18:57:59 +02:00
|
|
|
|
};
|
|
|
|
|
"aarch64-linux" = fetchurl {
|
|
|
|
|
url = "https://github.com/oven-sh/bun/releases/download/bun-v${version}/bun-linux-aarch64.zip";
|
2023-12-16 14:01:57 +01:00
|
|
|
|
hash = "sha256-xnFN1Kiaerot6ieMqf5fvyq826vE4KpM57r/7wz4C7o=";
|
2022-09-21 18:57:59 +02:00
|
|
|
|
};
|
|
|
|
|
"x86_64-darwin" = fetchurl {
|
|
|
|
|
url = "https://github.com/oven-sh/bun/releases/download/bun-v${version}/bun-darwin-x64.zip";
|
2023-12-16 14:01:57 +01:00
|
|
|
|
hash = "sha256-cNfTiMSdeCINchtRtAA1Lv4vVmrxwhLQNUe+96UFYp4=";
|
2022-09-21 18:57:59 +02:00
|
|
|
|
};
|
|
|
|
|
"x86_64-linux" = fetchurl {
|
|
|
|
|
url = "https://github.com/oven-sh/bun/releases/download/bun-v${version}/bun-linux-x64.zip";
|
2023-12-16 14:01:57 +01:00
|
|
|
|
hash = "sha256-qwqgaU3zYiuer4tI4JiSsZd94IO6xn+dSjJZkM70WP4=";
|
2022-09-21 18:57:59 +02: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
|
2023-09-26 08:45:30 +02:00
|
|
|
|
update-source-version "bun" "0" "${lib.fakeHash}" --source-key="sources.$platform"
|
2022-09-21 18:57:59 +02:00
|
|
|
|
update-source-version "bun" "$NEW_VERSION" --source-key="sources.$platform"
|
|
|
|
|
done
|
|
|
|
|
'';
|
|
|
|
|
};
|
2022-07-06 04:02:41 +02:00
|
|
|
|
meta = with lib; {
|
|
|
|
|
homepage = "https://bun.sh";
|
2023-09-13 05:17:25 +02:00
|
|
|
|
changelog = "https://bun.sh/blog/bun-v${version}";
|
2022-07-06 04:02:41 +02: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-09-08 16:46:09 +02:00
|
|
|
|
maintainers = with maintainers; [ DAlperin jk thilobillerbeck cdmistman coffeeispower ];
|
2022-09-21 18:57:59 +02:00
|
|
|
|
platforms = builtins.attrNames passthru.sources;
|
2022-07-06 04:02:41 +02:00
|
|
|
|
};
|
|
|
|
|
}
|