summary refs log tree commit diff
path: root/pkgs/applications/misc/gpg-mdp/default.nix
blob: 08ab2a5b7d9f605aaef6ff81d22db007e9cdc5f5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
{ fetchurl, fetchpatch, lib, stdenv, ncurses, gnupg }:

let version = "0.7.4";
in stdenv.mkDerivation {
  # mdp renamed to gpg-mdp because there is a mdp package already.
  pname = "gpg-mdp";
  inherit version;
  meta = {
    homepage = "https://tamentis.com/projects/mdp/";
    license = [lib.licenses.isc];
    description = "Manage your passwords with GnuPG and a text editor";
  };
  src = fetchurl {
    url = "https://tamentis.com/projects/mdp/files/mdp-${version}.tar.gz";
    sha256 = "04mdnx4ccpxf9m2myy9nvpl9ma4jgzmv9bkrzv2b9affzss3r34g";
  };
  patches = [
    # Pull fix pending upstream inclusion for -fno-common toolchain support:
    #   https://github.com/tamentis/mdp/pull/9
    (fetchpatch {
      name = "fno-common.patch";
      url = "https://github.com/tamentis/mdp/commit/95c77de3beb96dc7c76ff36d3f3dfb18411d7c54.patch";
      sha256 = "1j6yvjzkx31b758yav4arhlm5ig7phl8mgx4fcwj7lm2pfvzwcsz";
    })
  ];
  buildInputs = [ ncurses ];
  prePatch = ''
    substituteInPlace ./configure \
      --replace "alias echo=/bin/echo" ""

    substituteInPlace ./src/config.c \
      --replace "/usr/bin/gpg" "${gnupg}/bin/gpg" \
      --replace "/usr/bin/vi" "vi"

    substituteInPlace ./mdp.1 \
      --replace "/usr/bin/gpg" "${gnupg}/bin/gpg"
  '';
  # we add symlinks to the binary and man page with the name 'gpg-mdp', in case
  # the completely unrelated program also named 'mdp' is already installed.
  postFixup = ''
    ln -s $out/bin/mdp $out/bin/gpg-mdp
    ln -s $out/share/man/man1/mdp.1.gz $out/share/man/man1/gpg-mdp.1.gz
  '';
}