nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 python3,
4 fetchFromGitHub,
5 testers,
6 krr,
7}:
8
9python3.pkgs.buildPythonPackage rec {
10 pname = "krr";
11 version = "1.7.1";
12 pyproject = true;
13
14 src = fetchFromGitHub {
15 owner = "robusta-dev";
16 repo = "krr";
17 tag = "v${version}";
18 hash = "sha256-Bc1Ql3z/UmOXE2RJYC5/sE4a3MFdE06I3HwKY+SdSlk=";
19 };
20
21 postPatch = ''
22 substituteInPlace robusta_krr/__init__.py \
23 --replace-warn '1.7.0-dev' '${version}'
24
25 substituteInPlace pyproject.toml \
26 --replace-warn '1.7.0-dev' '${version}' \
27 --replace-fail 'aiostream = "^0.4.5"' 'aiostream = "*"' \
28 --replace-fail 'kubernetes = "^26.1.0"' 'kubernetes = "*"' \
29 --replace-fail 'pydantic = "1.10.7"' 'pydantic = "*"' \
30 --replace-fail 'typer = { extras = ["all"], version = "^0.7.0" }' 'typer = { extras = ["all"], version = "*" }'
31 '';
32
33 propagatedBuildInputs = with python3.pkgs; [
34 aiostream
35 alive-progress
36 kubernetes
37 numpy
38 poetry-core
39 prometheus-api-client
40 prometrix
41 pydantic_1
42 slack-sdk
43 typer
44 ];
45
46 nativeCheckInputs = with python3.pkgs; [
47 pytestCheckHook
48 ];
49
50 pythonImportsCheck = [
51 "robusta_krr"
52 ];
53
54 passthru.tests.version = testers.testVersion {
55 package = krr;
56 command = "krr version";
57 };
58
59 meta = {
60 description = "Prometheus-based Kubernetes resource recommendations";
61 longDescription = ''
62 Robusta KRR (Kubernetes Resource Recommender) is a CLI tool for optimizing
63 resource allocation in Kubernetes clusters. It gathers Pod usage data from
64 Prometheus and recommends requests and limits for CPU and memory. This
65 reduces costs and improves performance.
66 '';
67 homepage = "https://github.com/robusta-dev/krr";
68 changelog = "https://github.com/robusta-dev/krr/releases/tag/v${src.rev}";
69 license = lib.licenses.mit;
70 maintainers = [ ];
71 mainProgram = "krr";
72 };
73}