1{ stdenv
2, lib
3, buildPythonPackage
4, click
5, colorama
6, enum34
7, fetchPypi
8, git
9, gnugrep
10, gnupg
11, nose
12, pbr
13, pexpect
14, pythonAtLeast
15, pythonOlder
16, substituteAll
17, tree
18, xclip
19}:
20
21# Use the `pypass` top-level attribute, if you're interested in the
22# application
23buildPythonPackage rec {
24 pname = "pypass";
25 version = "0.2.1";
26
27 src = fetchPypi {
28 inherit pname version;
29 sha256 = "1nm4mj7pd7gz4ghic6b3wrnd1b59hd1f0axavdabfl79wy511l7r";
30 };
31
32 # Set absolute nix store paths to the executables that pypass uses
33 patches = [
34 (substituteAll {
35 src = ./mark-executables.patch;
36 git_exec = "${git}/bin/git";
37 grep_exec = "${gnugrep}/bin/grep";
38 gpg_exec = "${gnupg}/bin/gpg2";
39 tree_exec = "${tree}/bin/tree";
40 xclip_exec = "${xclip}/bin/xclip";
41 })
42 ];
43
44 # Remove enum34 requirement if Python >= 3.4
45 postPatch = lib.optionalString (pythonAtLeast "3.4") ''
46 substituteInPlace requirements.txt --replace "enum34" ""
47 '';
48
49 nativeBuildInputs = [ pbr ];
50
51 propagatedBuildInputs = [
52 click
53 colorama
54 pexpect
55 ] ++ lib.optional (pythonOlder "3.4") enum34;
56
57 nativeCheckInputs = [ nose ];
58
59 # Configuration so that the tests work
60 preCheck = ''
61 HOME=$TEMP ${git}/bin/git config --global user.email "nix-builder@nixos.org"
62 HOME=$TEMP ${git}/bin/git config --global user.name "Nix Builder"
63 HOME=$TEMP ${git}/bin/git config --global pull.ff only
64 HOME=$TEMP make setup_gpg
65 '';
66
67 # Run tests but exclude the test that uses clipboard as I wasn't able to make
68 # it work - probably the X clipboard just doesn't work in the build
69 # environment..
70 checkPhase = ''
71 runHook preCheck
72 HOME=$TEMP GNUPGHOME=pypass/tests/gnupg nosetests -v --exclude=test_show_clip .
73 runHook postCheck
74 '';
75
76 meta = with lib; {
77 broken = stdenv.isDarwin;
78 description = "Password manager pass in Python";
79 homepage = "https://github.com/aviau/python-pass";
80 license = licenses.gpl3Plus;
81 platforms = platforms.all;
82 maintainers = with maintainers; [ jluttine ];
83 };
84}