mirror of
https://github.com/SebastianWendel/nixpkgs.git
synced 2024-09-29 08:30:21 +02:00
Merge pull request #168623 from Ma27/bump-grafana
grafana: add update-script, (no-op) update 8.4.5 -> 8.4.6
This commit is contained in:
commit
910b3d28a5
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
buildGoModule rec {
|
buildGoModule rec {
|
||||||
pname = "grafana";
|
pname = "grafana";
|
||||||
version = "8.4.5";
|
version = "8.4.6";
|
||||||
|
|
||||||
excludedPackages = [ "alert_webhook_listener" "clean-swagger" "release_publisher" "slow_proxy" "slow_proxy_mac" "macaron" ];
|
excludedPackages = [ "alert_webhook_listener" "clean-swagger" "release_publisher" "slow_proxy" "slow_proxy_mac" "macaron" ];
|
||||||
|
|
||||||
|
@ -10,12 +10,12 @@ buildGoModule rec {
|
||||||
rev = "v${version}";
|
rev = "v${version}";
|
||||||
owner = "grafana";
|
owner = "grafana";
|
||||||
repo = "grafana";
|
repo = "grafana";
|
||||||
sha256 = "sha256-CdGg979c7XD5V3jZbVeHUGylAarGc+cR+bFi5FngKtU=";
|
sha256 = "sha256-BXAvsHP6bDMrSk5jMCJmvrS1w/d+Mmym+OMCqO2YozY=";
|
||||||
};
|
};
|
||||||
|
|
||||||
srcStatic = fetchurl {
|
srcStatic = fetchurl {
|
||||||
url = "https://dl.grafana.com/oss/release/grafana-${version}.linux-amd64.tar.gz";
|
url = "https://dl.grafana.com/oss/release/grafana-${version}.linux-amd64.tar.gz";
|
||||||
sha256 = "sha256-PjDTEmzjDmT1WQGqF3GwojJ6mG2whBoPK0KWfXI8AB4=";
|
sha256 = "1af0277kb2msjqjv2kxajpxia4q4y2bslf009fx13h2c0grv8j7f";
|
||||||
};
|
};
|
||||||
|
|
||||||
vendorSha256 = "sha256-iOJEy7dCZGRTaOuL/09wcMlNDHjRi9SIr9bialdcKi4=";
|
vendorSha256 = "sha256-iOJEy7dCZGRTaOuL/09wcMlNDHjRi9SIr9bialdcKi4=";
|
||||||
|
@ -66,7 +66,10 @@ buildGoModule rec {
|
||||||
cp ./conf/defaults.ini $out/share/grafana/conf/
|
cp ./conf/defaults.ini $out/share/grafana/conf/
|
||||||
'';
|
'';
|
||||||
|
|
||||||
passthru.tests = { inherit (nixosTests) grafana; };
|
passthru = {
|
||||||
|
tests = { inherit (nixosTests) grafana; };
|
||||||
|
updateScript = ./update.sh;
|
||||||
|
};
|
||||||
|
|
||||||
meta = with lib; {
|
meta = with lib; {
|
||||||
description = "Gorgeous metric viz, dashboards & editors for Graphite, InfluxDB & OpenTSDB";
|
description = "Gorgeous metric viz, dashboards & editors for Graphite, InfluxDB & OpenTSDB";
|
||||||
|
|
39
pkgs/servers/monitoring/grafana/update.sh
Executable file
39
pkgs/servers/monitoring/grafana/update.sh
Executable file
|
@ -0,0 +1,39 @@
|
||||||
|
#!/usr/bin/env nix-shell
|
||||||
|
#!nix-shell -i bash -p curl common-updater-scripts jq nix nix-prefetch-scripts moreutils
|
||||||
|
|
||||||
|
set -euxo pipefail
|
||||||
|
|
||||||
|
FILE="$(nix-instantiate --eval -E 'with import ./. {}; (builtins.unsafeGetAttrPos "version" grafana).file' | tr -d '"')"
|
||||||
|
replaceHash() {
|
||||||
|
old="${1?old hash missing}"
|
||||||
|
new="${2?new hash missing}"
|
||||||
|
awk -v OLD="$old" -v NEW="$new" '{
|
||||||
|
if (i=index($0, OLD)) {
|
||||||
|
$0 = substr($0, 1, i-1) NEW substr($0, i+length(OLD));
|
||||||
|
}
|
||||||
|
print $0;
|
||||||
|
}' "$FILE" | sponge "$FILE"
|
||||||
|
}
|
||||||
|
extractVendorHash() {
|
||||||
|
original="${1?original hash missing}"
|
||||||
|
result="$(nix-build -A grafana.go-modules 2>&1 | tail -n3 | grep 'got:' | cut -d: -f2- | xargs echo || true)"
|
||||||
|
[ -z "$result" ] && { echo "$original"; } || { echo "$result"; }
|
||||||
|
}
|
||||||
|
|
||||||
|
oldVersion="$(nix-instantiate --eval -E "with import ./. {}; lib.getVersion grafana" | tr -d '"')"
|
||||||
|
latest="$(curl https://api.github.com/repos/grafana/grafana/releases/latest | jq '.tag_name' -r | tr -d 'v')"
|
||||||
|
|
||||||
|
targetVersion="${1:-$latest}"
|
||||||
|
if [ ! "${oldVersion}" = "${targetVersion}" ]; then
|
||||||
|
update-source-version grafana "${targetVersion#v}"
|
||||||
|
oldStaticHash="$(nix-instantiate --eval -A grafana.srcStatic.outputHash | tr -d '"')"
|
||||||
|
newStaticHash="$(nix-prefetch-url "https://dl.grafana.com/oss/release/grafana-${targetVersion#v}.linux-amd64.tar.gz")"
|
||||||
|
replaceHash "$oldStaticHash" "$newStaticHash"
|
||||||
|
goHash="$(nix-instantiate --eval -A grafana.vendorSha256 | tr -d '"')"
|
||||||
|
emptyHash="$(nix-instantiate --eval -A lib.fakeSha256 | tr -d '"')"
|
||||||
|
replaceHash "$goHash" "$emptyHash"
|
||||||
|
replaceHash "$emptyHash" "$(extractVendorHash "$goHash")"
|
||||||
|
nix-build -A grafana
|
||||||
|
else
|
||||||
|
echo "grafana is already up-to-date"
|
||||||
|
fi
|
Loading…
Reference in a new issue