victoriametrics: add support to enable/disable subpackages

This commit is contained in:
Shawn8901 2024-04-28 23:04:35 +02:00
parent 2dc4ecdd56
commit d68244cf1f

View File

@ -1,36 +1,55 @@
{ lib, buildGoModule, fetchFromGitHub, nixosTests }: {
lib,
buildGoModule,
fetchFromGitHub,
nixosTests,
withServer ? true, # the actual metrics server
withVmAgent ? true, # Agent to collect metrics
withVmAlert ? true, # Alert Manager
withVmAuth ? true, # HTTP proxy for authentication
withBackupTools ? true, # vmbackup, vmrestore
withVmctl ? true, # vmctl is used to migrate time series
withVictoriaLogs ? true, # logs server
}:
buildGoModule rec { buildGoModule rec {
pname = "VictoriaMetrics"; pname = "VictoriaMetrics";
version = "1.101.0"; version = "1.101.0";
src = fetchFromGitHub { src = fetchFromGitHub {
owner = pname; owner = "VictoriaMetrics";
repo = pname; repo = "VictoriaMetrics";
rev = "v${version}"; rev = "v${version}";
hash = "sha256-Jjz/CbVCvc9NFbvzYTFthG8cov4pYpc6y1A1Kmd3Mjg="; hash = "sha256-Jjz/CbVCvc9NFbvzYTFthG8cov4pYpc6y1A1Kmd3Mjg=";
}; };
vendorHash = null; vendorHash = null;
subPackages = [ subPackages =
"app/victoria-logs" lib.optionals withServer [
"app/victoria-metrics" "app/victoria-metrics"
"app/vlinsert" "app/vminsert"
"app/vlselect" "app/vmselect"
"app/vlstorage" "app/vmstorage"
"app/vmagent" "app/vmui"
"app/vmalert-tool" ]
"app/vmalert" ++ lib.optionals withVmAgent [ "app/vmagent" ]
"app/vmauth" ++ lib.optionals withVmAlert [
"app/vmctl" "app/vmalert"
"app/vminsert" "app/vmalert-tool"
"app/vmselect" ]
"app/vmstorage" ++ lib.optionals withVmAuth [ "app/vmauth" ]
"app/vmbackup" ++ lib.optionals withVmctl [ "app/vmctl" ]
"app/vmrestore" ++ lib.optionals withBackupTools [
"app/vmui" "app/vmbackup"
]; "app/vmrestore"
]
++ lib.optionals withVictoriaLogs [
"app/victoria-logs"
"app/vlinsert"
"app/vlselect"
"app/vlstorage"
];
postPatch = '' postPatch = ''
# main module (github.com/VictoriaMetrics/VictoriaMetrics) does not contain package # main module (github.com/VictoriaMetrics/VictoriaMetrics) does not contain package
@ -46,7 +65,11 @@ buildGoModule rec {
--replace "time.NewTimer(time.Second * 10)" "time.NewTimer(time.Second * 120)" \ --replace "time.NewTimer(time.Second * 10)" "time.NewTimer(time.Second * 120)" \
''; '';
ldflags = [ "-s" "-w" "-X github.com/VictoriaMetrics/VictoriaMetrics/lib/buildinfo.Version=${version}" ]; ldflags = [
"-s"
"-w"
"-X github.com/VictoriaMetrics/VictoriaMetrics/lib/buildinfo.Version=${version}"
];
preCheck = '' preCheck = ''
# `lib/querytracer/tracer_test.go` expects `buildinfo.Version` to be unset # `lib/querytracer/tracer_test.go` expects `buildinfo.Version` to be unset
@ -55,7 +78,9 @@ buildGoModule rec {
__darwinAllowLocalNetworking = true; __darwinAllowLocalNetworking = true;
passthru.tests = { inherit (nixosTests) victoriametrics; }; passthru.tests = {
inherit (nixosTests) victoriametrics;
};
meta = with lib; { meta = with lib; {
homepage = "https://victoriametrics.com/"; homepage = "https://victoriametrics.com/";