1{lib, stdenv, git, perl, ncurses, coreutils, fetchFromGitHub, makeWrapper, ...}:
2
3stdenv.mkDerivation rec {
4 pname = "diff-so-fancy";
5 version = "1.4.3";
6
7 src = fetchFromGitHub {
8 owner = "so-fancy";
9 repo = "diff-so-fancy";
10 rev = "v${version}";
11 sha256 = "sha256-/xdBvq2u1s5/yzjwr3MLxpaD1CNktcPijXJTKW3Bc4c=";
12 };
13
14 nativeBuildInputs = [
15 makeWrapper
16 ];
17
18 buildInputs = [
19 perl # needed for patchShebangs
20 ];
21
22 dontBuild = true;
23
24 installPhase = ''
25 runHook preInstall
26
27 mkdir -p $out/bin $out/lib/diff-so-fancy
28
29 # diff-so-fancy executable searches for it's library relative to
30 # itself, so we are copying executable to lib, and only symlink it
31 # from bin/
32 cp diff-so-fancy $out/lib/diff-so-fancy
33 cp -r lib $out/lib/diff-so-fancy
34 ln -s $out/lib/diff-so-fancy/diff-so-fancy $out/bin
35
36 # ncurses is needed for `tput`
37 wrapProgram $out/lib/diff-so-fancy/diff-so-fancy \
38 --prefix PATH : "${git}/share/git/contrib/diff-highlight" \
39 --prefix PATH : "${git}/bin" \
40 --prefix PATH : "${coreutils}/bin" \
41 --prefix PATH : "${ncurses.out}/bin"
42
43 runHook postInstall
44 '';
45
46 meta = with lib; {
47 homepage = "https://github.com/so-fancy/diff-so-fancy";
48 description = "Good-looking diffs filter for git";
49 license = licenses.mit;
50 platforms = platforms.all;
51 longDescription = ''
52 diff-so-fancy builds on the good-lookin' output of git contrib's
53 diff-highlight to upgrade your diffs' appearances.
54 '';
55 maintainers = with maintainers; [ fpletz globin ma27 ];
56 };
57}