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