nixpkgs/pkgs/tools/security/asc-key-to-qr-code-gif/default.nix
Profpatsch 4a7f99d55d treewide: with stdenv.lib; in meta -> with lib;
Part of: https://github.com/NixOS/nixpkgs/issues/108938

meta = with stdenv.lib;

is a widely used pattern. We want to slowly remove
the `stdenv.lib` indirection and encourage people
to use `lib` directly. Thus let’s start with the meta
field.

This used a rewriting script to mostly automatically
replace all occurances of this pattern, and add the
`lib` argument to the package header if it doesn’t
exist yet.

The script in its current form is available at
https://cs.tvl.fyi/depot@2f807d7f141068d2d60676a89213eaa5353ca6e0/-/blob/users/Profpatsch/nixpkgs-rewriter/default.nix
2021-01-11 10:38:22 +01:00

46 lines
1.2 KiB
Nix

{ lib, stdenv, fetchFromGitHub, imagemagick, qrencode
, testQR ? false, zbar ? null
}:
assert testQR -> zbar != false;
stdenv.mkDerivation {
pname = "asc-key-to-qr-code-gif";
version = "20180613";
src = fetchFromGitHub {
owner = "yishilin14";
repo = "asc-key-to-qr-code-gif";
rev = "5b7b239a0089a5269444cbe8a651c99dd43dce3f";
sha256 = "0yrc302a2fhbzryb10718ky4fymfcps3lk67ivis1qab5kbp6z8r";
};
dontBuild = true;
dontStrip = true;
dontPatchELF = true;
preInstall = let
substitutions = [
''--replace "convert" "${imagemagick}/bin/convert"''
''--replace "qrencode" "${qrencode.bin}/bin/qrencode"''
] ++ stdenv.lib.optional testQR [
''--replace "hash zbarimg" "true"'' # hash does not work on NixOS
''--replace "$(zbarimg --raw" "$(${zbar.out}/bin/zbarimg --raw"''
];
in ''
substituteInPlace asc-to-gif.sh ${stdenv.lib.concatStringsSep " " substitutions}
'';
installPhase = ''
mkdir -p $out/bin
cp * $out/bin/
'';
meta = with lib; {
homepage = "https://github.com/yishilin14/asc-key-to-qr-code-gif";
description = "Convert ASCII-armored PGP keys to animated QR code";
platforms = platforms.linux;
maintainers = with maintainers; [ asymmetric ];
};
}