1{ lib, stdenv, fetchFromGitHub, fetchpatch, cmake, libxslt, html-tidy }:
2
3stdenv.mkDerivation rec {
4 pname = "html-tidy";
5 version = "5.8.0";
6
7 src = fetchFromGitHub {
8 owner = "htacg";
9 repo = "tidy-html5";
10 rev = version;
11 hash = "sha256-vzVWQodwzi3GvC9IcSQniYBsbkJV20iZanF33A0Gpe0=";
12 };
13
14 # https://github.com/htacg/tidy-html5/pull/1036
15 patches = (fetchpatch {
16 url = "https://github.com/htacg/tidy-html5/commit/e9aa038bd06bd8197a0dc049380bc2945ff55b29.diff";
17 sha256 = "sha256-Q2GjinNBWLL+HXUtslzDJ7CJSTflckbjweiSMCnIVwg=";
18 });
19
20 nativeBuildInputs = [ cmake libxslt/*manpage*/ ]
21 ++ lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) html-tidy;
22
23 cmakeFlags = lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
24 "-DHOST_TIDY=tidy"
25 ];
26
27 # ATM bin/tidy is statically linked, as upstream provides no other option yet.
28 # https://github.com/htacg/tidy-html5/issues/326#issuecomment-160322107
29
30 meta = with lib; {
31 description = "A HTML validator and `tidier'";
32 longDescription = ''
33 HTML Tidy is a command-line tool and C library that can be
34 used to validate and fix HTML data.
35 '';
36 license = licenses.libpng; # very close to it - the 3 clauses are identical
37 homepage = "http://html-tidy.org";
38 platforms = platforms.all;
39 maintainers = with maintainers; [ edwtjo ];
40 mainProgram = "tidy";
41 };
42}