1{ lib, stdenv
2, fetchurl
3, autoreconfHook
4, docbook_xsl
5, docbook_xml_dtd_43
6, gtk-doc
7, lzip
8, libidn2
9, libunistring
10, libxslt
11, pkg-config
12, python3
13, valgrind
14, publicsuffix-list
15}:
16
17let
18 enableValgrindTests = !stdenv.isDarwin && lib.meta.availableOn stdenv.hostPlatform valgrind
19 # Apparently valgrind doesn't support some new ARM features on (some) Hydra machines:
20 # VEX: Mismatch detected between RDMA and atomics features.
21 && !stdenv.isAarch64
22 # Valgrind on musl does not hook malloc calls properly, resulting in errors `Invalid free() / delete / delete[] / realloc()`
23 # https://bugs.kde.org/show_bug.cgi?id=435441
24 && !stdenv.hostPlatform.isMusl
25 ;
26in stdenv.mkDerivation rec {
27 pname = "libpsl";
28 version = "0.21.2";
29
30 src = fetchurl {
31 url = "https://github.com/rockdaboot/libpsl/releases/download/${version}/libpsl-${version}.tar.lz";
32 sha256 = "sha256-qj1wbEUnhtE0XglNriAc022B8Dz4HWNtXPwQ02WQfxc=";
33 };
34
35 nativeBuildInputs = [
36 autoreconfHook
37 docbook_xsl
38 docbook_xml_dtd_43
39 gtk-doc
40 lzip
41 pkg-config
42 python3
43 libxslt
44 ] ++ lib.optionals enableValgrindTests [
45 valgrind
46 ];
47
48 buildInputs = [
49 libidn2
50 libunistring
51 libxslt
52 ];
53
54 propagatedBuildInputs = [
55 publicsuffix-list
56 ];
57
58 postPatch = ''
59 patchShebangs src/psl-make-dafsa
60 '';
61
62 preAutoreconf = ''
63 gtkdocize
64 '';
65
66 configureFlags = [
67 # "--enable-gtk-doc"
68 "--enable-man"
69 "--with-psl-distfile=${publicsuffix-list}/share/publicsuffix/public_suffix_list.dat"
70 "--with-psl-file=${publicsuffix-list}/share/publicsuffix/public_suffix_list.dat"
71 "--with-psl-testfile=${publicsuffix-list}/share/publicsuffix/test_psl.txt"
72 ] ++ lib.optionals enableValgrindTests [
73 "--enable-valgrind-tests"
74 ];
75
76 enableParallelBuilding = true;
77
78 doCheck = true;
79
80 meta = with lib; {
81 description = "C library for the Publix Suffix List";
82 longDescription = ''
83 libpsl is a C library for the Publix Suffix List (PSL). A "public suffix"
84 is a domain name under which Internet users can directly register own
85 names. Browsers and other web clients can use it to avoid privacy-leaking
86 "supercookies" and "super domain" certificates, for highlighting parts of
87 the domain in a user interface or sorting domain lists by site.
88 '';
89 homepage = "https://rockdaboot.github.io/libpsl/";
90 changelog = "https://raw.githubusercontent.com/rockdaboot/${pname}/${pname}-${version}/NEWS";
91 license = licenses.mit;
92 maintainers = [ maintainers.c0bw3b ];
93 mainProgram = "psl";
94 platforms = platforms.unix;
95 pkgConfigModules = [ "libpsl" ];
96 };
97}