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

stdenv-generic: add meta attribute checking #25304

Merged
merged 1 commit into from Apr 29, 2017

Conversation

copumpkin
Copy link
Member

This is turned off by default but I think we should fix all packages to respect it and then turn it on by default. To turn it on, just put checkMeta = true; into your nixpkgs config.

cc @shlevy @dezgeg @edolstra

Motivation for this change

I got sick of constantly seeing typos and accidental type errors in our meta tags, and people never notice them until Hydra complains. I'd probably eventually start adding a few more checks (like that platforms members are in an enum and so on) but this should get us 95% of the value.

It's turned off by default because there are tons of violations, which I'd propose fixing incrementally in separate commits. The very first failure is in binutils, which has a priority field as a string 😄

Things done

Nothing. I just tried evaluating stdenv and got some failures, so there's work to be done 😁

N.B: this is not a mass rebuild, and only affects evaluation

@mention-bot
Copy link

@copumpkin, thanks for your PR! By analyzing the history of the files in this pull request, we identified @edolstra, @pikajude and @wmertens to be potential reviewers.

Copy link
Member

@shlevy shlevy left a comment

Choose a reason for hiding this comment

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

🚢 🚢 🚢

This is turned off by default but I think we should fix all packages to
respect it and then turn it on by default
@copumpkin copumpkin merged commit 76137a8 into NixOS:master Apr 29, 2017
@copumpkin
Copy link
Member Author

Okay, now that this is merged, if anyone wants to join me in making small commits to fix meta attributes, please feel free 😄

@copumpkin
Copy link
Member Author

I ran hydra-eval-jobs per @cleverca22's suggestion and I think I've fixed all remaining issues, so I switched checkMeta to true by default. Please let me know or switch to false if you object, but I'd rather sneak it in before others break more stuff.

@copumpkin
Copy link
Member Author

The two commits were 1a4ca22 and 90b9719

@edolstra
Copy link
Member

edolstra commented May 1, 2017

The thing is that meta is intended as an arbitrary name/value map. So it's perfectly fine to include attributes that are not "known".

@edolstra
Copy link
Member

edolstra commented May 1, 2017

Also, what's the impact of this on Nixpkgs evaluation speed? There has been a worrying slowdown in the last few releases, probably due to the increased complexity of stdenv...

@copumpkin
Copy link
Member Author

copumpkin commented May 1, 2017

@edolstra my sense is that the reason you'd add stuff to meta rather than a comment is that you want it to be structured for some form of machine consumption. If you want a machine to consume it, you generally want it to have a reasonably well defined schema. So it doesn't seem too burdensome to ask people wanting to add a new meta attribute to add it to the central schema first (and it'll be easy for them to tell if they miss it because it'll fail eagerly now)

On the evaluation speed, I don't know and haven't measured yet. Where can I find evaluation times in Hydra? I guess if it slows it down excessively we can turn it off, but given the literally dozens of edits I made to nixpkgs here to fix stupid typos I found with this feature, this is solving a real problem, so I'm loath to privilege speed of Hydra evaluation (which is rare and not something user-facing, and comparatively small compared to build time) over the system silently ignoring typo'd meta tags.

@7c6f434c
Copy link
Member

7c6f434c commented May 1, 2017

@copumpkin speed of evaluation is something visible via nix-env -qa; and also nix-env -i which shouldn't be used ever but oh well…

If you want a quick measurement, try measuring test-eval-release.sh, I think it should be a close proxy.

By the way, maybe the check should be done inside the tarball build, like the warning checks? Tarball failures block the channel, so they do get noticed…

(I did have to do some fixes because of this check being introduced, and I do like this check in general)

@copumpkin
Copy link
Member Author

copumpkin commented May 1, 2017 via email

@7c6f434c
Copy link
Member

7c6f434c commented May 1, 2017 via email

@edolstra
Copy link
Member

edolstra commented May 1, 2017

http://hydra.nixos.org/job/nixpkgs/trunk/metrics#tabs-charts

Note the jump for e.g. nix-env.qa.values around April 29 from around 2 million to 3.5 million. Or nix-env.qa.maxresident which went from 654 MB to 732 MB.

@edolstra
Copy link
Member

edolstra commented May 1, 2017

@7c6f434c Yeah, doing this kind of lint check in the Nixpkgs tarball job sounds good.

@copumpkin
Copy link
Member Author

copumpkin commented May 1, 2017

Yeah, so I guess it did go up a bit. The real question to me is what we're optimizing for. I'd obviously prefer what I'd call "developer efficiency", but I'm not the one paying for or maintaining Hydra hardware. At the same time, losing a few seconds (or <100MB of RAM) with each full-nixpkgs hydra evaluation when builds take hours or even days still seems pretty small.

I do realize that the evaluation time matters every time we do nix-env or nix-shell for users too, but even there it feels like it's small compared to downloading packages from the binary cache and tiny compared to building them.

Anyway, I can't really make the call and it's a trade-off like everything, but if I were running the project, I'd probably leave this turned on by default and accept slightly slower Hydra eval times.

@7c6f434c
Copy link
Member

7c6f434c commented May 1, 2017

@copumpkin @edolstra and what about environment-variable-controlled middle ground?

@copumpkin
Copy link
Member Author

It's already controlled by a config flag. The question is more whether we want it on by default or not.

@7c6f434c
Copy link
Member

7c6f434c commented May 1, 2017

My point is that nix-build and nix-env -qa with the default config should behave differently.

On Hydra the check should be just switched off in evaluation and moved to the tarball build.

@copumpkin
Copy link
Member Author

Ah, so we'd have nix-build always check meta, nix-env wouldn't check it, and Hydra would only check when building the tarball? I guess that isn't awful, although it does (by design) make things behave a little differently in potentially confusing ways. How do I distinguish between nix-build and nix-env (also, what would nix-shell do?) with an env var?

@7c6f434c
Copy link
Member

7c6f434c commented May 1, 2017

I would set an environment variable; and nix-shell is closer to nix-build; I actually would make nix-env -i invocations of the nix-build kind and only -qa lax.

There would be some slight difference in behaviour, true, but at least in case of success the hashes would be the same, so not that bad… I doubt we can go more confusing that the current broken/override interaction.

@copumpkin
Copy link
Member Author

Oh, you mean developers would need to set an environment variable when developing? That feels like defaulting it to off, which I didn't want.

I was hoping for something a bit like IN_NIX_SHELL that would let me distinguish between nix-build and nix-env.

My issue is just that the people who are typoing all their meta tags (often in consistently bad ways, like website, home, etc.) today probably aren't following our PRs that closely and won't know that I've added this feature. So the people who need it the most won't know that they need it.

@copumpkin
Copy link
Member Author

copumpkin commented May 1, 2017

I'll just turn it off by default for now, since I think I missed some broken meta in many of the python packages which don't get evaluated by Hydra. I still want to turn it on by default, but can get more community input or make an RFC or something like that if you think this is too impactful.

@edolstra where are you leaning? Did my "unstructured random data in meta is useless" point make sense? Do you think the performance issues are actually a big deal?

Trying to gauge how controversial this is, basically, to decide whether an RFC is worthwhile.

To be clear, this is what I'm proposing:

  1. Meta is for "semi-structured" data pertaining to packages. If you want to add a new flag that is likely to affect many packages, you should probably get community feedback and submit a PR adding it to the stdenv/generic schema.
  2. If you want freeform data, leave it in a comment or a README adjacent to the package expression file
  3. Check the meta schema by default for developers. I don't know how to separate developers at evaluation time from users and automated builds right now, but if we can do that, I'd like that.
  4. Make sure the meta attrset is correct in all existing packages (mostly done, except that I seem to have missed a few).

@copumpkin
Copy link
Member Author

I switched the default to false again (for now, I hope) in f3a05a0

@7c6f434c
Copy link
Member

7c6f434c commented May 1, 2017

No-no, I meant that nix* tools would set the variable that distinguishes mass operations from narrowly targeted ones. I would hope that adding a new package includes nix-build, which is a targeted operation and would do the strict check.

@7c6f434c
Copy link
Member

7c6f434c commented May 1, 2017

Distinguishing mass operations and targeted operations would be also useful for deprecation warnings.

For example, @oxij wonders is there a way to display notices that there are two different torbrowser packages (from source and binary) now.

@oxij
Copy link
Member

oxij commented May 1, 2017 via email

@aneeshusa aneeshusa mentioned this pull request May 2, 2017
7 tasks
branch = str;
homepage = str;
downloadPage = str;
license = either (listOf lib.types.attrs) lib.types.attrs;
Copy link
Contributor

Choose a reason for hiding this comment

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

The current documentation says that using strings for license is "valid", though "frowned upon". I suppose the manual should be updated?


# Weirder stuff that doesn't appear in the documentation?
version = str;
updateWalker = bool;
Copy link
Contributor

Choose a reason for hiding this comment

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

updateWalker seems to be documented.

copumpkin referenced this pull request Jun 26, 2017
The invalid meta.outputsToInstall has been blocking channel updates.
https://mailman.science.uu.nl/pipermail/nix-dev/2017-June/023991.html
piegamesde added a commit to piegamesde/nixpkgs that referenced this pull request Sep 25, 2022
- Enable metadata checking by default, see NixOS#25304 (comment)
- Check metadata before any other package issues, see NixOS#191124 (comment)
- Document that type checks only apply to the top level of nested values.

Co-authored-by: Valentin Gagarin <valentin.gagarin@tweag.io>
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.

None yet

7 participants