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

postgresql: more cleanup #293996

Merged
merged 14 commits into from
Apr 19, 2024
Merged

postgresql: more cleanup #293996

merged 14 commits into from
Apr 19, 2024

Conversation

wolfgangwalther
Copy link
Contributor

@wolfgangwalther wolfgangwalther commented Mar 7, 2024

Description of changes

TLDR: This is a continuation of #292993 including those changes which will cause rebuilding the postgresql derivations. Only cleanup, no functional changes.

While working on building PostgreSQL with meson as mentioned in #292993, I had to carefully look at every line in the old builder to see if and how to take this to the meson build. Some of the special cases seem to be not needed anymore, so this PR removes them. Trying to understand the purpose of each of the custom patches, I also cleaned those up along the way with some common formatting and improved naming. Hopefully, this would not only help my own understanding, but other's, too. Finally this PR also contains one more change that is related to the refactor of this in the other PR - here, I remove thisAttr, too, and make sure that .tests will always work correctly, even when overriding the derivation.

This merges into the branch of #292993, so please ignore the first 13 or so commits (all starting with "refactor ...") - those are discussed in the other PR. I still split this into a second PR, because the other changes are a pure refactor without causing rebuilds - while those changes there will cause a full rebuild of all postgresql derivations. Thus, I also targeted staging instead of master with this PR here.

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.05 Release Notes (or backporting 23.05 and 23.11 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Maintainers: @thoughtpolice @danbst @globin @marsam @ivan @Ma27

Add a 👍 reaction to pull requests you find important.

@github-actions github-actions bot added 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` labels Mar 7, 2024
@Ma27
Copy link
Member

Ma27 commented Mar 8, 2024

For now, just one request: please don't @ me in commit messages (feel free to reference my GH handle or my name, but without @). The reason is that too many people out there have interesting rebase workflows in their forks that cause notifications in my inbox whenever they push something (had this issue a few times already) and it was always pretty annoying.

@wolfgangwalther
Copy link
Contributor Author

please don't @ me in commit messages (feel free to reference my GH handle or my name, but without @). The reason is that too many people out there have interesting rebase workflows in their forks that cause notifications in my inbox

Uh, thanks for the hint. Yeah, that's bad. I found one reference to your handle, I removed the at (not pushed, yet). I also changed a @out@/lib mention to $out/lib, which is understandable as well... and avoids mentioning someone else accidentally.

@wolfgangwalther
Copy link
Contributor Author

Rebased after dropping the "split autotools.nix" commit in the other PR.

@Ma27 Ma27 marked this pull request as draft March 9, 2024 17:03
@Ma27
Copy link
Member

Ma27 commented Mar 10, 2024

Just to make sure it doesn't get lost, from #292993 (comment):

would you mind trying out if adding 2da789a to .git-blame-ignore-revs helps to retain a bit of the history of the previous file?

No idea if that works out, but maybe worth a try?

Comment on lines -287 to +291
broken = jitSupport && (stdenv.hostPlatform != stdenv.buildPlatform);
broken = (jitSupport && stdenv.hostPlatform != stdenv.buildPlatform)
# Allmost all tests fail FATAL errors for v12 and v13
|| (jitSupport && stdenv.hostPlatform.isMusl && olderThan "14");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

After marking pkgsMusl.postgresql_12_jit and pkgsMusl.postgresql_13_jit as broken here (which they currently are), I realized that those builds were fixed in #294504 / d5ab5216debe155f216e255d28921038fb482325. I don't really know why, though.

@wolfgangwalther
Copy link
Contributor Author

I don't expect the base branch to change much anymore - and even if it does, it would all be non-rebuilding refactors anyway. So I suggest you could already start reviewing the changes in here @Ma27? I think those are in good shape, too. I just added one more commit to deal with the failing regression tests on musl in a better way.

The meson based build is working fine now, but I haven't put that up in a PR, yet, because there's already enough of them open, all containing the same many unmerged commits.

@wolfgangwalther wolfgangwalther force-pushed the postgresql-cleanup branch 2 times, most recently from d3ea5c3 to 80084d2 Compare March 16, 2024 13:39
@wolfgangwalther
Copy link
Contributor Author

Added a commit to remove icu-collations-hack.patch for pkgsMusl. See #228349 (comment).

@Ma27
Copy link
Member

Ma27 commented Mar 17, 2024

I think this needs another rebase.

@wolfgangwalther
Copy link
Contributor Author

I think this needs another rebase.

Done. Will rebase again after the merged changes have made their way into staging. Until then, please ignore the first commits. The first commit of this PR is postgresql: remove thisAttr argument ....

@wolfgangwalther wolfgangwalther marked this pull request as ready for review March 17, 2024 10:18
@wolfgangwalther
Copy link
Contributor Author

Will rebase again after the merged changes have made their way into staging.

Done.

@ofborg ofborg bot requested a review from ivan March 17, 2024 12:32
Copy link
Contributor

@marsam marsam left a comment

Choose a reason for hiding this comment

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

LGTM. Great work, thanks a lot!

@wegank wegank added 12.approvals: 1 This PR was reviewed and approved by one reputable person 12.approved-by: package-maintainer This PR was reviewed and approved by a maintainer listed in the package labels Apr 1, 2024
@wolfgangwalther
Copy link
Contributor Author

Just a rebase to resolve a conflict in .git-blame-ignore-revs.

@ofborg ofborg bot requested a review from marsam April 3, 2024 18:26
@wegank wegank removed the 12.approvals: 1 This PR was reviewed and approved by one reputable person label Apr 4, 2024
Previously, it was not possible to run tests on an overridden derivation, because
the derivation under test was always pulled from pkgs.

With this change, the following will return the same test:

  postgresql_jit.tests

and

  (postgresql.override { jitSupport = true; }).tests
This is for consistency between the top-level attribute and the respective package
name, which makes it easier to track derivations.
More cosmetic than anything else. The description in findstring.patch was
duplicated, postgresql-9.6.1 references confusing. Timestamps are not
needed, that's what git blame is for.
Trying to understand what each patch does made me come up with some more
descriptive names:

- Renaming the two disable-xxx patches to a common names makes it immediately
  clear that one replaces the other depending on version number.
- findstring was really not descriptive at all.
- hardcode-pgxs-path will be extended with more paths for split outputs in
  a later commit. Renaming here already to allow git to better track renames.

Finally replacing HARDCODED_PGXS_PATH with $out/lib in the last patch, makes
it easier to understand what the end result will look like when reading the
patch.
This was introduced in 65fd8f3 around 20 years
ago as LANG=en_US, later changed to LC_ALL=en_US and LC_ALL=C to avoid bash
warnings. This might have been relevant to run initdb during the check phase, but
the PostgreSQL docs [1] say this today:

  For implementation reasons, setting LC_ALL does not work for this purpose

Therefore it can be removed safely.

[1]: https://www.postgresql.org/docs/current/regress-run.html#REGRESS-RUN-LOCALE
This seems to have been done better by now. There are no references kept
and the build does not fail when removing it.
This was introduced in NixOS#44083 to fix cross building, where xml2-config
wouldn't run on the host platform. This was fixed upstream two years
later [1], so that from v13 on pkg-config is used before xml2-config is.

Once v12 is EOL, we can remove this entirely.

[1]: postgres/postgres@0bc8ceb
This was disabled to fix NixOS#51093. The related discussion upstream revealed that this
has been fixed in [1] for v12+. Since v12 is our oldest supported version right now,
we should be able to safely enable parallel building on darwin again.

Furthermore, it seems that this kind of issue was also fixed in NixOS#51221 and NixOS#51408
for the general case.

[1]: postgres/postgres@826eff5
Those currently don't build on master, not sure whether they ever built
correctly in the first place.
The enableJIT = true case was fixed in NixOS#221851 or
e2fb651 respectively.

However this did not take the case into consideration, when doing this:

    services.postgresql = {
      enable = true;
      enableJIT = false;
      package = pkgs.postgresql_15_jit;
    };

If enableJIT is treated as the source of truth, then this should indeed
cause JIT to be disabled, which this commit does.
This was introduced in NixOS#228349, but doesn't seem necessary to build for pkgsMusl.

In fact the patch itself seems to be very specific about a stripped down icu
package in Alpine Linux, which does not apply to nixpkgs.
We don't have postgresql < 12 in nixpkgs anymore.
@wolfgangwalther
Copy link
Contributor Author

Rebased to fix the previously failing format check (#301268).

@Ma27
Copy link
Member

Ma27 commented Apr 15, 2024

Looking good. Would like to run a few tests on my own with it before approving and merging.

Btw cc @yu-re-ka would you mind taking a look at the musl-related patches?

Nice work!

@wolfgangwalther
Copy link
Contributor Author

Btw cc @yu-re-ka would you mind taking a look at the musl-related patches?

We already had a discussion about the icu related patches here: #228349 (comment)

@Ma27
Copy link
Member

Ma27 commented Apr 16, 2024

Apologies for the unnecessary ping then!

I thought there was discussion around that, but I didn't find it in this thread, sorry.

@Ma27 Ma27 merged commit cba6af7 into NixOS:staging Apr 19, 2024
24 checks passed
@Ma27
Copy link
Member

Ma27 commented Apr 19, 2024

Thanks a lot for your work and your patience!
#294504 needs a rebase now btw :)
Will try to get to reviewing that part soonish.

@wolfgangwalther wolfgangwalther deleted the postgresql-cleanup branch April 20, 2024 09:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` 10.rebuild-darwin: 501+ 10.rebuild-darwin: 2501-5000 10.rebuild-linux: 501+ 10.rebuild-linux: 5001+ 12.approved-by: package-maintainer This PR was reviewed and approved by a maintainer listed in the package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants