mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-04-16 20:58:28 +00:00
prometheus-chrony-exporter: add versionCheckHook and linker attrs
This commit is contained in:
parent
e29b8377b8
commit
418465d234
@ -3,8 +3,8 @@
|
||||
buildGoModule,
|
||||
fetchFromGitHub,
|
||||
nix-update-script,
|
||||
versionCheckHook,
|
||||
}:
|
||||
|
||||
buildGoModule (finalAttrs: {
|
||||
pname = "prometheus-chrony-exporter";
|
||||
version = "0.12.0";
|
||||
@ -13,18 +13,39 @@ buildGoModule (finalAttrs: {
|
||||
owner = "superq";
|
||||
repo = "chrony_exporter";
|
||||
tag = "v${finalAttrs.version}";
|
||||
hash = "sha256-ZXqCZZx0UG8050SYgVwD+wnTX0N41Bjv1dhdQmOHmR4=";
|
||||
hash = "sha256-W7MWshRuQdbxLm0XKkTHXN+pjwoX7wnCtjaeXyszr/Q=";
|
||||
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
|
||||
'';
|
||||
};
|
||||
|
||||
vendorHash = "sha256-3zL7BrCdMVnt7F1FiZ2eQnKVhmCeW3aYKKX9v01ms/k=";
|
||||
# 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)"
|
||||
'';
|
||||
|
||||
ldflags = [
|
||||
"-s"
|
||||
"-w"
|
||||
"-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"
|
||||
];
|
||||
|
||||
vendorHash = "sha256-3zL7BrCdMVnt7F1FiZ2eQnKVhmCeW3aYKKX9v01ms/k=";
|
||||
|
||||
passthru.updateScript = nix-update-script { };
|
||||
|
||||
nativeInstallCheckInputs = [ versionCheckHook ];
|
||||
|
||||
doInstallCheck = true;
|
||||
versionCheckProgram = "${placeholder "out"}/bin/chrony_exporter";
|
||||
versionCheckProgramArg = "--version";
|
||||
|
||||
meta = {
|
||||
changelog = "https://github.com/superq/chrony_exporter/releases/tag/v${finalAttrs.version}";
|
||||
homepage = "https://github.com/superq/chrony";
|
||||
|
Loading…
Reference in New Issue
Block a user