mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-11 20:25:32 +03:00
prometheus-chrony-exporter: add versionCheckHook and linker attrs
This commit is contained in:
parent
e29b8377b8
commit
418465d234
1 changed files with 24 additions and 3 deletions
|
@ -3,8 +3,8 @@
|
||||||
buildGoModule,
|
buildGoModule,
|
||||||
fetchFromGitHub,
|
fetchFromGitHub,
|
||||||
nix-update-script,
|
nix-update-script,
|
||||||
|
versionCheckHook,
|
||||||
}:
|
}:
|
||||||
|
|
||||||
buildGoModule (finalAttrs: {
|
buildGoModule (finalAttrs: {
|
||||||
pname = "prometheus-chrony-exporter";
|
pname = "prometheus-chrony-exporter";
|
||||||
version = "0.12.0";
|
version = "0.12.0";
|
||||||
|
@ -13,18 +13,39 @@ buildGoModule (finalAttrs: {
|
||||||
owner = "superq";
|
owner = "superq";
|
||||||
repo = "chrony_exporter";
|
repo = "chrony_exporter";
|
||||||
tag = "v${finalAttrs.version}";
|
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 = [
|
ldflags = [
|
||||||
"-s"
|
"-s"
|
||||||
"-w"
|
"-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 { };
|
passthru.updateScript = nix-update-script { };
|
||||||
|
|
||||||
|
nativeInstallCheckInputs = [ versionCheckHook ];
|
||||||
|
|
||||||
|
doInstallCheck = true;
|
||||||
|
versionCheckProgram = "${placeholder "out"}/bin/chrony_exporter";
|
||||||
|
versionCheckProgramArg = "--version";
|
||||||
|
|
||||||
meta = {
|
meta = {
|
||||||
changelog = "https://github.com/superq/chrony_exporter/releases/tag/v${finalAttrs.version}";
|
changelog = "https://github.com/superq/chrony_exporter/releases/tag/v${finalAttrs.version}";
|
||||||
homepage = "https://github.com/superq/chrony";
|
homepage = "https://github.com/superq/chrony";
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue