9 stdenv.mkDerivation (finalAttrs: {
11 version = "2024-01-13";
14 url = "https://bellard.org/quickjs/quickjs-${finalAttrs.version}.tar.xz";
15 hash = "sha256-PEv4+JW/pUvrSGyNEhgRJ3Hs/FrDvhA2hR70FWghLgM=";
27 makeFlags = [ "PREFIX=$(out)" ];
29 doInstallCheck = true;
31 enableParallelBuilding = true;
35 postPatch = lib.optionalString stdenv.hostPlatform.isDarwin ''
36 substituteInPlace Makefile \
37 --replace "CONFIG_LTO=y" ""
48 install -Dm644 -t ''${!outputInfo}/share/info *info
52 installCheckPhase = lib.concatStringsSep "\n" [
54 runHook preInstallCheck
60 # Programs exit with code 1 when testing help, so grep for a string
63 qjs --help 2>&1 | grep "QuickJS version"
64 qjscalc --help 2>&1 | grep "QuickJS version"
70 echo "console.log('Output from compiled program');" > "$temp"
72 out=$(mktemp) && qjsc -o "$out" "$temp" && "$out" | grep -q "Output from compiled program"
73 out=$(mktemp) && qjsc -flto -o "$out" "$temp" && "$out" | grep -q "Output from compiled program"
77 runHook postInstallCheck
82 version = testers.testVersion {
83 package = finalAttrs.finalPackage;
84 command = "qjs --help || true";
89 homepage = "https://bellard.org/quickjs/";
90 description = "Small and embeddable Javascript engine";
92 QuickJS is a small and embeddable Javascript engine. It supports the
93 ES2023 specification including modules, asynchronous generators, proxies
96 It optionally supports mathematical extensions such as big decimal
97 floating point numbers (BigDecimal), big binary floating point numbers
98 (BigFloat) and operator overloading.
102 - Small and easily embeddable: just a few C files, no external
103 dependency, 210 KiB of x86 code for a simple hello world program.
104 - Fast interpreter with very low startup time: runs the 76000 tests of
105 the ECMAScript Test Suite in less than 2 minutes on a single core of a
106 desktop PC. The complete life cycle of a runtime instance completes in
107 less than 300 microseconds.
108 - Almost complete ES2023 support including modules, asynchronous
109 generators and full Annex B support (legacy web compatibility).
110 - Passes nearly 100% of the ECMAScript Test Suite tests when selecting
111 the ES2023 features. A summary is available at Test262 Report.
112 - Can compile Javascript sources to executables with no external dependency.
113 - Garbage collection using reference counting (to reduce memory usage and
114 have deterministic behavior) with cycle removal.
115 - Mathematical extensions: BigDecimal, BigFloat, operator overloading,
116 bigint mode, math mode.
117 - Command line interpreter with contextual colorization implemented in
119 - Small built-in standard library with C library wrappers.
122 license = lib.licenses.mit;
123 maintainers = with lib.maintainers; [
128 platforms = lib.platforms.all;