From a2128516a703f832455e8b22f37e8b66379ff04c Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Fri, 22 Nov 2024 19:17:32 +0100 Subject: [PATCH 1/9] postgresql: sort and group dependencies A bit of structure and much more diff-friendly. --- pkgs/servers/sql/postgresql/generic.nix | 76 ++++++++++++++++++------- 1 file changed, 56 insertions(+), 20 deletions(-) diff --git a/pkgs/servers/sql/postgresql/generic.nix b/pkgs/servers/sql/postgresql/generic.nix index 5adb3db67db69..4941ac4c29915 100644 --- a/pkgs/servers/sql/postgresql/generic.nix +++ b/pkgs/servers/sql/postgresql/generic.nix @@ -1,34 +1,70 @@ let generic = - # dependencies - { stdenv, lib, fetchurl, fetchpatch, makeWrapper - , glibc, zlib, readline, openssl, icu, lz4, zstd, systemdLibs, libuuid - , pkg-config, libxml2, tzdata, libkrb5, substituteAll, darwin - , linux-pam, bison, flex, perl, docbook_xml_dtd_45, docbook-xsl-nons, libxslt - - , removeReferencesTo, writeShellScriptBin - - , systemdSupport ? lib.meta.availableOn stdenv.hostPlatform systemdLibs - , gssSupport ? with stdenv.hostPlatform; !isWindows && !isStatic - - # for postgresql.pkgs - , self, newScope, buildEnv - , stdenvNoCC, postgresqlTestHook + # utils + { stdenv + , fetchpatch + , fetchurl + , lib + , substituteAll + , writeShellScriptBin # source specification - , version, hash, muslPatches ? {} - - # for tests - , testers, nixosTests + , hash + , muslPatches ? {} + , version + + # runtime dependencies + , darwin + , glibc + , icu + , libuuid + , libxml2 + , linux-pam + , lz4 + , openssl + , readline + , tzdata + , zlib + , zstd + + # build dependencies + , bison + , docbook-xsl-nons + , docbook_xml_dtd_45 + , flex + , libxslt + , makeWrapper + , perl + , pkg-config + , removeReferencesTo + + # passthru + , buildEnv + , newScope + , nixosTests + , postgresqlTestHook + , self + , stdenvNoCC + , testers + + # GSSAPI + , gssSupport ? with stdenv.hostPlatform; !isWindows && !isStatic + , libkrb5 # JIT - , jitSupport - , nukeReferences, llvmPackages, overrideCC + , jitSupport # not default on purpose, this is set via "_jit or not" attributes + , llvmPackages + , nukeReferences + , overrideCC # PL/Python , pythonSupport ? false , python3 + + # Systemd + , systemdSupport ? lib.meta.availableOn stdenv.hostPlatform systemdLibs + , systemdLibs } @args: let atLeast = lib.versionAtLeast version; From 6bafc8f578c900d5cb168193e8f0bb9fa68121cb Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Fri, 22 Nov 2024 19:19:43 +0100 Subject: [PATCH 2/9] postgresql: make PAM optional --- pkgs/servers/sql/postgresql/generic.nix | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pkgs/servers/sql/postgresql/generic.nix b/pkgs/servers/sql/postgresql/generic.nix index 4941ac4c29915..c5018c5a9259b 100644 --- a/pkgs/servers/sql/postgresql/generic.nix +++ b/pkgs/servers/sql/postgresql/generic.nix @@ -20,7 +20,6 @@ let , icu , libuuid , libxml2 - , linux-pam , lz4 , openssl , readline @@ -58,6 +57,10 @@ let , nukeReferences , overrideCC + # PAM + , pamSupport ? stdenv.hostPlatform.isLinux + , linux-pam + # PL/Python , pythonSupport ? false , python3 @@ -135,7 +138,7 @@ let ++ lib.optionals systemdSupport [ systemdLibs ] ++ lib.optionals pythonSupport [ python3 ] ++ lib.optionals gssSupport [ libkrb5 ] - ++ lib.optionals stdenv'.hostPlatform.isLinux [ linux-pam ]; + ++ lib.optionals pamSupport [ linux-pam ]; nativeBuildInputs = [ makeWrapper @@ -173,7 +176,7 @@ let ++ lib.optionals gssSupport [ "--with-gssapi" ] ++ lib.optionals pythonSupport [ "--with-python" ] ++ lib.optionals jitSupport [ "--with-llvm" ] - ++ lib.optionals stdenv'.hostPlatform.isLinux [ "--with-pam" ] + ++ lib.optionals pamSupport [ "--with-pam" ] # This could be removed once the upstream issue is resolved: # https://postgr.es/m/flat/427c7c25-e8e1-4fc5-a1fb-01ceff185e5b%40technowledgy.de ++ lib.optionals (stdenv'.hostPlatform.isDarwin && atLeast "16") [ "LDFLAGS_EX_BE=-Wl,-export_dynamic" ] From 5f7a1e814c233c4aced75f51725509e87b11970a Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Fri, 22 Nov 2024 19:24:25 +0100 Subject: [PATCH 3/9] postgresql: make icu optional --- pkgs/servers/sql/postgresql/generic.nix | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/pkgs/servers/sql/postgresql/generic.nix b/pkgs/servers/sql/postgresql/generic.nix index c5018c5a9259b..c831bff49b2ff 100644 --- a/pkgs/servers/sql/postgresql/generic.nix +++ b/pkgs/servers/sql/postgresql/generic.nix @@ -17,7 +17,6 @@ let # runtime dependencies , darwin , glibc - , icu , libuuid , libxml2 , lz4 @@ -51,6 +50,10 @@ let , gssSupport ? with stdenv.hostPlatform; !isWindows && !isStatic , libkrb5 + # icu + , icuSupport ? true + , icu + # JIT , jitSupport # not default on purpose, this is set via "_jit or not" attributes , llvmPackages @@ -129,9 +132,9 @@ let readline openssl (libxml2.override {enableHttp = true;}) - icu libuuid ] + ++ lib.optionals icuSupport [ icu ] ++ lib.optionals jitSupport [ llvmPackages.llvm ] ++ lib.optionals lz4Enabled [ lz4 ] ++ lib.optionals zstdEnabled [ zstd ] @@ -162,10 +165,10 @@ let env.CFLAGS = "-fdata-sections -ffunction-sections" + (if stdenv'.cc.isClang then " -flto" else " -fmerge-constants -Wl,--gc-sections"); - configureFlags = [ + configureFlags = let inherit (lib) withFeature; in [ "--with-openssl" "--with-libxml" - "--with-icu" + (withFeature icuSupport "icu") "--sysconfdir=/etc" "--with-system-tzdata=${tzdata}/share/zoneinfo" "--enable-debug" From 53c64f04a73de74d8ac79624f5059998dd6275b3 Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Fri, 22 Nov 2024 19:33:00 +0100 Subject: [PATCH 4/9] postgresql: add perlSupport option --- pkgs/servers/sql/postgresql/generic.nix | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pkgs/servers/sql/postgresql/generic.nix b/pkgs/servers/sql/postgresql/generic.nix index c831bff49b2ff..bb2a32a32bbea 100644 --- a/pkgs/servers/sql/postgresql/generic.nix +++ b/pkgs/servers/sql/postgresql/generic.nix @@ -33,7 +33,6 @@ let , flex , libxslt , makeWrapper - , perl , pkg-config , removeReferencesTo @@ -64,6 +63,10 @@ let , pamSupport ? stdenv.hostPlatform.isLinux , linux-pam + # PL/Perl + , perlSupport ? false + , perl + # PL/Python , pythonSupport ? false , python3 @@ -141,7 +144,8 @@ let ++ lib.optionals systemdSupport [ systemdLibs ] ++ lib.optionals pythonSupport [ python3 ] ++ lib.optionals gssSupport [ libkrb5 ] - ++ lib.optionals pamSupport [ linux-pam ]; + ++ lib.optionals pamSupport [ linux-pam ] + ++ lib.optionals perlSupport [ perl ]; nativeBuildInputs = [ makeWrapper @@ -183,7 +187,7 @@ let # This could be removed once the upstream issue is resolved: # https://postgr.es/m/flat/427c7c25-e8e1-4fc5-a1fb-01ceff185e5b%40technowledgy.de ++ lib.optionals (stdenv'.hostPlatform.isDarwin && atLeast "16") [ "LDFLAGS_EX_BE=-Wl,-export_dynamic" ] - ++ lib.optionals (atLeast "17") [ "--without-perl" ]; + ++ lib.optionals (atLeast "17" && !perlSupport) [ "--without-perl" ]; patches = [ (if atLeast "16" then ./patches/relative-to-symlinks-16+.patch else ./patches/relative-to-symlinks.patch) From 1d6870f81e420bd7e54c73ecee22164236bd799a Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Fri, 22 Nov 2024 19:33:46 +0100 Subject: [PATCH 5/9] postgresql: add ldapSupport option --- pkgs/servers/sql/postgresql/generic.nix | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pkgs/servers/sql/postgresql/generic.nix b/pkgs/servers/sql/postgresql/generic.nix index bb2a32a32bbea..a8d211285156f 100644 --- a/pkgs/servers/sql/postgresql/generic.nix +++ b/pkgs/servers/sql/postgresql/generic.nix @@ -59,6 +59,10 @@ let , nukeReferences , overrideCC + # LDAP + , ldapSupport ? false + , openldap + # PAM , pamSupport ? stdenv.hostPlatform.isLinux , linux-pam @@ -145,7 +149,8 @@ let ++ lib.optionals pythonSupport [ python3 ] ++ lib.optionals gssSupport [ libkrb5 ] ++ lib.optionals pamSupport [ linux-pam ] - ++ lib.optionals perlSupport [ perl ]; + ++ lib.optionals perlSupport [ perl ] + ++ lib.optionals ldapSupport [ openldap ]; nativeBuildInputs = [ makeWrapper @@ -187,7 +192,8 @@ let # This could be removed once the upstream issue is resolved: # https://postgr.es/m/flat/427c7c25-e8e1-4fc5-a1fb-01ceff185e5b%40technowledgy.de ++ lib.optionals (stdenv'.hostPlatform.isDarwin && atLeast "16") [ "LDFLAGS_EX_BE=-Wl,-export_dynamic" ] - ++ lib.optionals (atLeast "17" && !perlSupport) [ "--without-perl" ]; + ++ lib.optionals (atLeast "17" && !perlSupport) [ "--without-perl" ] + ++ lib.optionals ldapSupport [ "--with-ldap" ]; patches = [ (if atLeast "16" then ./patches/relative-to-symlinks-16+.patch else ./patches/relative-to-symlinks.patch) From ac3961828b4f557ae80febaae0c976b1e2b00ff6 Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Fri, 22 Nov 2024 19:40:20 +0100 Subject: [PATCH 6/9] postgresql: add tclSupport option --- pkgs/servers/sql/postgresql/generic.nix | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pkgs/servers/sql/postgresql/generic.nix b/pkgs/servers/sql/postgresql/generic.nix index a8d211285156f..a632b1ae8c7ce 100644 --- a/pkgs/servers/sql/postgresql/generic.nix +++ b/pkgs/servers/sql/postgresql/generic.nix @@ -75,6 +75,10 @@ let , pythonSupport ? false , python3 + # PL/Tcl + , tclSupport ? false + , tcl + # Systemd , systemdSupport ? lib.meta.availableOn stdenv.hostPlatform systemdLibs , systemdLibs @@ -150,7 +154,8 @@ let ++ lib.optionals gssSupport [ libkrb5 ] ++ lib.optionals pamSupport [ linux-pam ] ++ lib.optionals perlSupport [ perl ] - ++ lib.optionals ldapSupport [ openldap ]; + ++ lib.optionals ldapSupport [ openldap ] + ++ lib.optionals tclSupport [ tcl ]; nativeBuildInputs = [ makeWrapper @@ -193,7 +198,8 @@ let # https://postgr.es/m/flat/427c7c25-e8e1-4fc5-a1fb-01ceff185e5b%40technowledgy.de ++ lib.optionals (stdenv'.hostPlatform.isDarwin && atLeast "16") [ "LDFLAGS_EX_BE=-Wl,-export_dynamic" ] ++ lib.optionals (atLeast "17" && !perlSupport) [ "--without-perl" ] - ++ lib.optionals ldapSupport [ "--with-ldap" ]; + ++ lib.optionals ldapSupport [ "--with-ldap" ] + ++ lib.optionals tclSupport [ "--with-tcl" ]; patches = [ (if atLeast "16" then ./patches/relative-to-symlinks-16+.patch else ./patches/relative-to-symlinks.patch) From cb8a1c74f37765ab728d13a69a113d8b55651237 Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Fri, 22 Nov 2024 19:45:01 +0100 Subject: [PATCH 7/9] postgresql: add selinuxSupport option --- pkgs/servers/sql/postgresql/generic.nix | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pkgs/servers/sql/postgresql/generic.nix b/pkgs/servers/sql/postgresql/generic.nix index a632b1ae8c7ce..7af3df9fe03c2 100644 --- a/pkgs/servers/sql/postgresql/generic.nix +++ b/pkgs/servers/sql/postgresql/generic.nix @@ -79,6 +79,10 @@ let , tclSupport ? false , tcl + # SELinux + , selinuxSupport ? false + , libselinux + # Systemd , systemdSupport ? lib.meta.availableOn stdenv.hostPlatform systemdLibs , systemdLibs @@ -155,7 +159,8 @@ let ++ lib.optionals pamSupport [ linux-pam ] ++ lib.optionals perlSupport [ perl ] ++ lib.optionals ldapSupport [ openldap ] - ++ lib.optionals tclSupport [ tcl ]; + ++ lib.optionals tclSupport [ tcl ] + ++ lib.optionals selinuxSupport [ libselinux ]; nativeBuildInputs = [ makeWrapper @@ -199,7 +204,8 @@ let ++ lib.optionals (stdenv'.hostPlatform.isDarwin && atLeast "16") [ "LDFLAGS_EX_BE=-Wl,-export_dynamic" ] ++ lib.optionals (atLeast "17" && !perlSupport) [ "--without-perl" ] ++ lib.optionals ldapSupport [ "--with-ldap" ] - ++ lib.optionals tclSupport [ "--with-tcl" ]; + ++ lib.optionals tclSupport [ "--with-tcl" ] + ++ lib.optionals selinuxSupport [ "--with-selinux" ]; patches = [ (if atLeast "16" then ./patches/relative-to-symlinks-16+.patch else ./patches/relative-to-symlinks.patch) From b492340e98b8db95ec56f47ff15eba82078315d2 Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Fri, 22 Nov 2024 19:49:22 +0100 Subject: [PATCH 8/9] postgresql: add nlsSupport option --- pkgs/servers/sql/postgresql/generic.nix | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pkgs/servers/sql/postgresql/generic.nix b/pkgs/servers/sql/postgresql/generic.nix index 7af3df9fe03c2..5b90c22063272 100644 --- a/pkgs/servers/sql/postgresql/generic.nix +++ b/pkgs/servers/sql/postgresql/generic.nix @@ -63,6 +63,10 @@ let , ldapSupport ? false , openldap + # NLS + , nlsSupport ? false + , gettext + # PAM , pamSupport ? stdenv.hostPlatform.isLinux , linux-pam @@ -160,7 +164,8 @@ let ++ lib.optionals perlSupport [ perl ] ++ lib.optionals ldapSupport [ openldap ] ++ lib.optionals tclSupport [ tcl ] - ++ lib.optionals selinuxSupport [ libselinux ]; + ++ lib.optionals selinuxSupport [ libselinux ] + ++ lib.optionals nlsSupport [ gettext ]; nativeBuildInputs = [ makeWrapper @@ -205,7 +210,8 @@ let ++ lib.optionals (atLeast "17" && !perlSupport) [ "--without-perl" ] ++ lib.optionals ldapSupport [ "--with-ldap" ] ++ lib.optionals tclSupport [ "--with-tcl" ] - ++ lib.optionals selinuxSupport [ "--with-selinux" ]; + ++ lib.optionals selinuxSupport [ "--with-selinux" ] + ++ lib.optionals nlsSupport [ "--enable-nls" ]; patches = [ (if atLeast "16" then ./patches/relative-to-symlinks-16+.patch else ./patches/relative-to-symlinks.patch) From 4aa1cda21f5a82e96f4a18d9c8c423b13ad3a3d6 Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Fri, 22 Nov 2024 20:39:31 +0100 Subject: [PATCH 9/9] postgresql: add bonjourSupport option --- pkgs/servers/sql/postgresql/generic.nix | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkgs/servers/sql/postgresql/generic.nix b/pkgs/servers/sql/postgresql/generic.nix index 5b90c22063272..5904cd93fc755 100644 --- a/pkgs/servers/sql/postgresql/generic.nix +++ b/pkgs/servers/sql/postgresql/generic.nix @@ -45,6 +45,9 @@ let , stdenvNoCC , testers + # bonjour + , bonjourSupport ? false + # GSSAPI , gssSupport ? with stdenv.hostPlatform; !isWindows && !isStatic , libkrb5 @@ -211,7 +214,8 @@ let ++ lib.optionals ldapSupport [ "--with-ldap" ] ++ lib.optionals tclSupport [ "--with-tcl" ] ++ lib.optionals selinuxSupport [ "--with-selinux" ] - ++ lib.optionals nlsSupport [ "--enable-nls" ]; + ++ lib.optionals nlsSupport [ "--enable-nls" ] + ++ lib.optionals bonjourSupport [ "--with-bonjour" ]; patches = [ (if atLeast "16" then ./patches/relative-to-symlinks-16+.patch else ./patches/relative-to-symlinks.patch)