mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-14 01:33:10 +00:00
6daf525c9d
quick-lint-js' build system supports cross compiling, but it's not automatic. Prior to quick-lint-js version 2.13, cross compiling with Nix works because some build-time tools are optional. These build-time tools need a compiler from buildPackages.stdenv. Version 2.13 made these build-time tools required. Refactor the quick-lint-js package to use quick-lint-js' cross compilation support. This fixes cross compilation with Nix. Upstream documentation for cross compiling: https://quick-lint-js.com/contribute/build-from-source/cross-compiling/ Testing: # Test Linux x86_64 cross compiling for Linux AArch64: x86$ uname -a Linux strapurp 6.2.0-35-generic #35~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Fri Oct 6 10:23:26 UTC 2 x86_64 x86_64 x86_64 GNU/Linux x86$ nix-shell -p pkgsCross.aarch64-multiplatform.quick-lint-js --run 'file $(which quick-lint-js)' /nix/store/3rdxhjxdmiwz1zg2mi477ysc9nb7jsqx-quick-lint-js-aarch64-unknown-linux-gnu-2.17.0/bin/quick-lint-js: ELF 64-bit LSB executable, ARM aarch64, version 1 (GNU/Linux), dynamically linked, interpreter /nix/store/5gdh4mp8rwliq4s33gwcpwzqvsb2xpzr-glibc-aarch64-unknown-linux-gnu-2.38-23/lib/ld-linux-aarch64.so.1, for GNU/Linux 3.10.0, not stripped # Test the binary on a Linux AArch64 machine: x86$ nix --extra-experimental-features nix-command copy --to ssh-ng://parallels@192.168.4.144 /nix/store/3rdxhjxdmiwz1zg2mi477ysc9nb7jsqx-quick-lint-js-aarch64-unknown-linux-gnu-2.17.0/ arm$ /nix/store/3rdxhjxdmiwz1zg2mi477ysc9nb7jsqx-quick-lint-js-aarch64-unknown-linux-gnu-2.17.0/bin/quick-lint-js --version quick-lint-js version 2.17.0
64 lines
1.7 KiB
Nix
64 lines
1.7 KiB
Nix
{ buildPackages, cmake, fetchFromGitHub, lib, ninja, stdenv, testers, quick-lint-js }:
|
|
|
|
let
|
|
version = "2.17.0";
|
|
|
|
src = fetchFromGitHub {
|
|
owner = "quick-lint";
|
|
repo = "quick-lint-js";
|
|
rev = version;
|
|
sha256 = "sha256-5+Cyw1cLgBkTePNNFoNAF2oHnLQDHr4vHiaZHJrewug=";
|
|
};
|
|
|
|
quick-lint-js-build-tools = buildPackages.stdenv.mkDerivation {
|
|
pname = "quick-lint-js-build-tools";
|
|
inherit version src;
|
|
|
|
patches = [ ./build-tools-install.patch ];
|
|
|
|
nativeBuildInputs = [ cmake ninja ];
|
|
doCheck = false;
|
|
|
|
cmakeFlags = [
|
|
"-DQUICK_LINT_JS_ENABLE_BUILD_TOOLS=ON"
|
|
# Temporary workaround for https://github.com/NixOS/nixpkgs/pull/108496#issuecomment-1192083379
|
|
"-DCMAKE_SKIP_BUILD_RPATH=ON"
|
|
];
|
|
ninjaFlags = "quick-lint-js-build-tools";
|
|
|
|
installPhase = ''
|
|
runHook preInstall
|
|
cmake --install . --component build-tools
|
|
runHook postInstall
|
|
'';
|
|
};
|
|
in
|
|
stdenv.mkDerivation rec {
|
|
pname = "quick-lint-js";
|
|
inherit version src;
|
|
|
|
nativeBuildInputs = [ cmake ninja ];
|
|
doCheck = true;
|
|
|
|
cmakeFlags = [
|
|
"-DQUICK_LINT_JS_USE_BUILD_TOOLS=${quick-lint-js-build-tools}/bin"
|
|
# Temporary workaround for https://github.com/NixOS/nixpkgs/pull/108496#issuecomment-1192083379
|
|
"-DCMAKE_SKIP_BUILD_RPATH=ON"
|
|
];
|
|
|
|
passthru.tests = {
|
|
version = testers.testVersion { package = quick-lint-js; };
|
|
};
|
|
|
|
meta = with lib; {
|
|
description = "Find bugs in Javascript programs";
|
|
homepage = "https://quick-lint-js.com";
|
|
license = licenses.gpl3Plus;
|
|
maintainers = with maintainers; [ ratsclub ];
|
|
platforms = platforms.all;
|
|
};
|
|
|
|
# Expose quick-lint-js-build-tools to nix repl as quick-lint-js.build-tools.
|
|
passthru.build-tools = quick-lint-js-build-tools;
|
|
}
|