Skip to content

Commit 359ac18

Browse files
committed
chore: % nix fmt
1 parent fd7f8f5 commit 359ac18

File tree

4 files changed

+168
-163
lines changed

4 files changed

+168
-163
lines changed

nix/ext/pgrouting.nix

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ let
5656

5757
cmakeFlags =
5858
[ "-DPOSTGRESQL_VERSION=${postgresql.version}" ]
59-
++ lib.optionals (stdenv.isDarwin && lib.versionAtLeast postgresql.version "16") [
60-
"-DCMAKE_MACOSX_RPATH=ON"
61-
"-DCMAKE_SHARED_MODULE_SUFFIX=.dylib"
62-
"-DCMAKE_SHARED_LIBRARY_SUFFIX=.dylib"
63-
];
59+
++ lib.optionals (stdenv.isDarwin && lib.versionAtLeast postgresql.version "16") [
60+
"-DCMAKE_MACOSX_RPATH=ON"
61+
"-DCMAKE_SHARED_MODULE_SUFFIX=.dylib"
62+
"-DCMAKE_SHARED_LIBRARY_SUFFIX=.dylib"
63+
];
6464

6565
preConfigure = lib.optionalString (stdenv.isDarwin && lib.versionAtLeast postgresql.version "16") ''
6666
export DLSUFFIX=.dylib

nix/ext/tests/lib.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ def assert_version_matches(self, expected_version: str):
8484
AssertionError: If the installed version does not match the expected version
8585
"""
8686
installed_version = self.get_installed_version()
87-
assert installed_version == expected_version, (
88-
f"Expected version {expected_version}, but found {installed_version}"
89-
)
87+
assert (
88+
installed_version == expected_version
89+
), f"Expected version {expected_version}, but found {installed_version}"
9090

9191
def check_upgrade_path(self, pg_version: str):
9292
"""Test the complete upgrade path for a PostgreSQL version.
@@ -172,6 +172,6 @@ def check_switch_extension_with_background_worker(
172172
self.vm.succeed(f"switch_{self.extension_name}_version {last_version}")
173173
# Check that we are using the last version now
174174
ext_version = self.vm.succeed(f"readlink -f {extension_lib_path}").strip()
175-
assert ext_version.endswith(f"{self.extension_name}-{last_version}.so"), (
176-
f"Expected {self.extension_name} version {last_version}, but found {ext_version}"
177-
)
175+
assert ext_version.endswith(
176+
f"{self.extension_name}-{last_version}.so"
177+
), f"Expected {self.extension_name} version {last_version}, but found {ext_version}"

nix/ext/wal2json.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
let
1111
pname = "wal2json";
1212
build =
13-
version: rev: hash:
13+
version: _rev: hash:
1414
stdenv.mkDerivation rec {
1515
inherit version pname;
1616

nix/postgresql/generic.nix

Lines changed: 156 additions & 151 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,6 @@ let
6464
# detection of crypt fails when using llvm stdenv, so we add it manually
6565
# for <13 (where it got removed: https://github.com/postgres/postgres/commit/c45643d618e35ec2fe91438df15abd4f3c0d85ca)
6666
libxcrypt,
67-
68-
isOrioleDB ? false,
6967
}@args:
7068
let
7169
atLeast = lib.versionAtLeast version;
@@ -107,43 +105,45 @@ let
107105
];
108106
setOutputFlags = false; # $out retains configureFlags :-/
109107

110-
buildInputs = [
111-
zlib
112-
readline
113-
openssl
114-
(libxml2.override { python3 = python3; })
115-
# Pin ICU to version 75 to maintain collation version 153.120
116-
# This prevents collation mismatch warnings when upgrading nixpkgs
117-
icu75
118-
]
119-
++ lib.optionals (olderThan "13") [ libxcrypt ]
120-
++ lib.optionals jitSupport [ llvmPackages.llvm ]
121-
++ lib.optionals lz4Enabled [ lz4 ]
122-
++ lib.optionals zstdEnabled [ zstd ]
123-
++ lib.optionals systemdSupport' [ systemd ]
124-
++ lib.optionals pythonSupport [ python3 ]
125-
++ lib.optionals gssSupport [ libkrb5 ]
126-
++ lib.optionals stdenv'.isLinux [ linux-pam ]
127-
++ lib.optionals (!stdenv'.isDarwin) [ libossp_uuid ]
128-
++ lib.optionals (isOrioleDB || (lib.versionAtLeast version "17")) [
129-
perl
130-
bison
131-
flex
132-
docbook_xsl
133-
docbook_xml_dtd_45
134-
docbook_xsl_ns
135-
libxslt
136-
];
108+
buildInputs =
109+
[
110+
zlib
111+
readline
112+
openssl
113+
(libxml2.override { python3 = python3; })
114+
# Pin ICU to version 75 to maintain collation version 153.120
115+
# This prevents collation mismatch warnings when upgrading nixpkgs
116+
icu75
117+
]
118+
++ lib.optionals (olderThan "13") [ libxcrypt ]
119+
++ lib.optionals jitSupport [ llvmPackages.llvm ]
120+
++ lib.optionals lz4Enabled [ lz4 ]
121+
++ lib.optionals zstdEnabled [ zstd ]
122+
++ lib.optionals systemdSupport' [ systemd ]
123+
++ lib.optionals pythonSupport [ python3 ]
124+
++ lib.optionals gssSupport [ libkrb5 ]
125+
++ lib.optionals stdenv'.isLinux [ linux-pam ]
126+
++ lib.optionals (!stdenv'.isDarwin) [ libossp_uuid ]
127+
++ lib.optionals (isOrioleDB || (lib.versionAtLeast version "17")) [
128+
perl
129+
bison
130+
flex
131+
docbook_xsl
132+
docbook_xml_dtd_45
133+
docbook_xsl_ns
134+
libxslt
135+
];
137136

138-
nativeBuildInputs = [
139-
makeWrapper
140-
pkg-config
141-
]
142-
++ lib.optionals jitSupport [
143-
llvmPackages.llvm.dev
144-
nukeReferences
145-
patchelf
146-
];
137+
nativeBuildInputs =
138+
[
139+
makeWrapper
140+
pkg-config
141+
]
142+
++ lib.optionals jitSupport [
143+
llvmPackages.llvm.dev
144+
nukeReferences
145+
patchelf
146+
];
147147

148148
enableParallelBuilding = true;
149149

@@ -156,109 +156,113 @@ let
156156
# Fixed upstream in https://github.com/postgres/postgres/commit/0bc8cebdb889368abdf224aeac8bc197fe4c9ae6
157157
env.NIX_CFLAGS_COMPILE = lib.optionalString (olderThan "13") "-I${libxml2.dev}/include/libxml2";
158158

159-
configureFlags = [
160-
"--with-openssl"
161-
"--with-libxml"
162-
"--with-icu"
163-
"--sysconfdir=/etc"
164-
"--libdir=$(lib)/lib"
165-
"--with-system-tzdata=${tzdata}/share/zoneinfo"
166-
"--enable-debug"
167-
(lib.optionalString systemdSupport' "--with-systemd")
168-
(if stdenv'.isDarwin then "--with-uuid=e2fs" else "--with-ossp-uuid")
169-
]
170-
++ lib.optionals lz4Enabled [ "--with-lz4" ]
171-
++ lib.optionals zstdEnabled [ "--with-zstd" ]
172-
++ lib.optionals gssSupport [ "--with-gssapi" ]
173-
++ lib.optionals pythonSupport [ "--with-python" ]
174-
++ lib.optionals jitSupport [ "--with-llvm" ]
175-
++ lib.optionals stdenv'.isLinux [ "--with-pam" ];
176-
177-
patches = [
178-
(
179-
if atLeast "16" then
180-
./patches/relative-to-symlinks-16+.patch
181-
else
182-
./patches/relative-to-symlinks.patch
159+
configureFlags =
160+
[
161+
"--with-openssl"
162+
"--with-libxml"
163+
"--with-icu"
164+
"--sysconfdir=/etc"
165+
"--libdir=$(lib)/lib"
166+
"--with-system-tzdata=${tzdata}/share/zoneinfo"
167+
"--enable-debug"
168+
(lib.optionalString systemdSupport' "--with-systemd")
169+
(if stdenv'.isDarwin then "--with-uuid=e2fs" else "--with-ossp-uuid")
170+
]
171+
++ lib.optionals lz4Enabled [ "--with-lz4" ]
172+
++ lib.optionals zstdEnabled [ "--with-zstd" ]
173+
++ lib.optionals gssSupport [ "--with-gssapi" ]
174+
++ lib.optionals pythonSupport [ "--with-python" ]
175+
++ lib.optionals jitSupport [ "--with-llvm" ]
176+
++ lib.optionals stdenv'.isLinux [ "--with-pam" ];
177+
178+
patches =
179+
[
180+
(
181+
if atLeast "16" then
182+
./patches/relative-to-symlinks-16+.patch
183+
else
184+
./patches/relative-to-symlinks.patch
185+
)
186+
./patches/less-is-more.patch
187+
./patches/paths-for-split-outputs.patch
188+
./patches/specify_pkglibdir_at_runtime.patch
189+
./patches/paths-with-postgresql-suffix.patch
190+
191+
(replaceVars ./patches/locale-binary-path.patch {
192+
locale = "${if stdenv.isDarwin then darwin.adv_cmds else lib.getBin stdenv.cc.libc}/bin/locale";
193+
})
194+
]
195+
++ lib.optionals stdenv'.hostPlatform.isMusl (
196+
# Using fetchurl instead of fetchpatch on purpose: https://github.com/NixOS/nixpkgs/issues/240141
197+
map fetchurl (lib.attrValues muslPatches)
183198
)
184-
./patches/less-is-more.patch
185-
./patches/paths-for-split-outputs.patch
186-
./patches/specify_pkglibdir_at_runtime.patch
187-
./patches/paths-with-postgresql-suffix.patch
188-
189-
(replaceVars ./patches/locale-binary-path.patch {
190-
locale = "${if stdenv.isDarwin then darwin.adv_cmds else lib.getBin stdenv.cc.libc}/bin/locale";
191-
})
192-
]
193-
++ lib.optionals stdenv'.hostPlatform.isMusl (
194-
# Using fetchurl instead of fetchpatch on purpose: https://github.com/NixOS/nixpkgs/issues/240141
195-
map fetchurl (lib.attrValues muslPatches)
196-
)
197-
++ lib.optionals stdenv'.isLinux [
198-
(if atLeast "13" then ./patches/socketdir-in-run-13+.patch else ./patches/socketdir-in-run.patch)
199-
];
199+
++ lib.optionals stdenv'.isLinux [
200+
(if atLeast "13" then ./patches/socketdir-in-run-13+.patch else ./patches/socketdir-in-run.patch)
201+
];
200202

201203
installTargets = [ "install-world-bin" ];
202204

203-
postPatch = ''
204-
# Hardcode the path to pgxs so pg_config returns the path in $out
205-
substituteInPlace "src/common/config_info.c" --subst-var out
206-
''
207-
+ lib.optionalString jitSupport ''
208-
# Force lookup of jit stuff in $out instead of $lib
209-
substituteInPlace src/backend/jit/jit.c --replace pkglib_path \"$out/lib\"
210-
substituteInPlace src/backend/jit/llvm/llvmjit.c --replace pkglib_path \"$out/lib\"
211-
substituteInPlace src/backend/jit/llvm/llvmjit_inline.cpp --replace pkglib_path \"$out/lib\"
212-
'';
213-
214-
postInstall = ''
215-
moveToOutput "lib/pgxs" "$out" # looks strange, but not deleting it
216-
moveToOutput "lib/libpgcommon*.a" "$out"
217-
moveToOutput "lib/libpgport*.a" "$out"
218-
moveToOutput "lib/libecpg*" "$out"
219-
220-
# Prevent a retained dependency on gcc-wrapper.
221-
substituteInPlace "$out/lib/pgxs/src/Makefile.global" --replace ${stdenv'.cc}/bin/ld ld
222-
223-
if [ -z "''${dontDisableStatic:-}" ]; then
224-
# Remove static libraries in case dynamic are available.
225-
for i in $out/lib/*.a $lib/lib/*.a; do
226-
name="$(basename "$i")"
227-
ext="${stdenv'.hostPlatform.extensions.sharedLibrary}"
228-
if [ -e "$lib/lib/''${name%.a}$ext" ] || [ -e "''${i%.a}$ext" ]; then
229-
rm "$i"
230-
fi
231-
done
232-
fi
233-
''
234-
+ lib.optionalString jitSupport ''
235-
# Move the bitcode and libllvmjit.so library out of $lib; otherwise, every client that
236-
# depends on libpq.so will also have libLLVM.so in its closure too, bloating it
237-
moveToOutput "lib/bitcode" "$out"
238-
moveToOutput "lib/llvmjit*" "$out"
239-
240-
# In the case of JIT support, prevent a retained dependency on clang-wrapper
241-
substituteInPlace "$out/lib/pgxs/src/Makefile.global" --replace ${stdenv'.cc}/bin/clang clang
242-
nuke-refs $out/lib/llvmjit_types.bc $(find $out/lib/bitcode -type f)
243-
244-
# Stop out depending on the default output of llvm
245-
substituteInPlace $out/lib/pgxs/src/Makefile.global \
246-
--replace ${llvmPackages.llvm.out}/bin "" \
247-
--replace '$(LLVM_BINPATH)/' ""
248-
249-
# Stop out depending on the -dev output of llvm
250-
substituteInPlace $out/lib/pgxs/src/Makefile.global \
251-
--replace ${llvmPackages.llvm.dev}/bin/llvm-config llvm-config \
252-
--replace -I${llvmPackages.llvm.dev}/include ""
253-
254-
${lib.optionalString (!stdenv'.isDarwin) ''
255-
# Stop lib depending on the -dev output of llvm
256-
rpath=$(patchelf --print-rpath $out/lib/llvmjit.so)
257-
nuke-refs -e $out $out/lib/llvmjit.so
258-
# Restore the correct rpath
259-
patchelf $out/lib/llvmjit.so --set-rpath "$rpath"
260-
''}
261-
'';
205+
postPatch =
206+
''
207+
# Hardcode the path to pgxs so pg_config returns the path in $out
208+
substituteInPlace "src/common/config_info.c" --subst-var out
209+
''
210+
+ lib.optionalString jitSupport ''
211+
# Force lookup of jit stuff in $out instead of $lib
212+
substituteInPlace src/backend/jit/jit.c --replace pkglib_path \"$out/lib\"
213+
substituteInPlace src/backend/jit/llvm/llvmjit.c --replace pkglib_path \"$out/lib\"
214+
substituteInPlace src/backend/jit/llvm/llvmjit_inline.cpp --replace pkglib_path \"$out/lib\"
215+
'';
216+
217+
postInstall =
218+
''
219+
moveToOutput "lib/pgxs" "$out" # looks strange, but not deleting it
220+
moveToOutput "lib/libpgcommon*.a" "$out"
221+
moveToOutput "lib/libpgport*.a" "$out"
222+
moveToOutput "lib/libecpg*" "$out"
223+
224+
# Prevent a retained dependency on gcc-wrapper.
225+
substituteInPlace "$out/lib/pgxs/src/Makefile.global" --replace ${stdenv'.cc}/bin/ld ld
226+
227+
if [ -z "''${dontDisableStatic:-}" ]; then
228+
# Remove static libraries in case dynamic are available.
229+
for i in $out/lib/*.a $lib/lib/*.a; do
230+
name="$(basename "$i")"
231+
ext="${stdenv'.hostPlatform.extensions.sharedLibrary}"
232+
if [ -e "$lib/lib/''${name%.a}$ext" ] || [ -e "''${i%.a}$ext" ]; then
233+
rm "$i"
234+
fi
235+
done
236+
fi
237+
''
238+
+ lib.optionalString jitSupport ''
239+
# Move the bitcode and libllvmjit.so library out of $lib; otherwise, every client that
240+
# depends on libpq.so will also have libLLVM.so in its closure too, bloating it
241+
moveToOutput "lib/bitcode" "$out"
242+
moveToOutput "lib/llvmjit*" "$out"
243+
244+
# In the case of JIT support, prevent a retained dependency on clang-wrapper
245+
substituteInPlace "$out/lib/pgxs/src/Makefile.global" --replace ${stdenv'.cc}/bin/clang clang
246+
nuke-refs $out/lib/llvmjit_types.bc $(find $out/lib/bitcode -type f)
247+
248+
# Stop out depending on the default output of llvm
249+
substituteInPlace $out/lib/pgxs/src/Makefile.global \
250+
--replace ${llvmPackages.llvm.out}/bin "" \
251+
--replace '$(LLVM_BINPATH)/' ""
252+
253+
# Stop out depending on the -dev output of llvm
254+
substituteInPlace $out/lib/pgxs/src/Makefile.global \
255+
--replace ${llvmPackages.llvm.dev}/bin/llvm-config llvm-config \
256+
--replace -I${llvmPackages.llvm.dev}/include ""
257+
258+
${lib.optionalString (!stdenv'.isDarwin) ''
259+
# Stop lib depending on the -dev output of llvm
260+
rpath=$(patchelf --print-rpath $out/lib/llvmjit.so)
261+
nuke-refs -e $out $out/lib/llvmjit.so
262+
# Restore the correct rpath
263+
patchelf $out/lib/llvmjit.so --set-rpath "$rpath"
264+
''}
265+
'';
262266

263267
postFixup = lib.optionalString (!stdenv'.isDarwin && stdenv'.hostPlatform.libc == "glibc") ''
264268
# initdb needs access to "locale" command from glibc.
@@ -305,21 +309,22 @@ let
305309
postgresql = this;
306310
} this.pkgs;
307311

308-
tests = {
309-
postgresql-wal-receiver = import ../../../../nixos/tests/postgresql-wal-receiver.nix {
310-
inherit (stdenv) system;
311-
pkgs = self;
312-
package = this;
313-
};
314-
pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
315-
}
316-
// lib.optionalAttrs jitSupport {
317-
postgresql-jit = import ../../../../nixos/tests/postgresql-jit.nix {
318-
inherit (stdenv) system;
319-
pkgs = self;
320-
package = this;
312+
tests =
313+
{
314+
postgresql-wal-receiver = import ../../../../nixos/tests/postgresql-wal-receiver.nix {
315+
inherit (stdenv) system;
316+
pkgs = self;
317+
package = this;
318+
};
319+
pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
320+
}
321+
// lib.optionalAttrs jitSupport {
322+
postgresql-jit = import ../../../../nixos/tests/postgresql-jit.nix {
323+
inherit (stdenv) system;
324+
pkgs = self;
325+
package = this;
326+
};
321327
};
322-
};
323328
};
324329

325330
meta = with lib; {

0 commit comments

Comments
 (0)