Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at fix-function-merge 101 lines 3.6 kB view raw
1{ lib 2, stdenvNoCC 3, fetchurl 4, autoPatchelfHook 5, unzip 6, installShellFiles 7, openssl 8, writeShellScript 9, curl 10, jq 11, common-updater-scripts 12}: 13 14stdenvNoCC.mkDerivation rec { 15 version = "1.1.20"; 16 pname = "bun"; 17 18 src = passthru.sources.${stdenvNoCC.hostPlatform.system} or (throw "Unsupported system: ${stdenvNoCC.hostPlatform.system}"); 19 20 strictDeps = true; 21 nativeBuildInputs = [ unzip installShellFiles ] ++ lib.optionals stdenvNoCC.isLinux [ autoPatchelfHook ]; 22 buildInputs = [ openssl ]; 23 24 dontConfigure = true; 25 dontBuild = true; 26 27 installPhase = '' 28 runHook preInstall 29 30 install -Dm 755 ./bun $out/bin/bun 31 ln -s $out/bin/bun $out/bin/bunx 32 33 runHook postInstall 34 ''; 35 36 postPhases = [ "postPatchelf" ]; 37 postPatchelf = lib.optionalString (stdenvNoCC.buildPlatform.canExecute stdenvNoCC.hostPlatform) '' 38 completions_dir=$(mktemp -d) 39 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 43 44 installShellCompletion --name bun \ 45 --bash $completions_dir/bun.completion.bash \ 46 --zsh $completions_dir/_bun \ 47 --fish $completions_dir/bun.fish 48 ''; 49 50 passthru = { 51 sources = { 52 "aarch64-darwin" = fetchurl { 53 url = "https://github.com/oven-sh/bun/releases/download/bun-v${version}/bun-darwin-aarch64.zip"; 54 hash = "sha256-ErutjiXBjC9GDvb0F39AgbbsSo6zhRzpDEvDor/xRbI="; 55 }; 56 "aarch64-linux" = fetchurl { 57 url = "https://github.com/oven-sh/bun/releases/download/bun-v${version}/bun-linux-aarch64.zip"; 58 hash = "sha256-vqL/H5t0elgT9fSk0Op7Td69eP9WPY2XVo1a8sraTwM="; 59 }; 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-5PLk8q3di5TW8HUfo7P3xrPWLhleAiSv9jp2XeL47Kk="; 63 }; 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-bLcK0DSaLOzJSrIRPNHQeld5qud8ccqxzyDIgawMB3U="; 67 }; 68 }; 69 updateScript = writeShellScript "update-bun" '' 70 set -o errexit 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." 75 exit 0 76 fi 77 for platform in ${lib.escapeShellArgs meta.platforms}; do 78 update-source-version "bun" "$NEW_VERSION" --ignore-same-version --source-key="sources.$platform" 79 done 80 ''; 81 }; 82 meta = with lib; { 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 ]; 87 longDescription = '' 88 All in one fast & easy-to-use tool. Instead of 1,000 node_modules for development, you only need bun. 89 ''; 90 license = with licenses; [ 91 mit # bun core 92 lgpl21Only # javascriptcore and webkit 93 ]; 94 mainProgram = "bun"; 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; 100 }; 101}