about summary refs log tree commit diff
path: root/pkgs/by-name/as/asc-key-to-qr-code-gif/package.nix
blob: e3f879d293afa4b451b01b294c70d6cbc2687729 (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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
{
  lib,
  stdenvNoCC,
  fetchFromGitHub,
  imagemagick,
  qrencode,
  testQR ? false,
  zbar ? null,
}:
assert testQR -> zbar != false;
stdenvNoCC.mkDerivation {
  pname = "asc-key-to-qr-code-gif";
  version = "0-unstable-2019-01-27";

  src = fetchFromGitHub {
    owner = "yishilin14";
    repo = "asc-key-to-qr-code-gif";
    rev = "5d36a1bada8646ae0f61b04356e62ba5ef10a1aa";
    sha256 = "sha256-DwxYgBsioL86WM6KBFJ+DuSJo3/1pwD1Fl156XD98RY=";
  };

  dontBuild = true;

  postPatch =
    let
      substitutions =
        [
          ''--replace-fail "convert" "${lib.getExe imagemagick}"''
          ''--replace-fail "qrencode" "${lib.getExe qrencode}"''
        ]
        ++ lib.optionals testQR [
          ''--replace-fail "hash zbarimg" "true"'' # hash does not work on NixOS
          ''--replace-fail "$(zbarimg --raw" "$(${zbar}/bin/zbarimg --raw"''
        ];
    in
    ''
      substituteInPlace asc-to-gif.sh ${lib.concatStringsSep " " substitutions}
    '';

  installPhase = ''
    runHook preInstall
    mkdir -p $out/bin
    cp asc-to-gif.sh $out/bin/asc-to-gif
    runHook postInstall
  '';

  meta = {
    homepage = "https://github.com/yishilin14/asc-key-to-qr-code-gif";
    description = "Convert ASCII-armored PGP keys to animated QR code";
    license = lib.licenses.unfree; # program does not have a license
    mainProgram = "asc-to-gif";
    platforms = lib.platforms.unix;
    maintainers = with lib.maintainers; [
      asymmetric
      NotAShelf
    ];
  };
}