diff --git a/pkgs/tools/text/html-tidy/default.nix b/pkgs/tools/text/html-tidy/default.nix
index 9694295ed1f..d80b8e8c899 100644
--- a/pkgs/tools/text/html-tidy/default.nix
+++ b/pkgs/tools/text/html-tidy/default.nix
@@ -1,4 +1,4 @@
-{ lib, stdenv, fetchFromGitHub, cmake, libxslt }:
+{ lib, stdenv, fetchFromGitHub, fetchpatch, cmake, libxslt, html-tidy }:
stdenv.mkDerivation rec {
pname = "html-tidy";
@@ -11,9 +11,18 @@ stdenv.mkDerivation rec {
sha256 = "sha256-ZMz0NySxzX2XHiqB8f5asvwjIG6kdIcq8Gb3EbAxBaU=";
};
- nativeBuildInputs = [ cmake libxslt/*manpage*/ ];
+ # https://github.com/htacg/tidy-html5/pull/1036
+ patches = (fetchpatch {
+ url = "https://github.com/htacg/tidy-html5/commit/e9aa038bd06bd8197a0dc049380bc2945ff55b29.diff";
+ sha256 = "sha256-Q2GjinNBWLL+HXUtslzDJ7CJSTflckbjweiSMCnIVwg=";
+ });
- cmakeFlags = [];
+ nativeBuildInputs = [ cmake libxslt/*manpage*/ ]
+ ++ lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) html-tidy;
+
+ cmakeFlags = lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
+ "-DHOST_TIDY=tidy"
+ ];
# ATM bin/tidy is statically linked, as upstream provides no other option yet.
# https://github.com/htacg/tidy-html5/issues/326#issuecomment-160322107