diff --git a/pkgs/development/tools/quick-lint-js/build-tools-install.patch b/pkgs/development/tools/quick-lint-js/build-tools-install.patch new file mode 100644 index 000000000000..2326170d5236 --- /dev/null +++ b/pkgs/development/tools/quick-lint-js/build-tools-install.patch @@ -0,0 +1,32 @@ +From 3923f0df76d24b73d57f15eec61ab190ea048093 Mon Sep 17 00:00:00 2001 +From: "Matthew \"strager\" Glazar" +Date: Thu, 26 Oct 2023 18:08:30 -0400 +Subject: [PATCH] fix(build): fix installing build tools for cross-compilation + +'cmake --install . --component build-tools' copies no files [1]. This +was caused by commit 1f2e1a47 where the code calling install() became +dead code on accident. Call install() so that 'cmake --install' copies +the build artifacts as intended. + +[1] https://github.com/quick-lint/quick-lint-js/issues/1099 + +Refs: 1f2e1a4701793cac24eaac44d7af81a8b820b1bc +--- + docs/CHANGELOG.md | 7 +++++++ + tools/CMakeLists.txt | 1 - + 2 files changed, 7 insertions(+), 1 deletion(-) + + (docs/CHANGELOG.md changes omitted to reduce conflicts.) + +diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt +index 71ccbdf1b..b541afb52 100644 +--- a/tools/CMakeLists.txt ++++ b/tools/CMakeLists.txt +@@ -68,7 +68,6 @@ if (QUICK_LINT_JS_ENABLE_BUILD_TOOLS) + COMMENT "Building all quick-lint-js build-time tools" + DEPENDS ${QUICK_LINT_JS_BUILD_TOOL_TARGETS} + ) +-elseif (QUICK_LINT_JS_ENABLE_BUILD_TOOLS) + install( + TARGETS ${QUICK_LINT_JS_BUILD_TOOL_TARGETS} + COMPONENT build-tools diff --git a/pkgs/development/tools/quick-lint-js/default.nix b/pkgs/development/tools/quick-lint-js/default.nix index 54badbaddc60..32c61c836b96 100644 --- a/pkgs/development/tools/quick-lint-js/default.nix +++ b/pkgs/development/tools/quick-lint-js/default.nix @@ -1,8 +1,6 @@ -{ cmake, fetchFromGitHub, lib, ninja, stdenv, testers, quick-lint-js }: +{ buildPackages, cmake, fetchFromGitHub, lib, ninja, stdenv, testers, quick-lint-js }: - -stdenv.mkDerivation rec { - pname = "quick-lint-js"; +let version = "2.17.0"; src = fetchFromGitHub { @@ -12,11 +10,41 @@ stdenv.mkDerivation rec { 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; - # Temporary workaround for https://github.com/NixOS/nixpkgs/pull/108496#issuecomment-1192083379 - cmakeFlags = [ "-DCMAKE_SKIP_BUILD_RPATH=ON" ]; + 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; }; @@ -29,4 +57,7 @@ stdenv.mkDerivation rec { 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; }