summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/nh3/default.nix
blob: 5633dfe6d97b3733b04cb829eb991227714e22d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
{
  lib,
  stdenv,
  buildPythonPackage,
  rustPlatform,
  libiconv,
  fetchFromGitHub,
}:
let
  pname = "nh3";
  version = "0.3.2";
  src = fetchFromGitHub {
    owner = "messense";
    repo = "nh3";
    rev = "v${version}";
    hash = "sha256-2D8ZLmVRA+SuMqeUsSXyY+0zlgqp7TSRyQuJMjmRVFk=";
  };
in
buildPythonPackage {
  inherit pname version src;
  pyproject = true;

  cargoDeps = rustPlatform.fetchCargoVendor {
    inherit pname version src;
    hash = "sha256-dN6zdwMGh8stgDuGiO+T/ZZ3/3P9Wu/gUw5gHJ1pPGA=";
  };

  nativeBuildInputs = with rustPlatform; [
    cargoSetupHook
    maturinBuildHook
  ];

  buildInputs = lib.optionals stdenv.hostPlatform.isDarwin [
    libiconv
  ];

  pythonImportsCheck = [ "nh3" ];

  meta = {
    description = "Python binding to Ammonia HTML sanitizer Rust crate";
    homepage = "https://github.com/messense/nh3";
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [ happysalada ];
  };
}