about summary refs log tree commit diff
path: root/nixpkgs/pkgs/tools/security/pass/extensions/import.nix
blob: 8c51356e184ba35a5b27f6ea9004a8d092371948 (plain) (blame)
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
{ lib
, fetchFromGitHub
, fetchpatch
, python3Packages
, gnupg
, pass
}:

python3Packages.buildPythonApplication rec {
  pname = "pass-import";
  version = "3.2";

  src = fetchFromGitHub {
    owner = "roddhjav";
    repo = "pass-import";
    rev = "v${version}";
    sha256 = "0hrpg7yiv50xmbajfy0zdilsyhbj5iv0qnlrgkfv99q1dvd5qy56";
  };

  patches = [
    (fetchpatch {
      name = "support-for-pykeepass-4.0.3.patch";
      url = "https://github.com/roddhjav/pass-import/commit/f1b167578916d971ee4f99be99ba0e86ef49015e.patch";
      hash = "sha256-u6bJbV3/QTfRaPauKSyCWNodpy6CKsreMXUZWKRbee0=";
    })
  ];

  propagatedBuildInputs = with python3Packages; [
    cryptography
    defusedxml
    pyaml
    pykeepass
    python-magic # similar API to "file-magic", but already in nixpkgs.
    secretstorage
  ];

  nativeCheckInputs = [
    gnupg
    pass
    python3Packages.pytestCheckHook
  ];

  disabledTests = [
    "test_import_gnome_keyring" # requires dbus, which pytest doesn't support
  ];

  postInstall = ''
    mkdir -p $out/lib/password-store/extensions
    cp ${src}/import.bash $out/lib/password-store/extensions/import.bash
    wrapProgram $out/lib/password-store/extensions/import.bash \
      --prefix PATH : "${python3Packages.python.withPackages (_: propagatedBuildInputs)}/bin" \
      --prefix PYTHONPATH : "$out/${python3Packages.python.sitePackages}" \
      --run "export PREFIX"
    cp -r ${src}/share $out/
  '';

  postCheck = ''
    $out/bin/pimport --list-exporters --list-importers
  '';

  meta = with lib; {
    description = "Pass extension for importing data from existing password managers";
    homepage = "https://github.com/roddhjav/pass-import";
    changelog = "https://github.com/roddhjav/pass-import/blob/v${version}/CHANGELOG.rst";
    license = licenses.gpl3Plus;
    maintainers = with maintainers; [ lovek323 fpletz tadfisher ];
    platforms = platforms.unix;
  };
}