diff --git a/README.md b/README.md index bacfafb3b1c..27db1e3b52d 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,12 @@ All in one fast & easy-to-use tool. Instead of 1,000 node_modules for develo curl -fsSL https://bun.sh/install | bash ``` +### Nix + +There is a `default.nix` file bundled with Bun's source. This could eventually be brought to Nixpkgs, but for now, you can run and install it like any other nix package. + +Before using it, change `bun_install` on line 11 to wherever you'd like Bun to store it's cache. + ## Benchmarks **CSS**: [Bun is 14x faster](./bench/hot-module-reloading/css-stress-test) than Next.js at hot reloading CSS. TODO: compare Vite diff --git a/default.nix b/default.nix new file mode 100644 index 00000000000..6ef4ac557c1 --- /dev/null +++ b/default.nix @@ -0,0 +1,31 @@ +{ stdenv +, autoPatchelfHook +, fetchurl +, openssl +, unzip +, pkgs +, ... }: +let + version = "0.0.52"; + checksum = "88k0RW6/X/CudqExRwnbfzpKcxHJ3BvtvX2dIudqU+A="; + bun_install = "/home//.bun"; # Set this to where you want bun's cache +in stdenv.mkDerivation { + pname = "bun"; + version = version; + src = fetchurl { + url = "https://github.com/Jarred-Sumner/bun-releases-for-updater/releases/download/bun-v${version}/bun-linux-x64.zip"; + sha256 = checksum; + }; + sourceRoot = "."; + unpackCmd = "unzip bun-linux-x64.zip"; + dontConfigure = true; + dontBuild = true; + nativeBuildInputs = [ pkgs.makeWrapper autoPatchelfHook ]; + buildInputs = [ unzip openssl stdenv.cc.cc.lib ]; + + installPhase = "install -D ./bun-linux-x64/bun $out/bin/bun"; + postInstall = '' + wrapProgram "$out/bin/bun" \ + --prefix BUN_INSTALL : ${bun_install} + ''; +} \ No newline at end of file