fix(nix): use the required Bun version for builds (#12592)

This commit is contained in:
Whitebeard
2026-07-28 17:05:59 +05:30
committed by GitHub
parent fb5f5ae31b
commit 8c88048781
3 changed files with 69 additions and 55 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"@kilocode/cli": patch
---
Keep Nix builds on the Bun version required by the repository.
+4 -55
View File
@@ -21,59 +21,7 @@
devShells = forEachSystem (pkgs: {
default =
let
# Pin bun to the version declared in package.json (packageManager: "bun@1.3.14").
# The locked nixpkgs revision ships 1.3.11, so we fetch the official release directly.
bun =
let
sources = {
"aarch64-linux" = {
name = "bun-linux-aarch64";
hash = "sha256-on/7Y6gxA3WDbg1vZorhf6jY0YuIw3yCHGUzGXOhmjs=";
};
"x86_64-linux" = {
name = "bun-linux-x64";
hash = "sha256-lR7iruhV8IWVruxiJSJqKY0/6oOj3NZGXAnLzN9+hI8=";
};
"aarch64-darwin" = {
name = "bun-darwin-aarch64";
hash = "sha256-2LliIYKK1vl6x6wKt+lYcjQa92MAHogD6CZ2UsJlJiA=";
};
"x86_64-darwin" = {
name = "bun-darwin-x64";
hash = "sha256-QYPfM3RiPlurMVxUfPoJdFM81FfYa3O2OfeoeXTNZjM=";
};
};
source =
sources.${pkgs.stdenv.hostPlatform.system}
or (throw "Unsupported system for bun: ${pkgs.stdenv.hostPlatform.system}");
in
pkgs.stdenv.mkDerivation rec {
pname = "bun";
version = "1.3.14";
src = pkgs.fetchurl {
url = "https://github.com/oven-sh/bun/releases/download/bun-v${version}/${source.name}.zip";
inherit (source) hash;
};
nativeBuildInputs = [
pkgs.unzip
] ++ pkgs.lib.optional pkgs.stdenv.isLinux pkgs.autoPatchelfHook;
buildInputs = pkgs.lib.optionals pkgs.stdenv.isLinux [ pkgs.stdenv.cc.cc.lib ];
dontConfigure = true;
dontBuild = true;
installPhase = ''
runHook preInstall
install -Dm755 bun $out/bin/bun
ln -s $out/bin/bun $out/bin/bunx
runHook postInstall
'';
meta = {
description = "Fast all-in-one JavaScript runtime";
homepage = "https://bun.sh";
license = pkgs.lib.licenses.mit;
mainProgram = "bun";
platforms = builtins.attrNames sources;
};
};
bun = pkgs.callPackage ./nix/bun.nix { };
kilo-dev = pkgs.writeShellScriptBin "kilo-dev" ''
set -euo pipefail
@@ -279,11 +227,12 @@
packages = forEachSystem (
pkgs:
let
bun = pkgs.callPackage ./nix/bun.nix { };
node_modules = pkgs.callPackage ./nix/node_modules.nix {
inherit rev;
inherit bun rev;
};
kilo = pkgs.callPackage ./nix/kilo.nix {
inherit node_modules;
inherit bun node_modules;
};
in
{
+60
View File
@@ -0,0 +1,60 @@
{
lib,
stdenv,
fetchurl,
unzip,
autoPatchelfHook,
}:
let
package = lib.pipe ../package.json [
builtins.readFile
builtins.fromJSON
];
version = lib.removePrefix "bun@" package.packageManager;
sources = {
"aarch64-linux" = {
name = "bun-linux-aarch64";
hash = "sha256-on/7Y6gxA3WDbg1vZorhf6jY0YuIw3yCHGUzGXOhmjs=";
};
"x86_64-linux" = {
name = "bun-linux-x64";
hash = "sha256-lR7iruhV8IWVruxiJSJqKY0/6oOj3NZGXAnLzN9+hI8=";
};
"aarch64-darwin" = {
name = "bun-darwin-aarch64";
hash = "sha256-2LliIYKK1vl6x6wKt+lYcjQa92MAHogD6CZ2UsJlJiA=";
};
"x86_64-darwin" = {
name = "bun-darwin-x64";
hash = "sha256-QYPfM3RiPlurMVxUfPoJdFM81FfYa3O2OfeoeXTNZjM=";
};
};
source =
sources.${stdenv.hostPlatform.system}
or (throw "Unsupported system for bun: ${stdenv.hostPlatform.system}");
in
stdenv.mkDerivation {
pname = "bun";
inherit version;
src = fetchurl {
url = "https://github.com/oven-sh/bun/releases/download/bun-v${version}/${source.name}.zip";
inherit (source) hash;
};
nativeBuildInputs = [ unzip ] ++ lib.optional stdenv.isLinux autoPatchelfHook;
buildInputs = lib.optionals stdenv.isLinux [ stdenv.cc.cc.lib ];
dontConfigure = true;
dontBuild = true;
installPhase = ''
runHook preInstall
install -Dm755 bun $out/bin/bun
ln -s $out/bin/bun $out/bin/bunx
runHook postInstall
'';
meta = {
description = "Fast all-in-one JavaScript runtime";
homepage = "https://bun.sh";
license = lib.licenses.mit;
mainProgram = "bun";
platforms = builtins.attrNames sources;
};
}