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