but patched to build with Lix
Go to file
Pierre Bourdon c057494450
flake.lock: Update
Flake lock file updates:

• Updated input 'flake-parts':
    'github:hercules-ci/flake-parts/2a55567fcf15b1b1c7ed712a2c6fadaec7412ea8' (2024-06-01)
  → 'github:hercules-ci/flake-parts/9227223f6d922fee3c7b190b2cc238a99527bbb7' (2024-07-03)
• Updated input 'lix':
    'f170870ae7.tar.gz?narHash=sha256-GK6PusfbMgkg%2BqdgChmrw78KTNQkm7SDoJ6%2BlJKY6vg%3D' (2024-06-25)
  → 'ef0de7c79f.tar.gz?narHash=sha256-GUH5%2BB1JztzDNSN1D7KbndrYSq0LWvVIJnuWKHlpN3Q%3D' (2024-07-16)
• Updated input 'nix-github-actions':
    'github:nix-community/nix-github-actions/5163432afc817cf8bd1f031418d1869e4c9d5547' (2023-12-29)
  → 'github:nix-community/nix-github-actions/622f829f5fe69310a866c8a6cd07e747c44ef820' (2024-07-04)
• Updated input 'nixpkgs':
    'github:NixOS/nixpkgs/d9e18354acbf59c625505b7315c85508e9831bf4' (2024-06-18)
  → 'github:NixOS/nixpkgs/732b4f3a3afdfe6a6c4fcb2511e529588d4e5ccd' (2024-07-15)
• Updated input 'treefmt-nix':
    'github:numtide/treefmt-nix/1cb529bffa880746a1d0ec4e0f5076876af931f1' (2024-06-11)
  → 'github:numtide/treefmt-nix/0fb28f237f83295b4dd05e342f333b447c097398' (2024-07-15)
2024-07-17 07:57:52 +02:00
.github Update cachix/install-nix-action action to v25 2024-01-12 17:34:52 +00:00
dev treefmt: replace prettier with deno 2023-12-10 10:25:15 +00:00
src drv: backport CA derivations support changes from hydra-eval-jobs 2024-07-16 09:15:21 +02:00
tests apply treefmt 2023-12-16 11:44:08 +01:00
.clang-format Move clang-format config to .clang-format 2023-07-14 07:09:40 +00:00
.gitignore Add editorconfig-checker 2021-08-25 13:58:43 -05:00
.mergify.yml fix mergify for normal non-bot merges 2023-11-20 06:50:56 +01:00
.prettierrc.js Add TOML formatter (prettier) 2022-04-26 21:40:31 +12:00
default.nix Fixup readme and version to say what this is 2024-05-27 12:54:51 -06:00
flake.lock flake.lock: Update 2024-07-17 07:57:52 +02:00
flake.nix Fix on latest lix 2024-06-18 23:08:04 -07:00 treefmt: replace prettier with deno 2023-12-10 10:25:15 +00:00 Tidy and make it work on release-2.90 2024-06-18 22:31:42 -07:00
pyproject.toml fix ci for infinite recursion case 2023-12-16 11:40:34 +01:00 Fixup readme and version to say what this is 2024-05-27 12:54:51 -06:00
renovate.json renovate: add dependencies label 2023-11-14 09:49:42 +01:00
shell.nix Fix on latest lix 2024-06-18 23:08:04 -07:00



This is a fork of nix-eval-jobs that works with Lix.

This project evaluates nix attribute sets in parallel with streamable json output. This is useful for time and memory intensive evaluations such as NixOS machines, i.e. in a CI context. The evaluation is done with a controllable number of threads that are restarted when their memory consumption exceeds a certain threshold.

To facilitate integration, nix-eval-jobs creates garbage collection roots for each evaluated derivation (drv file, not the build) within the provided attribute. This prevents race conditions between the nix garbage collection service and user-started nix builds processes.

Why using nix-eval-jobs?

  • Faster evaluation by using threads
  • Memory used for evaluation is reclaimed after nix-eval-jobs finish, so that the build can use it.
  • Evaluation of jobs can fail individually


In the following example we evaluate the hydraJobs attribute of the patchelf flake:

$ nix-eval-jobs --gc-roots-dir gcroot --flake 'github:NixOS/patchelf#hydraJobs'

The output here is newline-seperated json according to

The code is derived from hydra's eval-jobs executable.

Further options

$ nix-eval-jobs --help
USAGE: nix-eval-jobs [options] expr

  --arg                  Pass the value *expr* as the argument *name* to Nix functions.
  --argstr               Pass the string *string* as the argument *name* to Nix functions.
  --check-cache-status   Check if the derivations are present locally or in any configured substituters (i.e. binary cache). The information will be exposed in the `isCached` field of the JSON output.
  --debug                Set the logging verbosity level to 'debug'.
            The [URL of the Nix store](@docroot@/command-ref/new-cli/
            to use for evaluation, i.e. to store derivations (`.drv` files) and inputs referenced by them.

  --expr                 treat the argument as a Nix expression
  --flake                build a flake
  --force-recurse        force recursion (don't respect recurseIntoAttrs)
  --gc-roots-dir         garbage collector roots directory
  --help                 show usage information
  --impure               allow impure expressions

  --log-format           Set the format of log output; one of `raw`, `internal-json`, `bar` or `bar-with-logs`.
  --max-memory-size      maximum evaluation memory size in megabyte (4GiB per worker by default)
  --meta                 include derivation meta field in output
  --option               Set the Nix configuration setting *name* to *value* (overriding `nix.conf`).
  --override-flake       Override the flake registries, redirecting *original-ref* to *resolved-ref*.
  --override-input       Override a specific flake input (e.g. `dwarffs/nixpkgs`).
  --quiet                Decrease the logging verbosity level.
  --repair               During evaluation, rewrite missing or corrupted files in the Nix store. During building, rebuild missing or corrupted store paths.
  --show-trace           print out a stack trace in case of evaluation errors
  --verbose              Increase the logging verbosity level.
  --workers              number of evaluate workers

Potential use-cases for the tool

Faster evaluator in deployment tools. When evaluating NixOS machines, evaluation can take several minutes when run on a single core. This limits scalability for large deployments with deployment tools such as NixOps.

Faster evaluator in CIs. In addition to evaluation speed for CIs, it is also useful if evaluation of individual jobs in CIs can fail, as opposed to failing the entire jobset. For CIs that allow dynamic build steps to be created, one can also take advantage of the fact that nix-eval-jobs outputs the derivation path separately. This allows separate logs and success status per job instead of a single large log file. In the wiki we collect example ci configuration for various CIs.

Organisation of this repository

main follows Lix HEAD, and is updated alongside the Lix NixOS module. When we release we will make a release-2.90 etc branch, which receives backports.

The version of nix-eval-jobs follows the major version of Lix and minor versions of nix-eval-jobs are released as necessary when changes are made in n-e-j itself.

Projects using nix-eval-jobs

  • nix-fast-build - Combine the power of nix-eval-jobs with nix-output-monitor to speed-up your evaluation and building process
  • buildbot-nix - A nixos module to make buildbot a proper Nix-CI
  • colmena - A simple, stateless NixOS deployment tool
  • robotnix - Build Android (AOSP) using Nix, used in their CI


How can I check if my package already have been uploaded in the binary cache?

If you provide the --check-cache-status, the json will contain a "isCached" key in its json, that is true or false based on the status.

How can I evaluate nixpkgs?

If you want to evaluate nixpkgs in the same way hydra does it, use this snippet:

$ nix-eval-jobs --force-recurse pkgs/top-level/release.nix

nix-eval-jobs consumes too much memory / is too slow

By default, nix-eval-jobs spawns as many worker processes as there are hardware threads in the system and limits the memory usage for each worker to 4GB.

However, keep in mind that each worker process may need to re-evaluate shared dependencies of the attributes, which can introduce some overhead for each evaluation or cause workers to exceed their memory limit. If you encounter these situations, you can tune the following options:

--workers: This option allows you to set the number of evaluation workers that nix-eval-jobs should spawn. You can increase or decrease this number to optimize the evaluation speed and memory usage. For example, if you have a system with many CPU cores but limited memory, you may want to reduce the number of workers to avoid exceeding the memory limit.

--max-memory-size: This option allows you to adjust the memory limit for each worker process. By default, it's set to 4GiB, but you can increase or decrease this value as needed. For example, if you have a system with a lot of memory and want to speed up the evaluation, you may want to increase the memory limit to allow workers to cache more data in memory before getting restarted by nix-eval-jobs. Note that this is not a hard limit and memory usage may rise above the limit momentarily before the worker process exits.

Overall, tuning these options can help you optimize the performance and memory usage of nix-eval-jobs to better fit your system and evaluation needs.