Skip to content

Conversation

@B4dM4n
Copy link
Contributor

@B4dM4n B4dM4n commented Feb 28, 2025

This PR replaces all calls to nix-env -qaP and nix eval with calls to nix-eval-jobs. This allows the user to control the memory consumption of nixpkgs-review very accurately.

Each commit in this PR can be tested and reviewed individually.

With nix-eval-jobs, the user now has to options to control the memory usage of nixpkgs-review:

  • --num-parallel-evals: the same flag that existed before and controlled the number of parallel nix-env calls, is now used for the --worker argument to nix-eval-jobs (default 1)
  • --max-memory-size: this is passed directly to nix-eval-jobs and controls the amount of memory in MB, that each worker can consume (default 4096).

Due to the internals of nix-eval-jobs, a worker can shortly consume more memory than specified by --max-memory-size, if the evaluation of the current attribute is large (e.g. nixos tests). But once the evaluation of that attribute is finished, the worker restarts and the memory is freed.

The default.nix currently includes an unreleased nix-eval-jobs version, because the --apply flag is not released yet.

To reduce the memory usage further, the invoked nix build command will now receive the derivations to build directly, instead of evaluating all attributes itself again (which can also consume multiple GB of RAM).

Until now, failed tests would not be reported separately and simply shown in the
"tests build" list.
This switches `nix.Attr` from using `path` as the unique package identifier to
`drv_path`.
Re-evaluating all attributes can significantly increase the memory consumption
of `nix build` by several GB during the entire runtime of the process.
Therefore, simply give the derivations that have already been evaluated to the
process.
let
binPath =
[
pkgs.nixVersions.stable or nix_2_4
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pkgs.nixVersions.stable or nix_2_4
pkgs.nixVersions.stable

I don't think that is necessary anymore


inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

"--nix-path",
nix_path,
"--extra-experimental-features",
"nix-command" if allow.url_literals else "nix-command no-url-literals",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to remove allow.url_literals now completely?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants