-
-
Notifications
You must be signed in to change notification settings - Fork 14.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
postgresqlPackages: replace custom installPhase with buildPostgresqlExtension helper #344039
postgresqlPackages: replace custom installPhase with buildPostgresqlExtension helper #344039
Conversation
118c2da
to
a235ae4
Compare
That sounds like the right way to me. |
cb3595f
to
f9a323c
Compare
Did that. This works very nicely now. I built all extensions on aarch64-darwin and x86_64-linux - all of them have the same build result as on master, so succeed when they did before, and fail with the same errors when they did before. But overall, we have much less code in The first three commits had already been merged to master earlier, just putting them here to make my rebasing easier later. The last commit is the one to look at. |
f9a323c
to
2337b79
Compare
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.
Not sure I'm qualified to review this, but here's what questions came up for me:
2337b79
to
db7de2f
Compare
db7de2f
to
fd3514d
Compare
rebased due to merge conflict |
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.
Great work! Looks good to me. 👍 (With the already-mentioned caveat that I don't feel very qualified to review this.)
(Consider using one of the more standard-ish spellings of "OK"/"okey".)
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'm fine with the current state since it makes the situation easier for extension packages, but I don't really like it.
But I wonder, how much effort would it be to patch PGXS to not assume the output of pg_config
as base installation directory?
Exactly how I'm feeling about this, too. It isn't pretty, but it's better than the status quo.
You can't, really. That's what I started with, patching the PGXS Makefiles that PostgreSQL provides. But each extension includes those Makefiles - and then builds on top of that. So we'd have to suddenly patch the extension's Makefiles, too - if we wanted to make that solution generic, i.e. without knowing those Makefiles in advance, then it's... hard. There is one approach that I didn't try, yet. We could try to wrap the This would only work, though, if all extensions were really using |
So after taking another look at the Makefiles of some postgresql extensions I see what you mean and I have to agree. Let's stick to the approach. There are still a few minor things to be done (and perhaps the postgis maintainers @NixOS/geospatial @MarcWeber also want to take a look), then we can ship this. |
@wolfgangwalther I think we've discussed everything in here. Anything I can assist you with here to get it done? |
I'm currently travelling and will look into this and other PRs end of next week again. |
fd3514d
to
0b6e160
Compare
0b6e160
to
f3c401e
Compare
Rebased and addressed comments. Still building everything locally, will take a while. |
626f604
to
e749d99
Compare
All looks good from my side. |
Built a lot of stuff today, looking good! |
e749d99
to
d12c6dc
Compare
Rebased to resolve conflicts. |
Hm, ofborg failure seems unrelated to my changes. I will try another rebase on staging. |
d12c6dc
to
e24121e
Compare
Description of changes
Most postgres extensions are built with PGXS, postgres' build system for extension. All of them have in common, that they override the installPhase, because the pgxs Makefiles don't work correctly in nixpkgs out of the box. This PR fixes that - by providing the
DESTDIR
option, which all those Makefiles support. However, this will be added to the full paths which are returned by pg_config and will temporarily result in paths installed as$out/nix/store/..-postgresql-.../<proper-path
. To deal with that, a postInstall hook cleans up and moves the files back to$out/
directly without the additionalnix/store/...
.This works nicely - I was able to build all extension like this without any custom installPhases anymore. Even more, I was able to significantly simplify the
postgis
derivation with that.The current approach has two downsides, from what I can tell:
postInstall
doesn't work as expected, because at this time the files are still in$out/nix/store/.../
instead of$out
. The postInstall hook registered via setup hook will always run after thepostInstall
hook in the derivation.postgresql
in their build dependencies will get this setup hook and thus theDESTDIR
setting automatically, not only the extensions inpostgresql/ext
. While this is good thing for those which use PGXS - there might some other packages that just happen to have postgresql as a dependency without it's build system. SettingDESTDIR
could have unintended effects, if they happen to use that differently.One way to solve both of this would me to create a wrapper around
mkDerivation
specifically for postgresql extensions - and then prepend thepostInstall
hook code to the derivation-providedpostInstall
code. This would always run first, makingpostInstall
work normally again. This wrapper would have to be used explicitly - and all postgresql extensions would do so. Other packages would not be affected.Before I go that way, I would like to have some feedback on the general approach here and whether is anything that I might have missed or is not working currently. Since
postgis
is changed / simplified the most, I'd welcome a review of some of the postgis maintainers: @NixOS/geospatial @MarcWeberThings done
nix.conf
? (See Nix manual)sandbox = relaxed
sandbox = true
nix-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.