11 , common-updater-scripts
14 stdenvNoCC.mkDerivation rec {
18 src = passthru.sources.${stdenvNoCC.hostPlatform.system} or (throw "Unsupported system: ${stdenvNoCC.hostPlatform.system}");
21 nativeBuildInputs = [ unzip installShellFiles ] ++ lib.optionals stdenvNoCC.hostPlatform.isLinux [ autoPatchelfHook ];
22 buildInputs = [ openssl ];
30 install -Dm 755 ./bun $out/bin/bun
31 ln -s $out/bin/bun $out/bin/bunx
36 postPhases = lib.optionals (stdenvNoCC.buildPlatform.canExecute stdenvNoCC.hostPlatform) [ "postPatchelf" ];
38 completions_dir=$(mktemp -d)
40 SHELL="bash" $out/bin/bun completions $completions_dir
41 SHELL="zsh" $out/bin/bun completions $completions_dir
42 SHELL="fish" $out/bin/bun completions $completions_dir
44 installShellCompletion --name bun \
45 --bash $completions_dir/bun.completion.bash \
46 --zsh $completions_dir/_bun \
47 --fish $completions_dir/bun.fish
52 "aarch64-darwin" = fetchurl {
53 url = "https://github.com/oven-sh/bun/releases/download/bun-v${version}/bun-darwin-aarch64.zip";
54 hash = "sha256-dOQFfkxCiOFmAr11CjSdSKNpiLERkbVWawAuy8ASkJE=";
56 "aarch64-linux" = fetchurl {
57 url = "https://github.com/oven-sh/bun/releases/download/bun-v${version}/bun-linux-aarch64.zip";
58 hash = "sha256-ZuU14GvAtf1n1sA8amtZUSGp5iJ5qp/SI2wrw4Gwe/4=";
60 "x86_64-darwin" = fetchurl {
61 url = "https://github.com/oven-sh/bun/releases/download/bun-v${version}/bun-darwin-x64-baseline.zip";
62 hash = "sha256-qN8ciVHzHH8GgR89GDgfvteMV+YawMUQLiXNwYyN+wU=";
64 "x86_64-linux" = fetchurl {
65 url = "https://github.com/oven-sh/bun/releases/download/bun-v${version}/bun-linux-x64.zip";
66 hash = "sha256-zHitG4Ktt+iCKk9GrC3C4MRSWhUxh89kW9bUeHzqNJs=";
69 updateScript = writeShellScript "update-bun" ''
71 export PATH="${lib.makeBinPath [ curl jq common-updater-scripts ]}"
72 NEW_VERSION=$(curl --silent https://api.github.com/repos/oven-sh/bun/releases/latest | jq '.tag_name | ltrimstr("bun-v")' --raw-output)
73 if [[ "${version}" = "$NEW_VERSION" ]]; then
74 echo "The new version same as the old version."
77 for platform in ${lib.escapeShellArgs meta.platforms}; do
78 update-source-version "bun" "$NEW_VERSION" --ignore-same-version --source-key="sources.$platform"
83 homepage = "https://bun.sh";
84 changelog = "https://bun.sh/blog/bun-v${version}";
85 description = "Incredibly fast JavaScript runtime, bundler, transpiler and package manager – all in one";
86 sourceProvenance = with sourceTypes; [ binaryNativeCode ];
88 All in one fast & easy-to-use tool. Instead of 1,000 node_modules for development, you only need bun.
90 license = with licenses; [
92 lgpl21Only # javascriptcore and webkit
95 maintainers = with maintainers; [ DAlperin jk thilobillerbeck cdmistman coffeeispower diogomdp ];
96 platforms = builtins.attrNames passthru.sources;
97 # Broken for Musl at 2024-01-13, tracking issue:
98 # https://github.com/NixOS/nixpkgs/issues/280716
99 broken = stdenvNoCC.hostPlatform.isMusl;