Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 123 lines 3.3 kB view raw
1{ 2 lib, 3 fetchurl, 4 stdenv, 5 testers, 6 texinfo, 7}: 8 9stdenv.mkDerivation (finalAttrs: { 10 pname = "quickjs"; 11 version = "2025-04-26"; 12 13 src = fetchurl { 14 url = "https://bellard.org/quickjs/quickjs-${finalAttrs.version}.tar.xz"; 15 hash = "sha256-LyAHTCUWbvb3gfOBxQ1XtQLLhdRw1jmrzOu+95VMg78="; 16 }; 17 18 outputs = [ 19 "out" 20 "info" 21 ]; 22 23 nativeBuildInputs = [ 24 texinfo 25 ]; 26 27 makeFlags = [ "PREFIX=$(out)" ]; 28 29 doInstallCheck = true; 30 31 enableParallelBuilding = true; 32 33 strictDeps = true; 34 35 postPatch = lib.optionalString stdenv.hostPlatform.isDarwin '' 36 substituteInPlace Makefile \ 37 --replace "CONFIG_LTO=y" "" 38 ''; 39 40 postBuild = '' 41 make doc/version.texi 42 pushd doc 43 makeinfo *texi 44 popd 45 ''; 46 47 postInstall = '' 48 pushd doc 49 install -Dm644 -t ''${!outputInfo}/share/info *info 50 popd 51 ''; 52 53 installCheckPhase = lib.concatStringsSep "\n" [ 54 '' 55 runHook preInstallCheck 56 '' 57 58 '' 59 PATH="$out/bin:$PATH" 60 '' 61 # Programs exit with code 1 when testing help, so grep for a string 62 '' 63 set +o pipefail 64 qjs --help 2>&1 | grep "QuickJS version" 65 set -o pipefail 66 '' 67 68 '' 69 temp=$(mktemp).js 70 echo "console.log('Output from compiled program');" > "$temp" 71 set -o verbose 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" 74 '' 75 76 '' 77 runHook postInstallCheck 78 '' 79 ]; 80 81 passthru.tests = { 82 version = testers.testVersion { 83 package = finalAttrs.finalPackage; 84 command = "qjs --help || true"; 85 }; 86 }; 87 88 meta = { 89 homepage = "https://bellard.org/quickjs/"; 90 description = "Small and embeddable Javascript engine"; 91 longDescription = '' 92 QuickJS is a small and embeddable Javascript engine. It supports the 93 ES2023 specification including modules, asynchronous generators, proxies 94 and BigInt. 95 96 Main Features: 97 98 - Small and easily embeddable: just a few C files, no external 99 dependency, 210 KiB of x86 code for a simple hello world program. 100 - Fast interpreter with very low startup time: runs the 76000 tests of 101 the ECMAScript Test Suite in less than 2 minutes on a single core of a 102 desktop PC. The complete life cycle of a runtime instance completes in 103 less than 300 microseconds. 104 - Almost complete ES2023 support including modules, asynchronous 105 generators and full Annex B support (legacy web compatibility). 106 - Passes nearly 100% of the ECMAScript Test Suite tests when selecting 107 the ES2023 features. A summary is available at Test262 Report. 108 - Can compile Javascript sources to executables with no external dependency. 109 - Garbage collection using reference counting (to reduce memory usage and 110 have deterministic behavior) with cycle removal. 111 - Command line interpreter with contextual colorization implemented in 112 Javascript. 113 - Small built-in standard library with C library wrappers. 114 115 ''; 116 license = lib.licenses.mit; 117 maintainers = with lib.maintainers; [ 118 stesie 119 ]; 120 mainProgram = "qjs"; 121 platforms = lib.platforms.all; 122 }; 123})