diff --git a/pkgs/by-name/gr/grafana-loki/package.nix b/pkgs/by-name/gr/grafana-loki/package.nix new file mode 100644 index 000000000000..8aeda3eb7495 --- /dev/null +++ b/pkgs/by-name/gr/grafana-loki/package.nix @@ -0,0 +1,88 @@ +{ + stdenv, + lib, + buildGoModule, + fetchFromGitHub, + makeWrapper, + nix-update-script, + nixosTests, + systemd, + testers, + grafana-loki, +}: + +buildGoModule rec { + version = "3.4.2"; + pname = "grafana-loki"; + + src = fetchFromGitHub { + owner = "grafana"; + repo = "loki"; + rev = "v${version}"; + hash = "sha256-GE92NlFCOk6qFtrgeBvLDI0OkmWaJ1j07Q14+jgi9+w="; + }; + + vendorHash = null; + + subPackages = [ + # TODO split every executable into its own package + "cmd/loki" + "cmd/loki-canary" + "clients/cmd/promtail" + "cmd/logcli" + "cmd/lokitool" + ]; + + tags = [ "promtail_journal_enabled" ]; + + nativeBuildInputs = [ makeWrapper ]; + buildInputs = lib.optionals stdenv.hostPlatform.isLinux [ systemd.dev ]; + + preFixup = lib.optionalString stdenv.hostPlatform.isLinux '' + wrapProgram $out/bin/promtail \ + --prefix LD_LIBRARY_PATH : "${lib.getLib systemd}/lib" + ''; + + passthru = { + tests = { + inherit (nixosTests) loki; + version = testers.testVersion { + command = "loki --version"; + package = grafana-loki; + }; + }; + + updateScript = nix-update-script { }; + }; + + ldflags = + let + t = "github.com/grafana/loki/v3/pkg/util/build"; + in + [ + "-s" + "-w" + "-X ${t}.Version=${version}" + "-X ${t}.BuildUser=nix@nixpkgs" + "-X ${t}.BuildDate=unknown" + "-X ${t}.Branch=unknown" + "-X ${t}.Revision=unknown" + ]; + + meta = with lib; { + description = "Like Prometheus, but for logs"; + mainProgram = "promtail"; + license = with licenses; [ + agpl3Only + asl20 + ]; + homepage = "https://grafana.com/oss/loki/"; + changelog = "https://github.com/grafana/loki/releases/tag/v${version}"; + maintainers = with maintainers; [ + willibutz + globin + mmahut + emilylange + ]; + }; +} diff --git a/pkgs/servers/monitoring/loki/promtail.nix b/pkgs/by-name/pr/promtail/package.nix similarity index 100% rename from pkgs/servers/monitoring/loki/promtail.nix rename to pkgs/by-name/pr/promtail/package.nix diff --git a/pkgs/servers/monitoring/loki/default.nix b/pkgs/servers/monitoring/loki/default.nix deleted file mode 100644 index d5434daeef38..000000000000 --- a/pkgs/servers/monitoring/loki/default.nix +++ /dev/null @@ -1,70 +0,0 @@ -{ stdenv -, lib -, buildGoModule -, fetchFromGitHub -, makeWrapper -, nixosTests -, systemd -, testers -, grafana-loki -}: - -buildGoModule rec { - version = "3.4.0"; - pname = "grafana-loki"; - - src = fetchFromGitHub { - owner = "grafana"; - repo = "loki"; - rev = "v${version}"; - hash = "sha256-fFdp2QZQgrLPcgzY833TfGvW7QPR/Omq0wwvcejMXac="; - }; - - vendorHash = null; - - subPackages = [ - # TODO split every executable into its own package - "cmd/loki" - "cmd/loki-canary" - "clients/cmd/promtail" - "cmd/logcli" - "cmd/lokitool" - ]; - - tags = ["promtail_journal_enabled"]; - - nativeBuildInputs = [ makeWrapper ]; - buildInputs = lib.optionals stdenv.hostPlatform.isLinux [ systemd.dev ]; - - preFixup = lib.optionalString stdenv.hostPlatform.isLinux '' - wrapProgram $out/bin/promtail \ - --prefix LD_LIBRARY_PATH : "${lib.getLib systemd}/lib" - ''; - - passthru.tests = { - inherit (nixosTests) loki; - version = testers.testVersion { - command = "loki --version"; - package = grafana-loki; - }; - }; - - ldflags = let t = "github.com/grafana/loki/v3/pkg/util/build"; in [ - "-s" - "-w" - "-X ${t}.Version=${version}" - "-X ${t}.BuildUser=nix@nixpkgs" - "-X ${t}.BuildDate=unknown" - "-X ${t}.Branch=unknown" - "-X ${t}.Revision=unknown" - ]; - - meta = with lib; { - description = "Like Prometheus, but for logs"; - mainProgram = "promtail"; - license = with licenses; [ agpl3Only asl20 ]; - homepage = "https://grafana.com/oss/loki/"; - changelog = "https://github.com/grafana/loki/releases/tag/v${version}"; - maintainers = with maintainers; [ willibutz globin mmahut emilylange ]; - }; -} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 29e0cc423c85..b2ab0a6b84d9 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -11263,9 +11263,6 @@ with pkgs; grafana = callPackage ../servers/monitoring/grafana { }; grafanaPlugins = callPackages ../servers/monitoring/grafana/plugins { }; - grafana-loki = callPackage ../servers/monitoring/loki { }; - promtail = callPackage ../servers/monitoring/loki/promtail.nix { }; - hasura-graphql-engine = haskell.lib.compose.justStaticExecutables haskell.packages.ghc810.graphql-engine; hasura-cli = callPackage ../servers/hasura/cli.nix { };