Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ stdenv
2, lib
3, buildGoModule
4, fetchFromGitHub
5, makeWrapper
6, nixosTests
7, systemd
8}:
9
10buildGoModule rec {
11 version = "2.8.2";
12 pname = "grafana-loki";
13
14 src = fetchFromGitHub {
15 owner = "grafana";
16 repo = "loki";
17 rev = "v${version}";
18 hash = "sha256-29cpDLIwKw0CaYaNGv31E7sNTaRepymjvAZ8TL4RpxY=";
19 };
20
21 vendorHash = null;
22
23 subPackages = [
24 # TODO split every executable into its own package
25 "cmd/loki"
26 "cmd/loki-canary"
27 "clients/cmd/promtail"
28 "cmd/logcli"
29 ];
30
31 tags = ["promtail_journal_enabled"];
32
33 nativeBuildInputs = [ makeWrapper ];
34 buildInputs = lib.optionals stdenv.isLinux [ systemd.dev ];
35
36 preFixup = lib.optionalString stdenv.isLinux ''
37 wrapProgram $out/bin/promtail \
38 --prefix LD_LIBRARY_PATH : "${lib.getLib systemd}/lib"
39 '';
40
41 passthru.tests = { inherit (nixosTests) loki; };
42
43 ldflags = let t = "github.com/grafana/loki/pkg/util/build"; in [
44 "-s"
45 "-w"
46 "-X ${t}.Version=${version}"
47 "-X ${t}.BuildUser=nix@nixpkgs"
48 "-X ${t}.BuildDate=unknown"
49 "-X ${t}.Branch=unknown"
50 "-X ${t}.Revision=unknown"
51 ];
52
53 meta = with lib; {
54 description = "Like Prometheus, but for logs";
55 license = with licenses; [ agpl3Only asl20 ];
56 homepage = "https://grafana.com/oss/loki/";
57 changelog = "https://github.com/grafana/loki/releases/tag/v${version}";
58 maintainers = with maintainers; [ willibutz globin mmahut emilylange ];
59 };
60}