From 222dfa755cd84c6cc87778878c5e2cb5c7da5625 Mon Sep 17 00:00:00 2001 From: Pierre Penninckx Date: Sun, 21 Apr 2024 23:07:32 -0700 Subject: [PATCH] Revert to loki v2 (#230) This is needed because v3 requires manual intervention to upgrade otherwise Loki refuses to start. So until there's a fix, reverting is the easiest fix. --- CHANGELOG.md | 9 +++++++++ modules/blocks/monitoring.nix | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..f7d8d7f --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,9 @@ +# Upcoming + +- Revert Loki to major version 2 because upgrading to version 3 required manual intervention as Loki + refuses to start. So until this issue is tackled, reverting is the best immediate fix. + See https://github.com/NixOS/nixpkgs/commit/8f95320f39d7e4e4a29ee70b8718974295a619f4 + +# 0.1.0 + +Creation of CHANGELOG.md diff --git a/modules/blocks/monitoring.nix b/modules/blocks/monitoring.nix index cda1afc..2a63534 100644 --- a/modules/blocks/monitoring.nix +++ b/modules/blocks/monitoring.nix @@ -47,6 +47,16 @@ in default = 3002; }; + lokiMajorVersion = lib.mkOption { + type = lib.types.enum [ 2 3 ]; + description = '' + Switching from version 2 to 3 requires manual intervention + https://grafana.com/docs/loki/latest/setup/upgrade/#main--unreleased. So this let's the user + upgrade at their own pace. + ''; + default = 2; + }; + debugLog = lib.mkOption { type = lib.types.bool; description = "Set to true to enable debug logging of the infrastructure serving Grafana."; @@ -266,6 +276,28 @@ in services.loki = { enable = true; dataDir = "/var/lib/loki"; + package = if cfg.lokiMajorVersion == 3 then pkgs.grafana-loki else + # Comes from https://github.com/NixOS/nixpkgs/commit/8f95320f39d7e4e4a29ee70b8718974295a619f4 + (pkgs.grafana-loki.overrideAttrs (finalAttrs: previousAttrs: rec { + version = "2.9.6"; + + src = pkgs.fetchFromGitHub { + owner = "grafana"; + repo = "loki"; + rev = "v${version}"; + hash = "sha256-79hK7axHf6soku5DvdXkE/0K4WKc4pnS9VMbVc1FS2I="; + }; + + ldflags = let t = "github.com/grafana/loki/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" + ]; + })); configuration = { auth_enabled = false;