In the Master Password derivation the bash completion file is copied but not a file it source
s and requires to work. Because of this completing mpw
fails with message _comp_finish_completions: command not found
, which is defined in the missing file. How could this be fixed?
I tried this and I think it should work (not sure how to test it):
{ lib, stdenv, cmake, fetchFromGitLab
, json_c, libsodium, libxml2, ncurses }:
let
rev = "22796663dcad81684ab24308d9db570f6781ba2c";
in stdenv.mkDerivation rec {
name = "mpw-${version}-${builtins.substring 0 8 rev}";
version = "2.6";
src = fetchFromGitLab {
owner = "MasterPassword";
repo = "MasterPassword";
sha256 = "1f2vqacgbyam1mazawrfim8zwp38gnwf5v3xkkficsfnv789g6fw";
inherit rev;
};
sourceRoot = "./source/platform-independent/c/cli";
postPatch = ''
rm build
substituteInPlace mpw-cli-tests \
--replace '/usr/bin/env bash' ${stdenv.shell} \
--replace ./mpw ./build/mpw
substituteInPlace mpw.completion.bash \
--replace bashcomplib "${
builtins.placeholder "out"
}/share/bash-completion/completions/bashcomplib"
'';
cmakeFlags = [
"-Dmpw_version=${version}"
"-DBUILD_MPW_TESTS=ON"
];
nativeBuildInputs = [ cmake ];
buildInputs = [ json_c libxml2 libsodium ncurses ];
installPhase = ''
runHook preInstall
install -Dm755 mpw $out/bin/mpw
install -Dm644 ../mpw.completion.bash $out/share/bash-completion/completions/_mpw
install -Dm644 ../bashcomplib $out/share/bash-completion/completions/bashcomplib
install -Dm644 ../../../../README.md $out/share/doc/mpw/README.md
runHook postInstall
'';
doCheck = true;
checkPhase = ''
runHook preCheck
../mpw-cli-tests
runHook postCheck
'';
meta = with lib; {
description = "A stateless password management solution";
homepage = "https://masterpasswordapp.com/";
license = licenses.gpl3;
platforms = platforms.unix;
};
}
The patch being
diff --git a/pkgs/tools/security/mpw/default.nix b/pkgs/tools/security/mpw/default.nix
index 3973ed51343..7e9f93d7340 100644
--- a/pkgs/tools/security/mpw/default.nix
+++ b/pkgs/tools/security/mpw/default.nix
@@ -22,6 +22,10 @@ in stdenv.mkDerivation rec {
substituteInPlace mpw-cli-tests \
--replace '/usr/bin/env bash' ${stdenv.shell} \
--replace ./mpw ./build/mpw
+ substituteInPlace mpw.completion.bash \
+ --replace bashcomplib "${
+ builtins.placeholder "out"
+ }/share/bash-completion/completions/bashcomplib"
'';
cmakeFlags = [
@@ -38,6 +42,7 @@ in stdenv.mkDerivation rec {
install -Dm755 mpw $out/bin/mpw
install -Dm644 ../mpw.completion.bash $out/share/bash-completion/completions/_mpw
+ install -Dm644 ../bashcomplib $out/share/bash-completion/completions/bashcomplib
install -Dm644 ../../../../README.md $out/share/doc/mpw/README.md
runHook postInstall
I got the builtins.placeholder
from other derivations in nixpkgs
, but it seems to work without anyhow, not sure if it’s needed. Also, I think that bashcomplib could collide with a file from another package as it doesn’t seem to be a specific name. Would like suggestions.
Thanks.