Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions .changeset/fix-nix-bun-pin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@kilocode/cli": patch
---

Keep Nix builds on the Bun version required by the repository.
59 changes: 4 additions & 55 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
{
Expand Down
60 changes: 60 additions & 0 deletions nix/bun.nix
Original file line number Diff line number Diff line change
@@ -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;
};
}
Loading