lesspipe: validate and add script dependencies

use resholve to wrap lesspipe.sh and lesscomplete forcing external
references to be declared
This commit is contained in:
Anund 2023-09-10 22:25:02 +10:00
parent cfc3698c31
commit 2e2671126e

View File

@ -1,4 +1,22 @@
{ lib, stdenv, fetchFromGitHub, makeWrapper, perl, procps, file, gnused, bash, binutils }:
{ lib
, stdenv
, fetchFromGitHub
, makeWrapper
, perl
, procps
, bash
# shell referenced dependencies
, resholve
, binutils-unwrapped
, file
, gnugrep
, coreutils
, gnused
, gnutar
, iconv
, ncurses
}:
stdenv.mkDerivation rec {
pname = "lesspipe";
@ -28,9 +46,65 @@ stdenv.mkDerivation rec {
installFlags = [ "DESTDIR=$(out)" ];
postInstall = ''
for f in lesspipe.sh lesscomplete; do
wrapProgram "$out/bin/$f" --prefix-each PATH : "${lib.makeBinPath [ binutils file gnused procps ]}"
done
# resholve doesn't see strings in an array definition
substituteInPlace $out/bin/lesspipe.sh --replace 'nodash strings' "nodash ${binutils-unwrapped}/bin/strings"
${resholve.phraseSolution "lesspipe.sh" {
scripts = [ "bin/lesspipe.sh" ];
interpreter = "${bash}/bin/bash";
inputs = [
coreutils
file
gnugrep
gnused
gnutar
iconv
procps
ncurses
];
keep = [ "$prog" "$c1" "$c2" "$c3" "$c4" "$c5" "$cmd" "$colorizer" "$HOME" ];
fake = {
# script guards usage behind has_cmd test function, it's safe to leave these external and optional
external = [
"cpio" "isoinfo" "cabextract" "bsdtar" "rpm2cpio" "bsdtar" "unzip" "ar" "unrar" "rar" "7zr" "7za" "isoinfo"
"gzip" "bzip2" "lzip" "lzma" "xz" "brotli" "compress" "zstd" "lz4"
"archive_color" "bat" "batcat" "pygmentize" "source-highlight" "vimcolor" "code2color"
"w3m" "lynx" "elinks" "html2text" "dtc" "pdftotext" "pdftohtml" "pdfinfo" "ps2ascii" "procyon" "ccze"
"mdcat" "pandoc" "docx2txt" "libreoffice" "pptx2md" "mdcat" "xlscat" "odt2txt" "wvText" "antiword" "catdoc"
"broken_catppt" "sxw2txt" "groff" "mandoc" "unrtf" "dvi2tty" "pod2text" "perldoc" "h5dump" "ncdump" "matdump"
"djvutxt" "openssl" "gpg" "plistutil" "plutil" "id3v2" "csvlook" "jq" "zlib-flate" "lessfilter"
] ++ lib.optional stdenv.isDarwin [
# resholve only identifies this on darwin
# call site is gaurded by || so it's safe to leave dynamic
"locale"
];
builtin = [ "setopt" ];
};
execer = [
"cannot:${iconv}/bin/iconv"
];
}}
${resholve.phraseSolution "lesscomplete" {
scripts = [ "bin/lesscomplete" ];
interpreter = "${bash}/bin/bash";
inputs = [
coreutils
file
gnugrep
gnused
gnutar
];
keep = [ "$prog" "$c1" "$c2" "$c3" "$c4" "$c5" "$cmd" ];
fake = {
# script guards usage behind has_cmd test function, it's safe to leave these external and optional
external = [
"cpio" "isoinfo" "cabextract" "bsdtar" "rpm2cpio" "bsdtar" "unzip" "ar" "unrar" "rar" "7zr" "7za" "isoinfo"
"gzip" "bzip2" "lzip" "lzma" "xz" "brotli" "compress" "zstd" "lz4"
];
builtin = [ "setopt" ];
};
}}
'';
meta = with lib; {