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