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
wolfgangwalther
left a comment
There was a problem hiding this comment.
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 |
marsam
left a comment
There was a problem hiding this comment.
LGTM. Good work, thank you!
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.nixis split into multiple files and somepassthruattributes 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.postgresqlwork - 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
_jitdon't change, so it's a pure refactor.The files are structured like this:
default.nixcontains the logic to create all the top-level attributes, both with and without_jitsuffix.<major>.nixfiles contain the version-specific stuff: version number, hashes, musl patches. This is recommended here.generic.nixhas 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.nixonly has those parts which are specific to the autotools builds. This makes it easy to add ameson.nixnext to it later.Along the way, I also cleaned up a few things around arguments and passthru attributes:
readlinepassthru attribute introduced around 20 years ago - but entirely unused. Removed.psqlSchemais auto-created instead of passed for each version. Less chance for error when copy&pasting for a new version.jitSupport/llvmare not passed as passthru attributes to extensions, but viacallPackage/ the new pkgs scope. Again, reduces the chance for mistakes.thisargument is removed and replaced with internal recursion. This makes it possible to actually have things like(postgresql.override { jitSupport = true; }).pkgs.postgiswork correctly without making sure to passthisall the time.I also have commits to clean up
thisAttrwhich suffers from the same problem for tests thatthisdid - 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 = 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.