From 106d4049cd67fd6681f9e7be771932bd05bb76e9 Mon Sep 17 00:00:00 2001 From: Ivan Kozik Date: Sun, 17 Nov 2019 21:35:29 +0000 Subject: [PATCH] quickjs: init at 2019-10-27 (#73515) --- .../interpreters/quickjs/default.nix | 42 +++++++++++++++++++ pkgs/top-level/all-packages.nix | 2 + 2 files changed, 44 insertions(+) create mode 100644 pkgs/development/interpreters/quickjs/default.nix diff --git a/pkgs/development/interpreters/quickjs/default.nix b/pkgs/development/interpreters/quickjs/default.nix new file mode 100644 index 000000000000..23191b0e6d35 --- /dev/null +++ b/pkgs/development/interpreters/quickjs/default.nix @@ -0,0 +1,42 @@ +{ stdenv, fetchurl }: + +stdenv.mkDerivation rec { + pname = "quickjs"; + version = "2019-10-27"; + + src = fetchurl { + url = "https://bellard.org/${pname}/${pname}-${version}.tar.xz"; + sha256 = "0xm16ja3c0k80jy0xkx0f40r44v2lgx2si4dnaw2w7c5nx7cmkai"; + }; + + makeFlags = [ "prefix=${placeholder ''out''}" ]; + enableParallelBuilding = true; + + doInstallCheck = true; + installCheckPhase = '' + PATH="$out/bin:$PATH" + + # Programs exit with code 1 when testing help, so grep for a string + set +o pipefail + qjs --help 2>&1 | grep "QuickJS version" + qjsbn --help 2>&1 | grep "QuickJS version" + qjscalc --help 2>&1 | grep "QuickJS version" + set -o pipefail + + temp=$(mktemp).js + echo "console.log('Output from compiled program');" > "$temp" + set -o verbose + out=$(mktemp) && qjsc "$temp" -o "$out" && "$out" | grep -q "Output from compiled program" + out=$(mktemp) && qjsbnc "$temp" -o "$out" && "$out" | grep -q "Output from compiled program" + out=$(mktemp) && qjsc -flto "$temp" -o "$out" && "$out" | grep -q "Output from compiled program" + out=$(mktemp) && qjsbnc -flto "$temp" -o "$out" && "$out" | grep -q "Output from compiled program" + ''; + + meta = with stdenv.lib; { + description = "A small and embeddable Javascript engine"; + homepage = "https://bellard.org/quickjs/"; + maintainers = with maintainers; [ stesie ivan ]; + platforms = platforms.linux; + license = licenses.mit; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 450fb1367871..85e3fa5d23f0 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -5895,6 +5895,8 @@ in qtikz = libsForQt5.callPackage ../applications/graphics/ktikz { }; + quickjs = callPackage ../development/interpreters/quickjs { }; + quickserve = callPackage ../tools/networking/quickserve { }; quicktun = callPackage ../tools/networking/quicktun { };