1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 pythonOlder,
6 rustPlatform,
7 libiconv,
8 fetchFromGitHub,
9 darwin,
10}:
11let
12 pname = "nh3";
13 version = "0.2.17";
14 src = fetchFromGitHub {
15 owner = "messense";
16 repo = pname;
17 rev = "v${version}";
18 hash = "sha256-j9OoXAuuCWsBHanN+SzSip94ZA+kY8HUVvfY/omUSSM=";
19 };
20in
21buildPythonPackage {
22 inherit pname version src;
23 format = "pyproject";
24 disabled = pythonOlder "3.6";
25
26 cargoDeps = rustPlatform.fetchCargoTarball {
27 inherit src;
28 name = "${pname}-${version}";
29 hash = "sha256-WomlVzKOUfcgAWGJInSvZn9hm+bFpgc4nJbRiyPCU64=";
30 };
31
32 nativeBuildInputs = with rustPlatform; [
33 cargoSetupHook
34 maturinBuildHook
35 ];
36
37 buildInputs = lib.optionals stdenv.isDarwin [
38 libiconv
39 darwin.apple_sdk.frameworks.Security
40 ];
41
42 pythonImportsCheck = [ "nh3" ];
43
44 meta = with lib; {
45 description = "Python binding to Ammonia HTML sanitizer Rust crate";
46 homepage = "https://github.com/messense/nh3";
47 license = licenses.mit;
48 maintainers = with maintainers; [ happysalada ];
49 };
50}