2021-04-06 03:31:10 +02:00
|
|
|
{ stdenv
|
|
|
|
, lib
|
|
|
|
, buildGoModule
|
|
|
|
, fetchFromGitHub
|
|
|
|
, makeWrapper
|
|
|
|
, nixosTests
|
|
|
|
, systemd
|
2020-11-10 10:46:30 +01:00
|
|
|
}:
|
2019-03-01 08:18:57 +01:00
|
|
|
|
2020-10-29 01:13:01 +01:00
|
|
|
buildGoModule rec {
|
2021-04-06 03:53:51 +02:00
|
|
|
version = "2.2.1";
|
2019-08-15 14:41:18 +02:00
|
|
|
pname = "grafana-loki";
|
2019-03-01 08:18:57 +01:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
rev = "v${version}";
|
|
|
|
owner = "grafana";
|
|
|
|
repo = "loki";
|
2021-04-06 03:53:51 +02:00
|
|
|
sha256 = "sha256-ujZD5GIgMewvEQW3Wnt0eHdMIFs77PkkEecgCDw9290=";
|
2019-03-01 08:18:57 +01:00
|
|
|
};
|
|
|
|
|
2020-10-29 01:13:01 +01:00
|
|
|
vendorSha256 = null;
|
|
|
|
|
2021-03-15 19:10:46 +01:00
|
|
|
subPackages = [
|
|
|
|
# TODO split every executable into its own package
|
|
|
|
"cmd/loki"
|
|
|
|
"cmd/loki-canary"
|
|
|
|
"cmd/promtail"
|
|
|
|
"cmd/logcli"
|
|
|
|
];
|
2020-10-29 01:13:01 +01:00
|
|
|
|
2019-08-03 00:19:14 +02:00
|
|
|
nativeBuildInputs = [ makeWrapper ];
|
2021-01-15 08:07:56 +01:00
|
|
|
buildInputs = lib.optionals stdenv.isLinux [ systemd.dev ];
|
2019-08-03 00:19:14 +02:00
|
|
|
|
2021-01-15 08:07:56 +01:00
|
|
|
preFixup = lib.optionalString stdenv.isLinux ''
|
2020-04-28 03:50:57 +02:00
|
|
|
wrapProgram $out/bin/promtail \
|
2020-08-12 20:19:12 +02:00
|
|
|
--prefix LD_LIBRARY_PATH : "${lib.getLib systemd}/lib"
|
2019-08-03 00:19:14 +02:00
|
|
|
'';
|
|
|
|
|
2020-11-10 10:46:30 +01:00
|
|
|
passthru.tests = { inherit (nixosTests) loki; };
|
|
|
|
|
2021-04-06 03:31:10 +02:00
|
|
|
buildFlagsArray = let t = "github.com/grafana/loki/pkg/build"; in
|
|
|
|
''
|
|
|
|
-ldflags=-s -w -X ${t}.Version=${version} -X ${t}.BuildUser=nix@nixpkgs -X ${t}.BuildDate=unknown -X ${t}.Branch=unknown -X ${t}.Revision=unknown
|
|
|
|
'';
|
2021-03-03 00:12:37 +01:00
|
|
|
|
2020-10-29 01:13:01 +01:00
|
|
|
doCheck = true;
|
|
|
|
|
2021-01-11 08:54:33 +01:00
|
|
|
meta = with lib; {
|
2019-11-21 13:18:43 +01:00
|
|
|
description = "Like Prometheus, but for logs";
|
2019-03-01 08:18:57 +01:00
|
|
|
license = licenses.asl20;
|
2019-12-15 04:22:22 +01:00
|
|
|
homepage = "https://grafana.com/oss/loki/";
|
2019-11-21 13:18:43 +01:00
|
|
|
maintainers = with maintainers; [ willibutz globin mmahut ];
|
2019-12-15 04:22:22 +01:00
|
|
|
platforms = platforms.unix;
|
2019-03-01 08:18:57 +01:00
|
|
|
};
|
|
|
|
}
|