nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{ lib
2, stdenv
3, callPackage
4, buildPythonPackage
5, fetchPypi
6, rustPlatform
7, setuptools-rust
8, openssl
9, Security
10, packaging
11, six
12, isPyPy
13, cffi
14, pytestCheckHook
15, pytest-subtests
16, pretend
17, libiconv
18, iso8601
19, pytz
20, hypothesis
21}:
22
23let
24 cryptography-vectors = callPackage ./vectors.nix { };
25in
26buildPythonPackage rec {
27 pname = "cryptography";
28 version = "36.0.2"; # Also update the hash in vectors.nix
29
30 src = fetchPypi {
31 inherit pname version;
32 sha256 = "sha256-cPj097sqyfNAZVy6yJ1oxSevW7Q4dSKoQT6EHj5mKMk=";
33 };
34
35 cargoDeps = rustPlatform.fetchCargoTarball {
36 inherit src;
37 sourceRoot = "${pname}-${version}/${cargoRoot}";
38 name = "${pname}-${version}";
39 sha256 = "sha256-6C4N445h4Xf2nCc9rJWpSZaNPilR9GfgbmKvNlSIFqg=";
40 };
41
42 cargoRoot = "src/rust";
43
44 outputs = [ "out" "dev" ];
45
46 nativeBuildInputs = lib.optionals (!isPyPy) [
47 cffi
48 ] ++ [
49 rustPlatform.cargoSetupHook
50 setuptools-rust
51 ] ++ (with rustPlatform; [ rust.cargo rust.rustc ]);
52
53 buildInputs = [ openssl ]
54 ++ lib.optionals stdenv.isDarwin [ Security libiconv ];
55
56 propagatedBuildInputs = lib.optionals (!isPyPy) [
57 cffi
58 ];
59
60 checkInputs = [
61 cryptography-vectors
62 hypothesis
63 iso8601
64 pretend
65 pytestCheckHook
66 pytest-subtests
67 pytz
68 ];
69
70 pytestFlagsArray = [
71 "--disable-pytest-warnings"
72 ];
73
74 disabledTestPaths = lib.optionals (stdenv.isDarwin && stdenv.isAarch64) [
75 # aarch64-darwin forbids W+X memory, but this tests depends on it:
76 # * https://cffi.readthedocs.io/en/latest/using.html#callbacks
77 "tests/hazmat/backends/test_openssl_memleak.py"
78 ];
79
80 meta = with lib; {
81 description = "A package which provides cryptographic recipes and primitives";
82 longDescription = ''
83 Cryptography includes both high level recipes and low level interfaces to
84 common cryptographic algorithms such as symmetric ciphers, message
85 digests, and key derivation functions.
86 Our goal is for it to be your "cryptographic standard library". It
87 supports Python 2.7, Python 3.5+, and PyPy 5.4+.
88 '';
89 homepage = "https://github.com/pyca/cryptography";
90 changelog = "https://cryptography.io/en/latest/changelog/#v"
91 + replaceStrings [ "." ] [ "-" ] version;
92 license = with licenses; [ asl20 bsd3 psfl ];
93 maintainers = with maintainers; [ SuperSandro2000 ];
94 };
95}