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:
parent
1d9f2bd726
commit
62635c9643
@ -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)
|
||||
|
@ -21,7 +21,7 @@ let
|
||||
, testers, nixosTests, thisAttr
|
||||
|
||||
# JIT
|
||||
, jitSupport ? false
|
||||
, jitSupport
|
||||
, nukeReferences, patchelf, llvmPackages
|
||||
, makeRustPlatform, buildPgxExtension, cargo, rustc
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user