postgresql: refactor to remove "this" argument

This was proposed by abbradar in #150801, but left out of the follow up PR
#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 commit is contained in:
Wolfgang Walther 2024-02-29 19:31:41 +01:00
parent 14b3ea2789
commit 4b6bce5c31
No known key found for this signature in database
GPG Key ID: B39893FA5F65CAE1
4 changed files with 6 additions and 7 deletions

View File

@ -277,7 +277,7 @@ self: super: {
Here's a recipe on how to override a particular plugin through an overlay:
```
self: super: {
postgresql_15 = super.postgresql_15.override { this = self.postgresql_15; } // {
postgresql_15 = super.postgresql_15// {
pkgs = super.postgresql_15.pkgs // {
pg_repack = super.postgresql_15.pkgs.pg_repack.overrideAttrs (_: {
name = "pg_repack-v20181024";

View File

@ -16,7 +16,6 @@ let
self.lib.nameValuePair attrName (import path {
inherit jitSupport self;
thisAttr = attrName;
this = self.${attrName};
})
) versions;

View File

@ -12,7 +12,7 @@ let
, gssSupport ? with stdenv.hostPlatform; !isWindows && !isStatic
# for postgresql.pkgs
, this, self, newScope, buildEnv
, self, newScope, buildEnv
# source specification
, version, hash, muslPatches
@ -32,7 +32,7 @@ let
# detection of crypt fails when using llvm stdenv, so we add it manually
# for <13 (where it got removed: https://github.com/postgres/postgres/commit/c45643d618e35ec2fe91438df15abd4f3c0d85ca)
, libxcrypt
}:
} @args:
let
atLeast = lib.versionAtLeast version;
olderThan = lib.versionOlder version;
@ -215,9 +215,9 @@ let
disallowedReferences = [ stdenv'.cc ];
passthru = let
this = self.callPackage generic args;
jitToggle = this.override {
jitSupport = !jitSupport;
this = jitToggle;
};
in
{

View File

@ -26748,8 +26748,8 @@ with pkgs;
postgresql_15_jit
postgresql_16_jit
;
postgresql = postgresql_15.override { this = postgresql; };
postgresql_jit = postgresql_15_jit.override { this = postgresql_jit; };
postgresql = postgresql_15;
postgresql_jit = postgresql_15_jit;
postgresqlPackages = recurseIntoAttrs postgresql.pkgs;
postgresqlJitPackages = recurseIntoAttrs postgresql_jit.pkgs;
postgresql12Packages = recurseIntoAttrs postgresql_12.pkgs;