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

flattenTree: ignore attributes that throw errors #34

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Pacman99
Copy link
Contributor

@Pacman99 Pacman99 commented May 17, 2021

Improve flattenTree's safety. If attributes throw an error, they should just be ignored, since the goal is to filter out derivations.

@zimbatm
Copy link
Member

zimbatm commented May 18, 2021

This might filter too many packages. Let's say you modify a package and introduce a Nix error by mistake. The CI might still be building successfully while ignoring the failed package.

@Pacman99
Copy link
Contributor Author

I don't think that should be a concern. derivations require a deeper evaluations to check if there are errors in them.
This should pretty much only be able to check if here is a literal throw on the other side of the attribute.
If its a syntax error, that would fail no matter what. And if the derivation is broken, it won't know - so won't be ignored.

I might be missing something here though.

@zimbatm
Copy link
Member

zimbatm commented May 19, 2021

Let's see what my imagination can come up with :)

{ stdenv, lib, openssl, zlib }:
stdenv.mkDerivation {
  buildInputs = [ openssl ] ++ lib.optionals stdenv.isDarwin zlib;
}

That package would get filtered out isn't it?

@Pacman99
Copy link
Contributor Author

Great example! I just tried it out, I think it works. Here is my repl:

nix-repl> p = pkgs.callPackage ./test.nix { }                 

nix-repl> builtins.tryEval ((builtins.typeOf p) == "set")     
{ success = true; value = true; }

where test.nix was the package you sent.

I think the error of missing attributes or any general package error only gets triggered when you access specific attributes in the package or actually evaluate the derivation. So a shallow evaluation of it, wouldn't catch such things.

But also I think we came up with a better solution in flake-utils-plus to avoid running into throw's in the first place. So Its ok to close this. This was totally worth it to learn about tryEval :)

@blaggacao
Copy link
Contributor

I'd also want to add that https://github.com/numtide/flake-utils/blob/master/filterPackages.nix was intended for providing any kind of filtering services to users. I can't remember exactly why I didn't touch flattenTree filtering, I think it was because flatten tree does just the ordinary thing expected from any nix tools to recursively collect derivations.

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.

3 participants