-
-
Notifications
You must be signed in to change notification settings - Fork 13.7k
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
defaultPkgConfigPackages: init #212282
defaultPkgConfigPackages: init #212282
Conversation
@ofborg build tests.defaultPkgConfigPackages |
061efe8
to
6588f93
Compare
83d6170
to
139a681
Compare
f4cde1b
to
77d403e
Compare
|
||
- A [setup hook](#setup-hook-pkg-config) bundled with in the `pkg-config` package, to bring a derivation's declared build inputs into the environment. | ||
- The [`validatePkgConfig` setup hook](https://nixos.org/manual/nixpkgs/stable/#validatepkgconfig), for packages that provide pkg-config modules. | ||
- The `pkg-configPackages` package set: a set of aliases, named after the modules they provide. This is meant to be used by language-to-nix integrations. Hand-written packages should use the normal Nixpkgs attribute name instead. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The policy for hand written packages is of course hard to enforce, so it the question is if we should have a non-enforceable policy?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm? What policy? I just see documentation of Nixpkgs' interfaces.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hand-written packages should use the normal Nixpkgs attribute name instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, well I wouldn't sweat it. I think this supposed to be more "we're not changing the norms at this time" than "you must do it this way...".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A should, not a must. I prefer breaking rules over making rules anyway. Gee that sounds cheesy.
pkgs/test/default.nix
Outdated
# in order to filter out the unsupported packages without throwing any errors | ||
# tryEval would be too fragile, masking different problems as if they're | ||
# unsupported platform problems. | ||
allPkgs = import ../top-level { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
allPkgs = import ../top-level { | |
allPkgs = import pkgs.path { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That risks copying a path to the store. pkgs.path
is too complicated for me; most imports happen by path expression, which is known to work well.
pkgs/test/pkg-config-packages.nix
Outdated
# Make sure licensing info etc is preserved, as this is a concern for e.g. cache.nixos.org, | ||
# as hydra can't check this meta info in dependencies. | ||
# The test itself is just Nixpkgs, with MIT license. | ||
// builtins.intersectAttrs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd just update the meta
of the source package instead which seems more comprehensible – hydra will behave the same for both (i.e. pkg.meta // { description = … ; }
). The new meta
set is run through mkDerivation
anyways.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It isn't equivalent to the original package though, so I'd rather be conservative in terms of what we inherit. For example, the description would be wrong. For instance, your suggestion would copy the longDescription
, which is wrong.
cc @Ericson2314 who has also been working towards a (different?) solution of this problem. Edit: See https://github.com/nixpkgs-architecture/issues/issues/14. |
I didn't work any implementation yet, so this is great! Can we add tests / |
tests = { | ||
# NB: this may test a different variant of zlib than the package that | ||
# carries this `tests` attribute, due to overriding. | ||
pkg-configPackages = tests.pkg-configPackages.zlib; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rather this call makePkgConfigTest
, and then tests.pkg-configPackages
gathers these to run all of them. That is I think better layering, but concretely it allows the tests for individual packages to be built regardless of the package set in question.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The point is exactly to violate layering, so that ofborg will test the relevant bit of pkg-configPackages
when it's time to do so. I think this is the best we can achieve with the tooling we have, if we put in the effort.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should just ignore this idea and rely on asynchronous testing of the whole pkg-configPackages
on hydra.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I don't know the details of ofborg, but I thought the overriding was just for the top-level tests? I would think if the individual package is an unsupported systems, then ofborg would just skip the test too, which is fine?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've factored out the tester into a properly tested and documented tester.
@@ -0,0 +1,202 @@ | |||
/* A set of aliases to be used in generated expressions. | |||
|
|||
In case of ambiguity, this will pick a sensible default. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should provide all packages that match, something like one of:
pkgConfigName = [ pkg0 pkg1 ];
pkgConfigName = { inherit pkg0 pkg1; };
A key idea of pkg-config is that it tracks interfaces not implementations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My intent is for this to be a slightly curated set of packages, providing defaults for lang2nix integrations. Adding multiple versions / variants / ... here will add a lot more churn and will confuse lang2nix integrations that don't have a means to pick one. I feel like this would be more suitable for a version 2.
How about I call this package set defaultPkgConfigPackages
instead? That will leave room for a fancier implementation with a nice name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@roberth sounds good! The complete one can be autogenerated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The list data is in a .json
now that can be evolved if needed. It's already quite extensible because it uses records wherever it can; top-level and in each module. It also has a top-level version field just in case.
A meta attribute should not be part of the derivation.
So then it should be part of the derivation, or we should generate a Doing this kind of automatic stuff isn't really feasible in the current architecture, as hooks can, by nature, not affect the attribute set. If packages were modules, this would have a fantastic ui:
Alternatively, we'd have to add this logic to Doing it in this PR would blow up the scope. It's already tested, just differently, so I don't think it should be a blocker. |
We'd have
and |
That looks like it'd work, yes. It's a bit more manual than I'd like, but it's feasible, at least for the places where Nonetheless, I'd like to leave that as future work. My goal here is really to get the ball rolling. I can't spend a lot of time on this. |
Both ways of testing are independent, have different goals despite their similarity, and that we should eventually do both.
There's overlap in part of the implementation, but they are different subjects. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am happy to do that as follow-up then.
Maybe we should take a step back and deliberate if a package set is the best option? In what situations do we actually need it? If we have a lookup table lang2nix tools can use, that would work, too, and that generated expressions would be more overrideable. What bugs me right now that |
If you want json, the file can be converted and loaded with some functions. The package set and the generated tests are useful components of the json solution as well. |
I think that would be a good change. Having it as a
|
The overlapped part is now
Done. @ofborg build tests.testers.hasPkgConfigModule |
By allowing null, we allow code to avoid filterAttrs, improving laziness in real world use cases. Specifically, this strategy prevents infinite recursion errors, performance issues and possibly other errors that are unrelated to the user's code.
3196db4
to
d8a2178
Compare
This broke Hydra: https://hydra.nixos.org/build/207340888/nixlog/114 |
Yes, f192e96 in particular. Channel blocked again because of that. |
Ah, it was reverted already in PR #213615 |
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/adding-pkg-config-metadata-to-nixpkgs-packages/25281/1 |
r=$? | ||
set -e | ||
if [[ $r = 0 ]]; then | ||
echo "✅ pkg-config module $moduleName exists and has version $version" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First time I see some unicode in setup tooks and I am surprised that no one complained yet.
Description of changes
This is a mapping from pkg-config identifiers to packages, for anyone to use, but most useful for lang2nix tooling.
The initial list is based on cabal2nix from April 2022. It comes with tests to verify that the package actually exposes the expected pkg-config package. I've only had to update the vte package since then, as shown by the running the tests today.
cc @aakropotkin who also maintains a pkg-config mapping
cc @DavHau because probably dream2nix needs this too
Things done
sandbox = true
set innix.conf
? (See Nix manual)nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)nixos/doc/manual/md-to-db.sh
to update generated release notes