-
-
Notifications
You must be signed in to change notification settings - Fork 14.2k
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: refactor and cleanup #292993
postgresql: refactor and cleanup #292993
Conversation
May take until next week to get to it. But I'm definitely interested in reviewing that, thanks! |
It's unclear to me why It says something about a readline-related failure. Is that related to this?
I don't see how, though. |
Hmm, try running You don't need such hardware for the evaluation itself, that only gets relevant when it comes to building stuff, but the ofborg error looks like it didn't even get to that. |
Ah right, thanks for the hint. Both
|
Oh sorry I only saw the backtrace and didn't scroll down entirely 😅 |
82b9cc0
to
12bc04e
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.
Note: The latest push was just a rebase on latest master, no changes.
Regarding 32badde1f653b338314378e8918b036f538ea8ad: I'm not sure I understand the rationale behind moving things around there. |
Before this change, I would have to add this for a new version: postgresql_17 = import ./17.nix {
this = self.postgresql_17;
thisAttr = "postgresql_17";
inherit self;
}; In theory, there are 4 chances to get it wrong: Any of the 17s. After this change, I just need to do this: postgresql_17 = ./17.nix; Granted.. after the later changes to remove Another thing is, that with the old structure someone could theoretically come up later and add some version specific arguments in |
fb18d24
to
b76450a
Compare
b76450a
to
a5a33e5
Compare
Hmm... would you mind trying out if adding 2da789a409c67c99c7e7b27730256d42f10a5601 to No idea if that works out, but maybe worth a try? Anyways, I like that change and the fact that we got a few cleanups ready without any rebuilds. Will let a few other people review as well before merging. cc @marsam @thoughtpolice @ivan |
I think that's a great idea, not sure whether to wait to do this in a second PR (maybe in the follow up cleanup PR), once this is merged, to avoid having to change the commit hash.
👍 |
Fair. |
This commit is split up into two commits to allow git to detect renames, make rebasing easier and allow a working entry in .git-blame-ignore-revs. To allow bisecting we allow evaluation on every commit by moving the extensions into ext/ext/ first and back to ext/ with the next commit.
This aligns more with the commonly used style in nixpkgs.
No need to reference self here, because llvmPackages / stdenv' are available in that scope anyway. Pure refactor, derivations don't change.
This just renames default.nix to generic.nix, because the biggest chunk of code should move that way in the next commit. This gives us a much better diff for the next commit and makes rebasing **much** easier in case of changes. This commit does not stand on its own and needs to go in with the next commit (2/2).
The recommended [1] structure for a package regarding versioning is to have each version in a separate file. This commit just mechanically copies code around without any changes. Pure refactor, not changing any derivations. [1]: pkgs/README.md
Refactors some low hanging fruit in default.nix to make it easier to add new versions later on. Pure refactor, not changing any derivations. This change makes it easier to add new versions in default.nix without messing up - and also prevents us from adding version-specific arguments in default.nix by accident in the future. Those should be put in the versioned .nix files instead.
This seems to have been introduced 20 years ago in 5863d4f - but seems to have been a copy&paste mistake from the beginning. AFAICT, it's not used anywhere.
The passthru attribute is still set, but automatically created from the major version number. Fewer moving parts decrease the chance for mistakes.
This makes it obvious that the required argument muslPatches must be passed when creating a new version file. Pure refactor, not changing any derivations.
833abce
to
c4d2f56
Compare
Rebased after some new extensions caused a merge conflict for I think this is in good shape. @Ma27 do you think there will be any other reviewers? Otherwise, I think we could go ahead with what we have. No functional changes, so very likely no problem. |
Eval is failing otherwise this is probably fine |
…sthru This makes it less error-prone to use the llvm package in extensions, because it will always match the package used by the postgresql derivation itself. Previously, you could've accidentally used llvm instead of postgresql.llvm with a different result.
This was proposed by abbradar in NixOS#150801, but left out of the follow up PR NixOS#221851 by Ma27 to reduce the size of the diff. Compared to the initial proposal this includes the callPackage call in the recursion, which avoids breaking the withJIT/withoutJIT helpers. In terms of nixpkgs, this is a pure refactor, no derivations change. However, this makes downstream expressions like the following possible: (postgresql.override { jitSupport = true; }).pkgs.postgis This would have not worked before without passing another "this" argument, which is error prone as can be seen in this example: https://github.com/PostgREST/postgrest/pull/3222/files
This is the default anyway.
We have gssSupport, jitSupport and pythonSupport - but enableSystemd? Across nixpkgs there are currently three styles commonly used, about equally often: withX, xSupport and enableX. Let's at least use one consistent style in this package.
c4d2f56
to
e6bfabf
Compare
Ah, one of the new extensions after rebase was still using the old |
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.
LGTM. Good work, thank you!
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!
This was deprecated in e6bfabf, where we agreed on removing this after one release in [1]. Time has come! [1]: NixOS#292993 (comment)
Description of changes
TLDR: This is a pure refactor, where
postgresql/default.nix
is split into multiple files and somepassthru
attributes are cleaned up. No derivations are changed.Goal: I am currently working on building PG v16 via meson instead of autotools. This will make it possible to make
pkgsStatic.postgresql
work - at least for buildinglibpq
, which should cover almost all use-cases. This PR does not implement the meson build, yet. But to be able to have autotools-based builds up to v15 and meson-based builds for v16+ separated without repeating all the shared parts, this PR moves things around a little bit and splits them up in multiple files. But even without building with meson, the new structure is still an improvement, I think.This is best reviewed commit-by-commit. I tried to make it reviewable despite the big chunks of code moved around. The most important fact: The derivations for all 5 versions with and without
_jit
don't change, so it's a pure refactor.The files are structured like this:
default.nix
contains the logic to create all the top-level attributes, both with and without_jit
suffix.<major>.nix
files contain the version-specific stuff: version number, hashes, musl patches. This is recommended here.generic.nix
has all the metadata and most passthru arguments of the derivation, thus dealing with all the packages/extensions, tests and jit-helpers. It also contains all the patches, to make sure that both autotools and meson based builds will stay in sync.autotools.nix
only has those parts which are specific to the autotools builds. This makes it easy to add ameson.nix
next to it later.Along the way, I also cleaned up a few things around arguments and passthru attributes:
readline
passthru attribute introduced around 20 years ago - but entirely unused. Removed.psqlSchema
is auto-created instead of passed for each version. Less chance for error when copy&pasting for a new version.jitSupport
/llvm
are not passed as passthru attributes to extensions, but viacallPackage
/ the new pkgs scope. Again, reduces the chance for mistakes.this
argument is removed and replaced with internal recursion. This makes it possible to actually have things like(postgresql.override { jitSupport = true; }).pkgs.postgis
work correctly without making sure to passthis
all the time.I also have commits to clean up
thisAttr
which suffers from the same problem for tests thatthis
did - but those would not be a pure refactor anymore, so I'll put them in a separate PR.Pinging maintainers: @thoughtpolice @danbst @globin @marsam @ivan @Ma27
Things 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.