1{
2 lib,
3 stdenv,
4 cmake,
5 fetchFromGitLab,
6 json_c,
7 libsodium,
8 libxml2,
9 ncurses,
10}:
11
12let
13 rev = "22796663dcad81684ab24308d9db570f6781ba2c";
14
15in
16stdenv.mkDerivation rec {
17 name = "mpw-${version}-${builtins.substring 0 8 rev}";
18 version = "2.6";
19
20 src = fetchFromGitLab {
21 owner = "MasterPassword";
22 repo = "MasterPassword";
23 sha256 = "1f2vqacgbyam1mazawrfim8zwp38gnwf5v3xkkficsfnv789g6fw";
24 inherit rev;
25 };
26
27 sourceRoot = "${src.name}/platform-independent/c/cli";
28
29 postPatch = ''
30 rm build
31 substituteInPlace mpw-cli-tests \
32 --replace '/usr/bin/env bash' ${stdenv.shell} \
33 --replace ./mpw ./build/mpw
34 '';
35
36 cmakeFlags = [
37 "-Dmpw_version=${version}"
38 "-DBUILD_MPW_TESTS=ON"
39 ];
40
41 nativeBuildInputs = [ cmake ];
42
43 buildInputs = [
44 json_c
45 libxml2
46 libsodium
47 ncurses
48 ];
49
50 installPhase = ''
51 runHook preInstall
52
53 install -Dm755 mpw $out/bin/mpw
54 install -Dm644 ../mpw.completion.bash $out/share/bash-completion/completions/_mpw
55 install -Dm644 ../../../../README.md $out/share/doc/mpw/README.md
56
57 runHook postInstall
58 '';
59
60 # Some tests are expected to fail on ARM64
61 # See: https://gitlab.com/spectre.app/cli/-/issues/27#note_962950844 (mpw is a predecessor to spectre-cli and this issue is relevant to mpw as well)
62 doCheck = !(stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isAarch64);
63
64 checkPhase = ''
65 runHook preCheck
66
67 ../mpw-cli-tests
68
69 runHook postCheck
70 '';
71
72 meta = with lib; {
73 description = "Stateless password management solution";
74 mainProgram = "mpw";
75 homepage = "https://masterpasswordapp.com/";
76 license = licenses.gpl3;
77 platforms = platforms.unix;
78 };
79}