opentelemetry-collector: fix auto updates (#541965)

This commit is contained in:
Peder Bergebakken Sundt
2026-07-17 17:27:32 +00:00
committed by GitHub
3 changed files with 47 additions and 22 deletions

View File

@@ -6,7 +6,7 @@
buildGoModule rec {
pname = "ocb";
# Also update `pkgs/tools/misc/opentelemetry-collector/releases.nix`
# whenever that version changes.
# whenever this version changes.
version = "0.155.0";
src = fetchFromGitHub {
@@ -31,6 +31,8 @@ buildGoModule rec {
"-skip TestGenerateAndCompile|TestReplaceStatementsAreComplete|TestVersioning|TestRunInit"
];
passthru.updateScript = ./update.sh;
# Rename to ocb (it's generated as "builder")
postInstall = ''
mv $out/bin/builder $out/bin/ocb

View File

@@ -4,9 +4,7 @@
fetchFromGitHub,
installShellFiles,
testers,
nixosTests,
opentelemetry-collector-builder,
pkgs,
go,
git,
cacert,
@@ -17,16 +15,14 @@ let
builder = "${opentelemetry-collector-builder}/bin/ocb";
# Keep the version in sync with the builder.
rev = opentelemetry-collector-builder.src.rev;
version = lib.removePrefix "cmd/builder/v" rev;
version = "0.155.0";
# This is a weird meta-repo where all the open-telemetry collectors are.
src = fetchFromGitHub {
releasesSrc = fetchFromGitHub {
owner = "open-telemetry";
repo = "opentelemetry-collector-releases";
rev = "v${version}";
hash = "sha256-5AoUgGZEvxbvlksD1P84lxMrHPAP05cN21fABK4UXRg=";
hash = "sha256-w4J5Q7cztSQyjqHH5L0blDUiFO6+fK4/dLoQT+ftUSE=";
};
# Then from this src, we use the tool to generate some go code, including
@@ -39,7 +35,10 @@ let
hash,
}:
stdenv.mkDerivation {
inherit name;
# Inherit the version from the builder, so that updates there trigger
# a rebuild here.
inherit version;
pname = "${name}-src";
nativeBuildInputs = [
cacert
@@ -47,7 +46,7 @@ let
go
];
inherit src;
src = releasesSrc;
outputHash = hash;
outputHashMode = "recursive";
@@ -117,11 +116,16 @@ let
--zsh <($out/bin/${name} completion zsh)
'';
passthru.tests = {
version = testers.testVersion {
inherit package version;
command = "${name} -v";
passthru = {
tests = {
version = testers.testVersion {
inherit package version;
command = "${name} -v";
};
};
# The updatescript for the builder updates the releases
updateScript = null;
inherit releasesSrc;
};
meta = {
@@ -148,26 +152,26 @@ in
lib.recurseIntoAttrs {
otelcol = mkDistribution {
name = "otelcol";
sourceHash = "sha256-4PpZ6anKPkFyVcARJJSEpyy3duTCyrMnnAnh6CWwjUc=";
vendorHash = "sha256-OoXz9rFIipM0tc6kvkkPdUtYXVIfo0L40V4SUfwSF6M=";
sourceHash = "sha256-JY/jg5SeZ90lVLo+t6MuxZAMZ5IpNwEQEz9kC2uYc+8=";
vendorHash = "sha256-tEA2wCtk2Pm7YJem5jOB/1Iz7K1jKKl/N9VKSumC+WA=";
};
otelcol-contrib = mkDistribution {
name = "otelcol-contrib";
sourceHash = "sha256-wUmpivqLSnRYGTJn3IIlpwFXORmK4FJrc8U472YPV2o=";
vendorHash = "sha256-7Rb3Ku0q+5cBvgtd/oZaLaFa4chv0b/MzaHEpJvJ6rE=";
sourceHash = "sha256-ANIyUa0bibTYRWC1RZbvYFitaEkmLOiubQxFfmzj4kQ=";
vendorHash = "sha256-dPaDmhO4XASQ1y3NyetxnJuTr+pIDwF/rwrN5QkBBCA=";
proxyVendor = true; # hash mismatch between linux and darwin
};
otelcol-k8s = mkDistribution {
name = "otelcol-k8s";
sourceHash = "sha256-yNhE0CwMNus12QDSbP/x9irrIcOdez0e/RpXFFRQ2LE=";
vendorHash = "sha256-2ZzLCMTafbpmSpkpwvYgkP/Myg/QD1LHgiMigbj3x9I=";
sourceHash = "sha256-cZ+ok52ceYkQE9bG+FFTFYONUQfsC8kbJk5SLZ8IIYU=";
vendorHash = "sha256-qwlZr0LoXZWf72flpORf19PAkHdITY8bxJGkacG2j+A=";
};
otelcol-otlp = mkDistribution {
name = "otelcol-otlp";
sourceHash = "sha256-+cffC4sOlyPWtydkPZz7M0NF2Q3heQ04/pEB8d+942c=";
vendorHash = "sha256-WiP+TYj7VZBt3tP4C/ZvQwkDP8/b4F+Bc7Z95p0tBTI=";
sourceHash = "sha256-W1QHjHMn6xWVN08FpJi2YcKzkpxTPbq9MYIbdQxVHHY=";
vendorHash = "sha256-gX1D+RPCwcp9UMpzAzEYHDsBrn2KdfN/4RxcgKHViYQ=";
};
}

View File

@@ -0,0 +1,19 @@
#! /usr/bin/env nix-shell
#! nix-shell -i bash -p curl jq nix-update common-updater-scripts
set -euf
# Get latest version from releases repo
version=$(curl https://api.github.com/repos/open-telemetry/opentelemetry-collector-releases/releases/latest | jq -r '.name')
version=${version#v}
# Update builder
nix-update opentelemetry-collector-builder --version="${version}"
# Update the otel-collector-releases source
update-source-version opentelemetry-collector-releases.otelcol "${version}" --source-key="releasesSrc"
# Update the individual distributions
for dist in {"",-contrib,-k8s,-otlp}
do
nix-update "opentelemetry-collector-releases.otelcol${dist}" --version skip
done