Mic92 / nixpkgs-review

Review pull-requests on https://github.com/NixOS/nixpkgs
MIT License
353 stars 59 forks source link

flake/nix-command based eval? #327

Open GenericNerdyUsername opened 1 year ago

GenericNerdyUsername commented 1 year ago

would it be possible to use nix eval, so that the evaluation is cached? I feel it would speed up usage a fair bit

Mic92 commented 1 year ago

I don't think that would work. nixpkgs currently does not expose all packages in the flake and legacyPackages is not cached afaik. Also as far as I know it might also slow down the first evaluation since for every attribute it would needs to create entries in the eval cache sqlite databases.

GenericNerdyUsername commented 1 year ago

This is the first ive heard of not all packages being exposed

Mic92 commented 1 year ago

If you do $ nix flake show --legacy you see that it won't include any nested package sets such as python packages. It's probably possible to have an eval script that iterates over all packages in the same way nix-env does, but it likely also slower. And I don't think you will be able to use the eval cache in this case.

GenericNerdyUsername commented 1 year ago

What would be the problem with writing a small expression that gives you all of the packages?

Mic92 commented 1 year ago

Than you won't benefit from any cache and just reimplement nix-env in a slower way. Also there are some exceptions thrown in nixpkgs every once in a while that you cannot catch from nix. This is the script that I used before to go over all of nixpkgs. https://gist.github.com/Mic92/0a30fa6babd3eb9c8445fd877ae8781f

GenericNerdyUsername commented 1 year ago

Why not put that script in a flake and modify the nixpkgs input?

Mic92 commented 1 year ago

I'd say it would be easier to just cache the nixpkgs package list that nix-env generates: https://github.com/Mic92/nixpkgs-review/blob/30a6655d29da7b380d504b9fdbe06a60ae9ea911/nixpkgs_review/review.py#L344 and less error prone than those terrible nix expressions that has to use tons of tryEval.