summary refs log tree commit diff
path: root/pkgs/development/tools/misc/libtree/default.nix
blob: f852b7ea7adfdeb50a1ff0643b054a092aa0fbdd (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
{ lib
, stdenv
, fetchFromGitHub
, fetchpatch
, binutils
, chrpath
, cmake
, cxxopts
, elfio
, termcolor
, gtest
}:

stdenv.mkDerivation rec {
  pname = "libtree";
  version = "2.0.0";

  src = fetchFromGitHub {
    owner = "haampie";
    repo = "libtree";
    rev = "v${version}";
    sha256 = "sha256-j54fUwMkX4x4MwL8gMraguK9GqQRBjCC+W6ojFnQdHQ=";
  };

  patches = [
    # add missing include
    # https://github.com/haampie/libtree/pull/42
    (fetchpatch {
      url = "https://github.com/haampie/libtree/commit/219643ff6edcae42c9546b8ba38cfec9d19b034e.patch";
      sha256 = "sha256-vdFmmBdBiOT3QBcwd3SuiolcaFTFAb88kU1KN8229K0=";
    })
  ];

  postPatch = ''
    substituteInPlace src/main.cpp \
      --replace "std::string strip = \"strip\";" "std::string strip = \"${binutils}/bin/strip\";" \
      --replace "std::string chrpath = \"chrpath\";" "std::string chrpath = \"${chrpath}/bin/chrpath\";"
  '';

  nativeBuildInputs = [ cmake ];

  buildInputs = [ cxxopts elfio termcolor ];

  doCheck = true;

  checkInputs = [ gtest ];

  cmakeFlags = [ "-DLIBTREE_BUILD_TESTS=ON" ];

  meta = with lib; {
    description = "Tree ldd with an option to bundle dependencies into a single folder";
    homepage = "https://github.com/haampie/libtree";
    license = licenses.mit;
    platforms = platforms.linux;
    maintainers = with maintainers; [ prusnak rardiol ];
  };
}