setup-hooks: add auto-patch-pc-hook#394610
setup-hooks: add auto-patch-pc-hook#394610marcin-serwin wants to merge 1 commit intoNixOS:masterfrom
Conversation
cbc5b33 to
350e8f4
Compare
350e8f4 to
2db8959
Compare
|
Thanks so much for working on this! I think we might want this hook to be in I’d like to request you pick another licence, if possible; CC0 is not really designed for code, and has an explicit disclaimer against granting patent rights that has led to e.g. Fedora rejecting its use for software. |
|
I think it makes sense to just put the code for the tool in nixpkgs. |
2db8959 to
0055976
Compare
Changed to Unlicense
Should the files go into |
|
I'd put it in a subdirectory, personally, just for convenience. |
aadce28 to
a15c363
Compare
|
I don’t think the code needs to be in Nixpkgs; we depend on plenty of tools like |
|
I thought it was smaller, to be honest, but also, looking at it now... Do we really have to reinvent string handling in C again? Can we do Python or something? |
Python depends on |
|
We don't need curl if we vendor the sources though? |
|
|
|
Can we just leave this out of some of the bootstrap? Or go with C++ or Rust or something. Hell, at least glib? |
Probably, that's what I meant when I said that it'll make the bootstrap more complicated.
|
|
I'm really really sorry if I'm coming on too strong here, but I also really, really don't want to see more C string manipulation code in nixpkgs, or anywhere for that matter. Skipping this for a few bootstrap packages is absolutely worth the maintenance cost savings of not doing it in C. |
|
Probably much of the manual string parsing could be avoided by using the |
a15c363 to
d92ea30
Compare
|
I've rewritten it in python. Turns out that with |
|
Sorry for making you rewrite this! But I absolutely love the new version. |
d92ea30 to
b8929dc
Compare
|
I've managed to build my system atop of #394607, but I had to make some chanages:
|
LordGrimmauld
left a comment
There was a problem hiding this comment.
Some more documentation and explanation would be nice.
The changes themselves look fine honestly - so far nothing uses this, but this is quite compact and certainly more maintainable than the C proposal you had.
Feel free to ignore my python nits, my coding style in py is a bit peculiar. But figured i'd bring those up, even if they end up ignored. Your code is very clean. Noone stops learning, discussing the best way to do things can be nice. But i also don't want to turn this to bike shedding hell, so if that ends up too annoying just close those comments please!
pkgs/top-level/all-packages.nix
Outdated
There was a problem hiding this comment.
nit: autoPatchPcHook might not be very descriptive, autoPatchPkgConfigHook might be easier to understand when looking at any package that would use this
pkgs/top-level/all-packages.nix
Outdated
There was a problem hiding this comment.
Is this actually intended to be a different pkgconf than above propagated pkg-config? Might it make more sense to make a let...in for the whole block and use the same here as in propagation?
There was a problem hiding this comment.
Is this actually intended to be a different pkgconf than above propagated pkg-config?
Yes, the pkg-config in propagated build inputs is the freedesktop's implementation which is currently the default in nixpkgs. We can't use it in the patch-pc.py because it does not support the --path flag. I want to avoid packages having both pkg-config and pkgconf in their nativeBuildInputs so I propagate the pkg-config to ensure that its setup hook is registered while the script uses pkgconf. Once nixpkgs switches to pkgconf this can be simplified to propagating pkgconf and the script using the the program from PATH.
There was a problem hiding this comment.
stylistic nit, feel free to ignore:
| print(f"Requires{".private" if private else ""}:", ", ".join(requires)) | |
| print(f"Requires{".private" if private else ""}: ", end="") | |
| print(*requires, sep=", ") |
You could technically also replace ".private" if private else "" with ".private" * private because you are checking for bool parameter, but honestly don't, that would be too deep into python weirdness. But the print is a serious suggestion.
There was a problem hiding this comment.
Applied the print suggestion.
There was a problem hiding this comment.
Stylistic nit (feel free to ignore):
| requires = (transform_dep_spec(dep) for dep in list_requires(file, private)) | |
| requires = map(transform_dep_spec, list_requires(file, private)) |
We do functional programming in nix, a map might be more appropriate than list comprehension, but i am happy with either.
There was a problem hiding this comment.
I don't write a lot of Python but my understanding is that list comprehensions are considered more pythonic than the functional equivalents, e.g., see here.
b8929dc to
c7d2020
Compare
c7d2020 to
cb180cd
Compare
cb180cd to
fac5a50
Compare
fac5a50 to
dbcace1
Compare
LordGrimmauld
left a comment
There was a problem hiding this comment.
Thanks for the documentation! Now the need for it is clearer, and when/how to use too. The python code looks clean, and the nix/bash part looks at least manageable. I am not too familiar with stdenv things, my approval shouldn't be sufficient to blindly merge this, but no complaints left here.
|
I think we should enable this by default and have an opt-out in case it breaks things. Still need to review the Python bits closer. |
How can we do an opt-out that also removes runtime dependencies? Other hooks I've looked at do something like |
|
Can do something in |
|
Maybe stdenv people have better ideas how to do this "properly"? @emilazy boop |
|
|
patch-pcreplaces dependencies in pc files with their absolute paths,auto-patch-pc-hookautomatically runs it during fixup phase for all.pcfiles produced by the package. See #334195 for motivation. Feel free to also comment on thepatch-pccode in this PR, I'll tag it as0.1.0once I'm sure no more changes are necessary.I am currently in the process of rebuilding my personal NixOS system on top of the #394607 branch. So far it's going well, the only problematic package is
xorgprotowhich produces.pcfiles that reference packages depending onxorgproto, creating circular dependency. I've patched them out for now, not sure what's the proper way to address it.cc @emilazy
Things done
nix.conf? (See Nix manual)sandbox = relaxedsandbox = truenix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/)Add a 👍 reaction to pull requests you find important.