2025-03-27 11:49:40 +00:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
buildGoModule,
|
|
|
|
fetchFromGitHub,
|
|
|
|
nix-update-script,
|
2025-03-30 11:53:20 +00:00
|
|
|
versionCheckHook,
|
2025-03-27 11:49:40 +00:00
|
|
|
}:
|
|
|
|
buildGoModule (finalAttrs: {
|
|
|
|
pname = "prometheus-chrony-exporter";
|
2025-06-11 09:39:15 +00:00
|
|
|
version = "0.12.1";
|
2025-03-27 11:49:40 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "superq";
|
|
|
|
repo = "chrony_exporter";
|
|
|
|
tag = "v${finalAttrs.version}";
|
2025-06-11 09:39:15 +00:00
|
|
|
hash = "sha256-8iuWL6/urv8sf86Z8ySGx+2zzDPqOj7OcYcTubL9LK8=";
|
2025-03-30 11:53:20 +00:00
|
|
|
leaveDotGit = true;
|
|
|
|
postFetch = ''
|
|
|
|
cd "$out"
|
|
|
|
date -u -d "@$(git log -1 --pretty=%ct)" "+%Y-%m-%dT%H:%M:%SZ" > $out/BUILD_COMMIT_DATE
|
|
|
|
find "$out" -name .git -print0 | xargs -0 rm -rf
|
|
|
|
'';
|
2025-03-27 11:49:40 +00:00
|
|
|
};
|
|
|
|
|
2025-03-30 11:53:20 +00:00
|
|
|
# do not use real BuildDate, but fixed imagenary (commit date) for binary reproducibility
|
|
|
|
preBuild = ''
|
|
|
|
ldflags+=" -X github.com/prometheus/common/version.BuildDate=$(cat BUILD_COMMIT_DATE)"
|
|
|
|
'';
|
2025-03-27 11:49:40 +00:00
|
|
|
|
|
|
|
ldflags = [
|
|
|
|
"-s"
|
|
|
|
"-w"
|
2025-03-30 11:53:20 +00:00
|
|
|
"-X github.com/prometheus/common/version.Version=${finalAttrs.version}"
|
|
|
|
"-X github.com/prometheus/common/version.Revision=${finalAttrs.src.rev}"
|
|
|
|
"-X github.com/prometheus/common/version.Branch=master"
|
|
|
|
"-X github.com/prometheus/common/version.BuildUser=nix@nixpkgs"
|
2025-03-27 11:49:40 +00:00
|
|
|
];
|
|
|
|
|
2025-06-11 09:39:15 +00:00
|
|
|
vendorHash = "sha256-TAj7tYDFKPsPCHpWT4UQ3oZkUcLbL4iliXghwZqwuC8=";
|
2025-03-30 11:53:20 +00:00
|
|
|
|
2025-03-27 11:49:40 +00:00
|
|
|
passthru.updateScript = nix-update-script { };
|
|
|
|
|
2025-03-30 11:53:20 +00:00
|
|
|
nativeInstallCheckInputs = [ versionCheckHook ];
|
|
|
|
|
|
|
|
doInstallCheck = true;
|
|
|
|
versionCheckProgram = "${placeholder "out"}/bin/chrony_exporter";
|
|
|
|
versionCheckProgramArg = "--version";
|
|
|
|
|
2025-03-27 11:49:40 +00:00
|
|
|
meta = {
|
|
|
|
changelog = "https://github.com/superq/chrony_exporter/releases/tag/v${finalAttrs.version}";
|
|
|
|
homepage = "https://github.com/superq/chrony";
|
|
|
|
description = "Prometheus exporter for the chrony NTP service";
|
|
|
|
license = lib.licenses.asl20;
|
|
|
|
mainProgram = "chrony_exporter";
|
|
|
|
maintainers = with lib.maintainers; [ paepcke ];
|
|
|
|
};
|
|
|
|
})
|