nixpkgs/pkgs/applications/version-management/git-and-tools/diff-so-fancy/default.nix
Jan Tojnar 2b6f959c3b gitAndTools.diff-so-fancy: Fix shebang patching and clean up
perl is a runtime dependency so it needs to be in buildInputs,
otherwise patchShebangs hook will not see it.
2020-08-21 12:31:29 -07:00

58 lines
1.5 KiB
Nix

{stdenv, git, perl, ncurses, coreutils, fetchFromGitHub, makeWrapper, ...}:
stdenv.mkDerivation rec {
pname = "diff-so-fancy";
version = "1.3.0";
src = fetchFromGitHub {
owner = "so-fancy";
repo = "diff-so-fancy";
rev = "v${version}";
sha256 = "0aavxahzha2mms4vdwysk79pa6wzswpfwgsq2hwaxnaf66maahfl";
};
nativeBuildInputs = [
makeWrapper
];
buildInputs = [
perl # needed for patchShebangs
];
dontBuild = true;
installPhase = ''
runHook preInstall
mkdir -p $out/bin $out/lib/diff-so-fancy
# diff-so-fancy executable searches for it's library relative to
# itself, so we are copying executable to lib, and only symlink it
# from bin/
cp diff-so-fancy $out/lib/diff-so-fancy
cp -r lib $out/lib/diff-so-fancy
ln -s $out/lib/diff-so-fancy/diff-so-fancy $out/bin
# ncurses is needed for `tput`
wrapProgram $out/lib/diff-so-fancy/diff-so-fancy \
--prefix PATH : "${git}/share/git/contrib/diff-highlight" \
--prefix PATH : "${git}/bin" \
--prefix PATH : "${coreutils}/bin" \
--prefix PATH : "${ncurses.out}/bin"
runHook postInstall
'';
meta = with stdenv.lib; {
homepage = "https://github.com/so-fancy/diff-so-fancy";
description = "Good-looking diffs filter for git";
license = licenses.mit;
platforms = platforms.all;
longDescription = ''
diff-so-fancy builds on the good-lookin' output of git contrib's
diff-highlight to upgrade your diffs' appearances.
'';
maintainers = with maintainers; [ fpletz globin ];
};
}