Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ lib 2, stdenvNoCC 3, callPackage 4, fetchurl 5, autoPatchelfHook 6, unzip 7, openssl 8, writeShellScript 9, curl 10, jq 11, common-updater-scripts 12}: 13 14stdenvNoCC.mkDerivation rec { 15 version = "0.6.6"; 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 ] ++ lib.optionals stdenvNoCC.isLinux [ autoPatchelfHook ]; 22 buildInputs = [ openssl ]; 23 24 dontConfigure = true; 25 dontBuild = true; 26 27 installPhase = '' 28 runHook preInstall 29 install -Dm 755 ./bun $out/bin/bun 30 runHook postInstall 31 ''; 32 passthru = { 33 sources = { 34 "aarch64-darwin" = fetchurl { 35 url = "https://github.com/oven-sh/bun/releases/download/bun-v${version}/bun-darwin-aarch64.zip"; 36 sha256 = "7nOxN+DMGytkmT/VhC//r/endE4tT7qktwr1hoBAWXg="; 37 }; 38 "aarch64-linux" = fetchurl { 39 url = "https://github.com/oven-sh/bun/releases/download/bun-v${version}/bun-linux-aarch64.zip"; 40 sha256 = "kqAe6ZgUcHMzxYOYdO5sLbuJzRqHGjFizkTxkfGr1ho="; 41 }; 42 "x86_64-darwin" = fetchurl { 43 url = "https://github.com/oven-sh/bun/releases/download/bun-v${version}/bun-darwin-x64.zip"; 44 sha256 = "UDJyOhS4Q0U7u8JW1kbrZ29zGlPyE2UH17ZBis2SOFQ="; 45 }; 46 "x86_64-linux" = fetchurl { 47 url = "https://github.com/oven-sh/bun/releases/download/bun-v${version}/bun-linux-x64.zip"; 48 sha256 = "oYSYmmYOKF4XYbdpXZnOgVBjyU3L7LRTjSG+RfU+I5w="; 49 }; 50 }; 51 updateScript = writeShellScript "update-bun" '' 52 set -o errexit 53 export PATH="${lib.makeBinPath [ curl jq common-updater-scripts ]}" 54 NEW_VERSION=$(curl --silent https://api.github.com/repos/oven-sh/bun/releases/latest | jq '.tag_name | ltrimstr("bun-v")' --raw-output) 55 if [[ "${version}" = "$NEW_VERSION" ]]; then 56 echo "The new version same as the old version." 57 exit 0 58 fi 59 for platform in ${lib.escapeShellArgs meta.platforms}; do 60 update-source-version "bun" "0" "${lib.fakeSha256}" --source-key="sources.$platform" 61 update-source-version "bun" "$NEW_VERSION" --source-key="sources.$platform" 62 done 63 ''; 64 }; 65 meta = with lib; { 66 homepage = "https://bun.sh"; 67 changelog = "https://github.com/Jarred-Sumner/bun/releases/tag/bun-v${version}"; 68 description = "Incredibly fast JavaScript runtime, bundler, transpiler and package manager all in one"; 69 sourceProvenance = with sourceTypes; [ binaryNativeCode ]; 70 longDescription = '' 71 All in one fast & easy-to-use tool. Instead of 1,000 node_modules for development, you only need bun. 72 ''; 73 license = with licenses; [ 74 mit # bun core 75 lgpl21Only # javascriptcore and webkit 76 ]; 77 maintainers = with maintainers; [ DAlperin jk thilobillerbeck ]; 78 platforms = builtins.attrNames passthru.sources; 79 }; 80}