1{ lib
2, buildPythonPackage
3, click
4, colorama
5, enum34
6, fetchPypi
7, git
8, gnugrep
9, gnupg
10, nose
11, pbr
12, pexpect
13, pythonAtLeast
14, pythonOlder
15, substituteAll
16, tree
17, xclip
18}:
19
20# NOTE: pypass can also be used as an application, but probably the most
21# important usecase is as a library. So, let's use buildPythonPackage and
22# support any Python version instead of defining it as an application with
23# buildPythonApplication.
24buildPythonPackage rec {
25 pname = "pypass";
26 version = "0.2.1";
27
28 src = fetchPypi {
29 inherit pname version;
30 sha256 = "1nm4mj7pd7gz4ghic6b3wrnd1b59hd1f0axavdabfl79wy511l7r";
31 };
32
33 # Set absolute nix store paths to the executables that pypass uses
34 patches = [
35 (substituteAll {
36 src = ./mark-executables.patch;
37 git_exec = "${git}/bin/git";
38 grep_exec = "${gnugrep}/bin/grep";
39 gpg_exec = "${gnupg}/bin/gpg2";
40 tree_exec = "${tree}/bin/tree";
41 xclip_exec = "${xclip}/bin/xclip";
42 })
43 ];
44
45 # Remove enum34 requirement if Python >= 3.4
46 postPatch = lib.optionalString (pythonAtLeast "3.4") ''
47 substituteInPlace requirements.txt --replace "enum34" ""
48 '';
49
50 nativeBuildInputs = [ pbr ];
51
52 propagatedBuildInputs = [
53 click
54 colorama
55 pexpect
56 ] ++ lib.optional (pythonOlder "3.4") enum34;
57
58 checkInputs = [ nose ];
59
60 # Configuration so that the tests work
61 preCheck = ''
62 HOME=$TEMP ${git}/bin/git config --global user.email "nix-builder@nixos.org"
63 HOME=$TEMP ${git}/bin/git config --global user.name "Nix Builder"
64 HOME=$TEMP ${git}/bin/git config --global pull.ff only
65 HOME=$TEMP make setup_gpg
66 '';
67
68 # Run tests but exclude the test that uses clipboard as I wasn't able to make
69 # it work - probably the X clipboard just doesn't work in the build
70 # environment..
71 checkPhase = ''
72 runHook preCheck
73 HOME=$TEMP GNUPGHOME=pypass/tests/gnupg nosetests -v --exclude=test_show_clip .
74 runHook postCheck
75 '';
76
77 meta = with lib; {
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}