1{ lib, python3Packages, fetchFromGitHub }:
2
3let
4 inherit (python3Packages) buildPythonApplication pythonOlder;
5
6in
7buildPythonApplication rec {
8 pname = "pwgen-secure";
9 version = "0.9.1";
10
11 # it needs `secrets` which was introduced in 3.6
12 disabled = pythonOlder "3.6";
13
14 # GH is newer than Pypi and contains both library *and* the actual program
15 # whereas Pypi only has the library
16 src = fetchFromGitHub {
17 owner = "mjmunger";
18 repo = "pwgen_secure";
19 rev = "v${version}";
20 sha256 = "15md5606hzy1xfhj2lxmc0nvynyrcs4vxa5jdi34kfm31rdklj28";
21 };
22
23 postPatch = ''
24 shareDir=$out/share/${pname}
25
26 substituteInPlace pwgen_secure/rpg.py \
27 --replace "os.path.join(path, 'words.txt')" "os.path.join('$shareDir', 'words.txt')"
28 '';
29
30 propagatedBuildInputs = with python3Packages; [ docopt ];
31
32 postInstall = ''
33 install -Dm555 spwgen.py $out/bin/spwgen
34 install -Dm444 pwgen_secure/words.txt -t $shareDir
35 '';
36
37 # there are no checks
38 doCheck = false;
39
40 meta = with lib; {
41 description = "Secure password generation library to replace pwgen";
42 homepage = "https://github.com/mjmunger/pwgen_secure/";
43 license = licenses.mit;
44 maintainers = with maintainers; [ peterhoeg ];
45 mainProgram = "spwgen";
46 };
47}