nixpkgs/pkgs/development/interpreters/quickjs/default.nix

40 lines
1.2 KiB
Nix
Raw Normal View History

{ lib, stdenv, fetchurl }:
2019-11-17 21:35:29 +00:00
stdenv.mkDerivation rec {
pname = "quickjs";
2021-02-15 16:08:25 +00:00
version = "2020-11-08";
2019-11-17 21:35:29 +00:00
src = fetchurl {
url = "https://bellard.org/${pname}/${pname}-${version}.tar.xz";
2021-02-15 16:08:25 +00:00
sha256 = "0yqqcjxi3cqagw184mqrxpvqg486x7c233r3cp9mxachngd6779f";
2019-11-17 21:35:29 +00:00
};
makeFlags = [ "prefix=${placeholder "out"}" ];
2019-11-17 21:35:29 +00:00
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"
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) && qjsc -flto "$temp" -o "$out" && "$out" | grep -q "Output from compiled program"
'';
meta = with lib; {
2019-11-17 21:35:29 +00:00
description = "A small and embeddable Javascript engine";
homepage = "https://bellard.org/quickjs/";
maintainers = with maintainers; [ stesie ];
2019-11-17 21:35:29 +00:00
platforms = platforms.linux;
license = licenses.mit;
};
}