2024-04-21 15:54:59 +00:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
buildGoModule,
|
2024-10-29 11:11:06 +00:00
|
|
|
stdenv,
|
2024-04-21 15:54:59 +00:00
|
|
|
fetchFromGitHub,
|
2024-10-29 11:11:06 +00:00
|
|
|
versionCheckHook,
|
2024-04-21 15:54:59 +00:00
|
|
|
}:
|
|
|
|
buildGoModule rec {
|
|
|
|
pname = "nezha-agent";
|
2024-10-29 11:11:06 +00:00
|
|
|
version = "0.20.3";
|
2024-04-21 15:54:59 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "nezhahq";
|
|
|
|
repo = "agent";
|
2024-07-01 15:47:52 +00:00
|
|
|
rev = "refs/tags/v${version}";
|
2024-10-29 11:11:06 +00:00
|
|
|
hash = "sha256-cLLiJbAr7TxVUNV31Y9TG8ZL4uqBCOnrOr1FM4+1U5c=";
|
2024-04-21 15:54:59 +00:00
|
|
|
};
|
|
|
|
|
2024-10-29 11:11:06 +00:00
|
|
|
vendorHash = "sha256-q6/265vVg6jCnDvs825nni8QFHkJpQz4xxC9MlJH2do=";
|
2024-04-21 15:54:59 +00:00
|
|
|
|
|
|
|
ldflags = [
|
|
|
|
"-s"
|
|
|
|
"-w"
|
|
|
|
"-X main.version=${version}"
|
2024-10-29 11:11:06 +00:00
|
|
|
"-X main.arch=${stdenv.hostPlatform.system}"
|
2024-04-21 15:54:59 +00:00
|
|
|
];
|
|
|
|
|
2024-10-29 11:11:06 +00:00
|
|
|
checkFlags =
|
|
|
|
let
|
|
|
|
# Skip tests that require network access
|
|
|
|
skippedTests = [
|
|
|
|
"TestLookupIP"
|
|
|
|
"TestGeoIPApi"
|
|
|
|
"TestFetchGeoIP"
|
|
|
|
"TestCloudflareDetection"
|
|
|
|
];
|
|
|
|
in
|
|
|
|
[ "-skip=^${builtins.concatStringsSep "$|^" skippedTests}$" ];
|
|
|
|
|
|
|
|
postInstall = ''
|
|
|
|
pushd $out/bin
|
|
|
|
mv agent nezha-agent
|
|
|
|
|
|
|
|
# for compatibility
|
|
|
|
ln -sr nezha-agent agent
|
|
|
|
popd
|
2024-04-21 15:54:59 +00:00
|
|
|
'';
|
|
|
|
|
2024-10-29 11:11:06 +00:00
|
|
|
doInstallCheck = true;
|
|
|
|
|
|
|
|
versionCheckProgramArg = "-v";
|
|
|
|
|
|
|
|
nativeInstallCheckInputs = [
|
|
|
|
versionCheckHook
|
|
|
|
];
|
2024-04-21 15:54:59 +00:00
|
|
|
|
2024-07-01 15:47:52 +00:00
|
|
|
meta = {
|
2024-04-21 15:54:59 +00:00
|
|
|
description = "Agent of Nezha Monitoring";
|
|
|
|
homepage = "https://github.com/nezhahq/agent";
|
2024-07-01 15:47:52 +00:00
|
|
|
license = lib.licenses.asl20;
|
|
|
|
maintainers = with lib.maintainers; [ moraxyc ];
|
2024-10-29 11:11:06 +00:00
|
|
|
mainProgram = "nezha-agent";
|
2024-04-21 15:54:59 +00:00
|
|
|
};
|
|
|
|
}
|