postgresql: refactor mkPackages in default.nix

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 commit is contained in:
Wolfgang Walther 2024-02-29 14:05:47 +01:00
parent 1d9f2bd726
commit 62635c9643
No known key found for this signature in database
GPG Key ID: B39893FA5F65CAE1
2 changed files with 23 additions and 41 deletions

View File

@ -1,43 +1,25 @@
self:
let
mkPackages = self: {
postgresql_12 = import ./12.nix {
this = self.postgresql_12;
thisAttr = "postgresql_12";
inherit self;
};
postgresql_13 = import ./13.nix {
this = self.postgresql_13;
thisAttr = "postgresql_13";
inherit self;
};
postgresql_14 = import ./14.nix {
this = self.postgresql_14;
thisAttr = "postgresql_14";
inherit self;
};
postgresql_15 = import ./15.nix {
this = self.postgresql_15;
thisAttr = "postgresql_15";
inherit self;
};
postgresql_16 = import ./16.nix {
this = self.postgresql_16;
thisAttr = "postgresql_16";
inherit self;
};
versions = {
postgresql_12 = ./12.nix;
postgresql_13 = ./13.nix;
postgresql_14 = ./14.nix;
postgresql_15 = ./15.nix;
postgresql_16 = ./16.nix;
};
in self:
let packages = mkPackages self; in
packages
// self.lib.mapAttrs'
(attrName: postgres: self.lib.nameValuePair "${attrName}_jit" (postgres.override rec {
jitSupport = true;
thisAttr = "${attrName}_jit";
this = self.${thisAttr};
}))
packages
mkAttributes = jitSupport:
self.lib.mapAttrs' (version: path:
let
attrName = if jitSupport then "${version}_jit" else version;
in
self.lib.nameValuePair attrName (import path {
inherit jitSupport self;
thisAttr = attrName;
this = self.${attrName};
})
) versions;
in
# variations without and with JIT
(mkAttributes false) // (mkAttributes true)

View File

@ -21,7 +21,7 @@ let
, testers, nixosTests, thisAttr
# JIT
, jitSupport ? false
, jitSupport
, nukeReferences, patchelf, llvmPackages
, makeRustPlatform, buildPgxExtension, cargo, rustc