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

Q: why does flattenTree rely on recurseIntoAttrs? #112

Open
mightyiam opened this issue Jan 9, 2024 · 4 comments
Open

Q: why does flattenTree rely on recurseIntoAttrs? #112

mightyiam opened this issue Jan 9, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@mightyiam
Copy link
Contributor

The need to add recurseIntoAttrs causes pollution of the attrset with the marker attribute. That prevents it from being set as the packages output of a flake.

In checks, I do wish to use flattenTree. But in packages I don't. But I must in order to remove the marker attr. And that goes for other places packages ends up in.

This makes me wish for a flattenTree that doesn't need recurseIntoAttrs.

Dime for you thoughts?

@mightyiam mightyiam added the enhancement New feature or request label Jan 9, 2024
@zimbatm
Copy link
Member

zimbatm commented Jan 15, 2024

If packages is an attrs of derivations, it doesn't need flattenTree as the tree is already flat.

If it has a hierarchy, it's incompatible with the packages schema since it only allows derivations as values. In that case, the package set has to be put in legacyPackages to conform with the flake schema, and having an additional recurseIntoAttrs doesn't matter.

@jfly
Copy link

jfly commented Jan 16, 2024

@zimbatm, how about specifically for checks? Here's a snippet from our flake.nix:

checks = flake-utils.lib.flattenTree {
    packages = (recurseIntoAttrs packages);
    nixosTests = (recurseIntoAttrs nixosTests);
};

(where there is some collision in the keys between packages and nixosTests, so we use flattenTree to ensure uniqueness in the final checks attrset)

The above code works, but it is bit cumbersome to have to call recurseIntoAttrs on every value. We'd prefer to write this as:

checks = flake-utils.lib.flattenTree {
    inherit packages nixosTests;
};

@zimbatm
Copy link
Member

zimbatm commented Jan 16, 2024

It would make sense to add a flake-utils.lib.mkChecks for that. There might be also a smart variant flake-utils.lib.mkDefaultChecks self system that automatically picks the packages, nixosTests, ...

@mightyiam
Copy link
Contributor Author

I like the mkDefaultChecks idea. It would take only self, I suppose? I can see it also making a formatting check from the formatter output.

I'm not sure, in that case, of the value of mkChecks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants