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