Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 48 additions & 35 deletions pkgs/development/web/bun/default.nix
Original file line number Diff line number Diff line change
@@ -1,40 +1,21 @@
{ stdenvNoCC, callPackage, fetchurl, autoPatchelfHook, unzip, openssl, lib }:
let
dists = {
aarch64-darwin = {
arch = "aarch64";
shortName = "darwin";
sha256 = "sha256-R17Ga4C6PSxfL1bz6IBjx0dYFmX93i0y8uqxG1eZKd4=";
};

aarch64-linux = {
arch = "aarch64";
shortName = "linux";
sha256 = "sha256-KSC4gdsJZJoPjMEs+VigVuqlUDhg4sL054WRlAbB+eA=";
};
{ lib
, stdenvNoCC
, callPackage
, fetchurl
, autoPatchelfHook
, unzip
, openssl
, writeShellScript
, curl
, jq
, common-updater-scripts
}:

x86_64-darwin = {
arch = "x64";
shortName = "darwin";
sha256 = "sha256-CVqFPvZScNTudE2wgUctwGDgTyaMeN8dUNmLatcKo5M=";
};

x86_64-linux = {
arch = "x64";
shortName = "linux";
sha256 = "sha256-N3hGPyp9wvb7jjpaFLJcdNIRyLvegjAe+MiV2aMS1nE=";
};
};
dist = dists.${stdenvNoCC.hostPlatform.system} or (throw "Unsupported system: ${stdenvNoCC.hostPlatform.system}");
in
stdenvNoCC.mkDerivation rec {
version = "0.1.11";
version = "0.1.13";
pname = "bun";

src = fetchurl {
url = "https://github.com/Jarred-Sumner/bun-releases-for-updater/releases/download/bun-v${version}/bun-${dist.shortName}-${dist.arch}.zip";
sha256 = dist.sha256;
};
src = passthru.sources.${stdenvNoCC.hostPlatform.system} or (throw "Unsupported system: ${stdenvNoCC.hostPlatform.system}");

strictDeps = true;
nativeBuildInputs = [ unzip ] ++ lib.optionals stdenvNoCC.isLinux [ autoPatchelfHook ];
Expand All @@ -48,7 +29,39 @@ stdenvNoCC.mkDerivation rec {
install -Dm 755 ./bun $out/bin/bun
runHook postInstall
'';

passthru = {
sources = {
"aarch64-darwin" = fetchurl {
url = "https://github.com/oven-sh/bun/releases/download/bun-v${version}/bun-darwin-aarch64.zip";
sha256 = "RYTRcc8xccRmxuKOXwX3bBWJSXLI2/XfH4/7ZdcUBdE=";
};
"aarch64-linux" = fetchurl {
url = "https://github.com/oven-sh/bun/releases/download/bun-v${version}/bun-linux-aarch64.zip";
sha256 = "LixLrzSsgbXyfpFKiksM4zNS5iDU3tXOrr7fP8yJknM=";
};
"x86_64-darwin" = fetchurl {
url = "https://github.com/oven-sh/bun/releases/download/bun-v${version}/bun-darwin-x64.zip";
sha256 = "SGZcT2uVy6egr99FzyaykUWLuZBqDsvbCM/lsgy//g0=";
};
"x86_64-linux" = fetchurl {
url = "https://github.com/oven-sh/bun/releases/download/bun-v${version}/bun-linux-x64.zip";
sha256 = "ssZtJi+CEVn7MjPMqFkwv1lnwE7a7ttkmiuoT0Y6wao=";
};
};
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
'';
};
meta = with lib; {
homepage = "https://bun.sh";
changelog = "https://github.com/Jarred-Sumner/bun/releases/tag/bun-v${version}";
Expand All @@ -62,6 +75,6 @@ stdenvNoCC.mkDerivation rec {
lgpl21Only # javascriptcore and webkit
];
maintainers = with maintainers; [ DAlperin jk ];
platforms = builtins.attrNames dists;
platforms = builtins.attrNames passthru.sources;
};
}