Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

evaluated: introduce nixpkgs package list evaluation as a package #357934

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

lucasew
Copy link
Contributor

@lucasew lucasew commented Nov 21, 2024

This is a package that basically takes a nixpkgs tree and evaluates the package, and function, list to a file so comparing different releases is faster.

It runs as a nix derivation so the expensive evaluation could be offloaded to a worker node.

It returns a text file with the item path from pkgs, the type and the outPath if it's a derivation.

Implementation may be suboptimal but suggestions are welcome.

Consider this a experiment.

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 25.05 Release Notes (or backporting 24.11 and 25.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@lucasew lucasew force-pushed the 20241119-eval-as-a-package branch from e57b20f to b2c82a4 Compare November 21, 2024 16:51
@lucasew
Copy link
Contributor Author

lucasew commented Nov 21, 2024

nixpkgs-review result

Generated using nixpkgs-review.

Command: nixpkgs-review pr 357934


x86_64-linux

✅ 1 package built:
  • evaluated

@r-vdp
Copy link
Contributor

r-vdp commented Nov 21, 2024

What's the motivation to have this in nixpkgs?
It feels to me like this is more like something you would define downstream, but maybe I'm missing something?

@lucasew
Copy link
Contributor Author

lucasew commented Nov 22, 2024

What's the motivation to have this in nixpkgs? It feels to me like this is more like something you would define downstream, but maybe I'm missing something?

It's more like an experiment to allow parallelization of nixpkgs evaluation for ofborg, nixpkgs-review and stuff like that.

It's kinda slow tho, like almost 10 minutes for a full nixpkgs evaluation but the data is nice!

else if !evaluated.success then
builtins.trace ":tree: exception ${pathStr} :tree:" null
else if isDerivation tree then
builtins.trace (builtins.unsafeDiscardStringContext ":tree: derivation ${pathStr} ${tree.drvPath} :tree:") null
Copy link
Member

Choose a reason for hiding this comment

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

How does it compare to the existing approach using nix-env. That one seems to be faster in our current CI than the 10 minutes that you are describing?

Copy link
Member

Choose a reason for hiding this comment

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

This is what we also do in nixpkgs-review.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In this case we can also diff added functions, not only derivations

IDK exactly how nix-env traverses packages so I don't know the differences in approach

Copy link
Member

Choose a reason for hiding this comment

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

What would we do with the function diff? We cannot test those directly, can we? Should be added function not also obvious from reading the diff?

Copy link
Member

Choose a reason for hiding this comment

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

Here is what is currently done:

nix-env -f "${nixpkgs}/pkgs/top-level/release-attrpaths-parallel.nix" \

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What would we do with the function diff? We cannot test those directly, can we? Should be added function not also obvious from reading the diff?

Can't test, yet, but it shows in the diff when another function is introduced. Maybe when we introduce some kind of passthru.tests for functions we could automate testing only the functions that changed and it's dependents.

BTW my intention here is to experiment with a different approach, like how faster or slower can we go if we builtins.trace the stuff instead of returning a data structure using nix-env, and running it on a derivation so it could be offloaded to a remote builder.

Maybe the implementation could be faster but I don't know how to optimize further.

Copy link
Member

@Mic92 Mic92 Nov 24, 2024

Choose a reason for hiding this comment

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

Sure. I just wanted to summarize of how things work today. I also did some experimenting in the past with walking the tree with nix, but wasn't able to beat the C++ function that nix-env uses internally back than. Also this new github eval goes in a similar direction.

@lucasew lucasew mentioned this pull request Jan 3, 2025
13 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants