mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-02-05 11:44:02 +00:00
e0464e4788
In preparation for the deprecation of `stdenv.isX`. These shorthands are not conducive to cross-compilation because they hide the platforms. Darwin might get cross-compilation for which the continued usage of `stdenv.isDarwin` will get in the way One example of why this is bad and especially affects compiler packages https://www.github.com/NixOS/nixpkgs/pull/343059 There are too many files to go through manually but a treewide should get users thinking when they see a `hostPlatform.isX` in a place where it doesn't make sense. ``` fd --type f "\.nix" | xargs sd --fixed-strings "stdenv.is" "stdenv.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "stdenv'.is" "stdenv'.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "clangStdenv.is" "clangStdenv.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "gccStdenv.is" "gccStdenv.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "stdenvNoCC.is" "stdenvNoCC.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "inherit (stdenv) is" "inherit (stdenv.hostPlatform) is" fd --type f "\.nix" | xargs sd --fixed-strings "buildStdenv.is" "buildStdenv.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "effectiveStdenv.is" "effectiveStdenv.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "originalStdenv.is" "originalStdenv.hostPlatform.is" ```
63 lines
1.5 KiB
Nix
63 lines
1.5 KiB
Nix
{ lib
|
|
, stdenv
|
|
, fetchurl
|
|
, texinfo
|
|
}:
|
|
|
|
stdenv.mkDerivation rec {
|
|
pname = "quickjs";
|
|
version = "2024-01-13";
|
|
|
|
src = fetchurl {
|
|
url = "https://bellard.org/quickjs/quickjs-${version}.tar.xz";
|
|
hash = "sha256-PEv4+JW/pUvrSGyNEhgRJ3Hs/FrDvhA2hR70FWghLgM=";
|
|
};
|
|
|
|
postPatch = lib.optionalString stdenv.hostPlatform.isDarwin ''
|
|
substituteInPlace Makefile --replace "CONFIG_LTO=y" ""
|
|
'';
|
|
|
|
makeFlags = [ "PREFIX=${placeholder "out"}" ];
|
|
enableParallelBuilding = true;
|
|
|
|
nativeBuildInputs = [
|
|
texinfo
|
|
];
|
|
|
|
postBuild = ''
|
|
(cd doc
|
|
makeinfo *texi)
|
|
'';
|
|
|
|
postInstall = ''
|
|
(cd doc
|
|
install -Dt $out/share/doc *texi *info)
|
|
'';
|
|
|
|
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 -o "$out" "$temp" && "$out" | grep -q "Output from compiled program"
|
|
out=$(mktemp) && qjsc -flto -o "$out" "$temp" && "$out" | grep -q "Output from compiled program"
|
|
'';
|
|
|
|
meta = with lib; {
|
|
description = "Small and embeddable Javascript engine";
|
|
homepage = "https://bellard.org/quickjs/";
|
|
maintainers = with maintainers; [ stesie AndersonTorres ];
|
|
platforms = platforms.unix;
|
|
license = licenses.mit;
|
|
mainProgram = "qjs";
|
|
};
|
|
}
|