mirror of
https://github.com/oven-sh/bun
synced 2026-02-02 15:08:46 +00:00
Add Nix flake for development environment (#23406)
Provides a Nix flake as an alternative to `scripts/bootstrap.sh` for setting up the Bun development environment. ## What's included: - **flake.nix**: Full development environment with all dependencies from bootstrap.sh - LLVM 19, CMake 3.30+, Node.js 24, Rust, Go - Build tools: ninja, ccache, pkg-config, make - Chromium dependencies for Puppeteer testing - gdb for core dump debugging - **shell.nix**: Simple wrapper for `nix-shell` usage - **cmake/CompilerFlags.cmake**: Nix compatibility fixes - Disable zstd debug compression (Nix's LLVM not built with zstd) - Set _FORTIFY_SOURCE=0 for -O0 debug builds - Downgrade _FORTIFY_SOURCE warning to not error ## Usage: ```bash nix-shell export CMAKE_SYSTEM_PROCESSOR=$(uname -m) bun bd ``` ## Verified working: ✅ Successfully compiles Bun debug build ✅ Binary tested: `./build/debug/bun-debug --version` → 1.2.24-debug ✅ All dependencies from bootstrap.sh included ## Advantages: - Fully isolated (no sudo required) - 100% reproducible dependency versions - Fast setup with binary caching --------- Co-authored-by: Claude Bot <claude-bot@bun.sh> Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
103
shell.nix
Normal file
103
shell.nix
Normal file
@@ -0,0 +1,103 @@
|
||||
# Simple shell.nix for users without flakes enabled
|
||||
# For reproducible builds with locked dependencies, use: nix develop
|
||||
# This uses unpinned <nixpkgs> for simplicity; flake.nix provides version pinning via flake.lock
|
||||
{ pkgs ? import <nixpkgs> {} }:
|
||||
|
||||
pkgs.mkShell rec {
|
||||
packages = with pkgs; [
|
||||
# Core build tools (matching bootstrap.sh)
|
||||
cmake
|
||||
ninja
|
||||
clang_19
|
||||
llvm_19
|
||||
lld_19
|
||||
nodejs_24
|
||||
bun
|
||||
rustc
|
||||
cargo
|
||||
go
|
||||
python3
|
||||
ccache
|
||||
pkg-config
|
||||
gnumake
|
||||
libtool
|
||||
ruby
|
||||
perl
|
||||
|
||||
# Libraries
|
||||
openssl
|
||||
zlib
|
||||
libxml2
|
||||
|
||||
# Development tools
|
||||
git
|
||||
curl
|
||||
wget
|
||||
unzip
|
||||
xz
|
||||
|
||||
# Linux-specific: gdb and Chromium deps for testing
|
||||
] ++ pkgs.lib.optionals pkgs.stdenv.isLinux [
|
||||
gdb
|
||||
# Chromium dependencies for Puppeteer tests
|
||||
xorg.libX11
|
||||
xorg.libxcb
|
||||
xorg.libXcomposite
|
||||
xorg.libXcursor
|
||||
xorg.libXdamage
|
||||
xorg.libXext
|
||||
xorg.libXfixes
|
||||
xorg.libXi
|
||||
xorg.libXrandr
|
||||
xorg.libXrender
|
||||
xorg.libXScrnSaver
|
||||
xorg.libXtst
|
||||
libxkbcommon
|
||||
mesa
|
||||
nspr
|
||||
nss
|
||||
cups
|
||||
dbus
|
||||
expat
|
||||
fontconfig
|
||||
freetype
|
||||
glib
|
||||
gtk3
|
||||
pango
|
||||
cairo
|
||||
alsa-lib
|
||||
at-spi2-atk
|
||||
at-spi2-core
|
||||
libgbm
|
||||
liberation_ttf
|
||||
atk
|
||||
libdrm
|
||||
xorg.libxshmfence
|
||||
gdk-pixbuf
|
||||
];
|
||||
|
||||
shellHook = ''
|
||||
export CC="${pkgs.lib.getExe pkgs.clang_19}"
|
||||
export CXX="${pkgs.lib.getExe' pkgs.clang_19 "clang++"}"
|
||||
export AR="${pkgs.llvm_19}/bin/llvm-ar"
|
||||
export RANLIB="${pkgs.llvm_19}/bin/llvm-ranlib"
|
||||
export CMAKE_C_COMPILER="$CC"
|
||||
export CMAKE_CXX_COMPILER="$CXX"
|
||||
export CMAKE_AR="$AR"
|
||||
export CMAKE_RANLIB="$RANLIB"
|
||||
export CMAKE_SYSTEM_PROCESSOR=$(uname -m)
|
||||
export TMPDIR=''${TMPDIR:-/tmp}
|
||||
'' + pkgs.lib.optionalString pkgs.stdenv.isLinux ''
|
||||
export LD="${pkgs.lib.getExe' pkgs.lld_19 "ld.lld"}"
|
||||
export NIX_CFLAGS_LINK="''${NIX_CFLAGS_LINK:+$NIX_CFLAGS_LINK }-fuse-ld=lld"
|
||||
export LD_LIBRARY_PATH="${pkgs.lib.makeLibraryPath packages}''${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
|
||||
'' + ''
|
||||
|
||||
echo "====================================="
|
||||
echo "Bun Development Environment (Nix)"
|
||||
echo "====================================="
|
||||
echo "To build: bun bd"
|
||||
echo "To test: bun bd test <test-file>"
|
||||
echo "====================================="
|
||||
'';
|
||||
}
|
||||
Reference in New Issue
Block a user