nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 perl,
6 perlPackages,
7 makeWrapper,
8 glibc,
9}:
10
11stdenv.mkDerivation rec {
12 version = "1.1.5";
13 pname = "longview";
14
15 src = fetchFromGitHub {
16 owner = "linode";
17 repo = "longview";
18 rev = "v${version}";
19 sha256 = "1i9lli8iw8sb1bd633i82fzhx5gz85ma9d1hra41pkv2p3h823pa";
20 };
21
22 patches = [
23 # log to systemd journal
24 ./log-stdout.patch
25 ];
26
27 # Read all configuration from /run/longview
28 postPatch = ''
29 substituteInPlace Linode/Longview/Util.pm \
30 --replace /var/run/longview.pid /run/longview/longview.pid \
31 --replace /etc/linode /run/longview
32 substituteInPlace Linode/Longview.pl \
33 --replace /etc/linode /run/longview
34 '';
35
36 nativeBuildInputs = [ makeWrapper ];
37 buildInputs = [
38 perl
39 glibc
40 ]
41 ++ (with perlPackages; [
42 LWP
43 LWPProtocolHttps
44 MozillaCA
45 CryptSSLeay
46 IOSocketINET6
47 LinuxDistribution
48 JSONPP
49 JSON
50 LogLogLite
51 TryTiny
52 DBI
53 DBDmysql
54 ]);
55
56 dontBuild = true;
57
58 installPhase = ''
59 mkdir -p $out/bin $out/usr
60 mv Linode $out
61 ln -s ../Linode/Longview.pl $out/bin/longview
62 for h in syscall.h sys/syscall.h asm/unistd.h asm/unistd_32.h asm/unistd_64.h bits/wordsize.h bits/syscall.h; do
63 ${perl}/bin/h2ph -d $out ${glibc.dev}/include/$h
64 mkdir -p $out/usr/include/$(dirname $h)
65 mv $out${glibc.dev}/include/''${h%.h}.ph $out/usr/include/$(dirname $h)
66 done
67 wrapProgram $out/Linode/Longview.pl --prefix PATH : ${perl}/bin:$out/bin \
68 --suffix PERL5LIB : $out/Linode --suffix PERL5LIB : $PERL5LIB \
69 --suffix PERL5LIB : $out --suffix INC : $out
70 '';
71
72 meta = {
73 homepage = "https://www.linode.com/longview";
74 description = "Collects all of your system-level metrics and sends them to Linode";
75 mainProgram = "longview";
76 license = lib.licenses.gpl2Plus;
77 maintainers = [ lib.maintainers.rvl ];
78 inherit version;
79 platforms = [
80 "x86_64-linux"
81 "i686-linux"
82 ];
83 };
84}