1{
2 lib,
3 aws-sam-cli,
4 boto3,
5 buildPythonPackage,
6 cfn-lint,
7 fetchFromGitHub,
8 mock,
9 moto,
10 mypy-boto3-ebs,
11 poetry-core,
12 pytestCheckHook,
13 pythonOlder,
14 typer,
15 urllib3,
16}:
17
18buildPythonPackage rec {
19 pname = "dsnap";
20 version = "1.0.1";
21 pyproject = true;
22
23 disabled = pythonOlder "3.7";
24
25 src = fetchFromGitHub {
26 owner = "RhinoSecurityLabs";
27 repo = "dsnap";
28 tag = "v${version}";
29 hash = "sha256-h5zeyfkBoHnvjqHYahDXEEbGdmMti2Y56R/8OKyxOOM=";
30 };
31
32 postPatch = ''
33 # Is no direct dependency
34 substituteInPlace pyproject.toml \
35 --replace-fail 'urllib3 = "^1.26.4"' 'urllib3 = "*"'
36 '';
37
38 build-system = [ poetry-core ];
39
40 dependencies = [
41 boto3
42 urllib3
43 ];
44
45 optional-dependencies = {
46 cli = [ typer ];
47 scannerd = [
48 aws-sam-cli
49 cfn-lint
50 ];
51 };
52
53 nativeCheckInputs = [
54 mock
55 moto
56 mypy-boto3-ebs
57 pytestCheckHook
58 ]
59 ++ lib.flatten (builtins.attrValues optional-dependencies);
60
61 # https://github.com/RhinoSecurityLabs/dsnap/issues/26
62 # ImportError: cannot import name 'mock_iam' from 'moto'
63 doCheck = false;
64
65 pythonImportsCheck = [ "dsnap" ];
66
67 meta = with lib; {
68 description = "Utility for downloading and mounting EBS snapshots using the EBS Direct API's";
69 homepage = "https://github.com/RhinoSecurityLabs/dsnap";
70 changelog = "https://github.com/RhinoSecurityLabs/dsnap/releases/tag/v${version}";
71 license = licenses.bsd3;
72 maintainers = with maintainers; [ fab ];
73 mainProgram = "dsnap";
74 };
75}