diff --git a/flake.lock b/flake.lock index 1c8e62bd82..e66c04991a 100644 --- a/flake.lock +++ b/flake.lock @@ -2,11 +2,11 @@ "nodes": { "nixpkgs": { "locked": { - "lastModified": 1776683584, - "narHash": "sha256-NuTLMrr10Tng72hurYG8jYQ4XKK8wnpJmOGcPiis96g=", + "lastModified": 1777270315, + "narHash": "sha256-yKB4G6cKsQsWN7M6rZGk6gkJPDNPIzT05y4qzRyCDlI=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "9dd5558b06dbdacbf635a3dd36dce1b1a7ee3a89", + "rev": "6368eda62c9775c38ef7f714b2555a741c20c72d", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 13293523aa..6380c23d27 100644 --- a/flake.nix +++ b/flake.nix @@ -21,9 +21,63 @@ devShells = forEachSystem (pkgs: { default = let + # Pin bun to the version declared in package.json (packageManager: "bun@1.3.13"). + # nixpkgs-unstable currently ships 1.3.11, so we fetch the official release directly. + bun = + let + sources = { + "aarch64-linux" = { + name = "bun-linux-aarch64"; + hash = "sha256-cLrkGzkIsKEg4eWMXIrzDnSvrjuNEbDT/djnh937SyI="; + }; + "x86_64-linux" = { + name = "bun-linux-x64"; + hash = "sha256-ecB3H6i5LDOq5B4VoODTB+qZ0OLwAxfHHGxTI3p44lo="; + }; + "aarch64-darwin" = { + name = "bun-darwin-aarch64"; + hash = "sha256-VGfj9l26Umuf6pjwzOBO+vwMY+Fpcz7Ce4dqOtMtoZA="; + }; + "x86_64-darwin" = { + name = "bun-darwin-x64"; + hash = "sha256-5abItk9BmSUjLREeyxPiXwq/VeVPeSNB+YdiP9B3gAk="; + }; + }; + 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.13"; + 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; + }; + }; + kilo-dev = pkgs.writeShellScriptBin "kilo-dev" '' cd "$KILO_ROOT" - exec ${pkgs.bun}/bin/bun dev "$@" + exec ${bun}/bin/bun dev "$@" ''; kilo-install-bin = pkgs.writeShellScriptBin "kilo-install" ''