Skip to content

libpq: init at 17.2#359659

Merged
wolfgangwalther merged 5 commits intoNixOS:stagingfrom
wolfgangwalther:postgresql-libpq
Jan 19, 2025
Merged

libpq: init at 17.2#359659
wolfgangwalther merged 5 commits intoNixOS:stagingfrom
wolfgangwalther:postgresql-libpq

Conversation

@wolfgangwalther
Copy link
Contributor

@wolfgangwalther wolfgangwalther commented Nov 27, 2024

This creates a separate libpq package as discussed in #61580 (comment).

This brings down the number of rebuilds after updating postgresql to about 1.2k darwin and 2.5k linux. Before, they were ~ around 5k, IIRC.

Unfortunately, we are still not anywhere low enough to be able to merge postgresql updates directly into master. I think the nr. 1 reason for that is postgresqlTestHook - and the fact that many packages use a very simple postgresql server in their build dependencies for the check phase.

The only way to get the number of rebuilds lower would be to package postgresqlTestHook as a separate postgresql derivation. The idea would be, that security related issues are irrelevant for the check phase of other packages - and thus updating this separately could easily go through staging with a certain delay. This derivation could also be one that is built with the minimal feature set, making it slimmer overall.

I still think that introducing libpq is a good thing on it's own, thus this PR.

Closes #61580 and #191920

Things done

  • Built on platform(s)
    • x86_64-linux (the directly changed packages)
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 25.05 Release Notes (or backporting 24.11 and 25.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@github-actions github-actions bot added 6.topic: python Python is a high-level, general-purpose programming language. 6.topic: qt/kde Object-oriented framework for GUI creation 6.topic: rust General-purpose programming language emphasizing performance, type safety, and concurrency. 6.topic: ruby A dynamic, open source programming language with a focus on simplicity and productivity. 6.topic: ocaml OCaml is a general-purpose, high-level, multi-paradigm programming language. 6.topic: lua Lua is a powerful, efficient, lightweight, embeddable scripting language. 6.topic: games Gaming on NixOS 6.topic: php PHP is a general-purpose scripting language geared towards web development. 6.topic: continuous integration Affects continuous integration (CI) in Nixpkgs, including Ofborg and GitHub Actions labels Nov 27, 2024
@ofborg ofborg bot added the 2.status: merge conflict This PR has merge conflicts with the target branch label Nov 28, 2024
@wolfgangwalther wolfgangwalther force-pushed the postgresql-libpq branch 2 times, most recently from 1eb5366 to 862bd30 Compare November 28, 2024 18:48
@wolfgangwalther wolfgangwalther removed the 2.status: merge conflict This PR has merge conflicts with the target branch label Nov 28, 2024
@szlend szlend reopened this Jan 18, 2025
@szlend
Copy link
Member

szlend commented Jan 18, 2025

Apologies, misclicked 😅

@wolfgangwalther
Copy link
Contributor Author

wolfgangwalther commented Jan 19, 2025

After re-reading #294504 (comment) I'm not sure if I consider the status quo that bad: packages like psycopg or pdo_pgsql only depend on the lib output at runtime which is effectively libpq already. The static build seems to produce static libraries successfully as well nowadays. Regarding dependency concerns, one may still work with outputChecks.

Dependencies come into play whenever we need to (re-)build. For us the most relevant case is the one inside nixpkgs - where we discuss how to speed up merging to master etc.

However, there's more: Yes, postgresql builds in pkgsStatic now. But it still carries more dependencies. All of which might need to be rebuild when you're trying to actually cross-compile libpq. The whole cross-compilation thing was brought up repeatedly, e.g. in #61580 (comment).

hoping that we didn't discuss this before and I just didn't find the thread again

Essentially most of the discussion in #61580 is exactly about this. I'd summarize this as: many are for a split, few are for no split. Although, to be fair those numbers are certainly without considering the facts that the outputs are now split and pkgsStatic actually builds....

... that is, it builds on Linux.

One example why libpq is a good idea:

Try building pkgsStatic.libpq and pkgsStatic.postgresql on darwin. libpq succeeds* - and is fairly quick to build, because of fewer dependencies. Building the full postgresql pulls in some other dependencies, takes a lot longer - and then the build eventually fails while building a static perl.**

* which in itself is quite a 🥳 moment for me!
** the fact that it tries to build a static perl is stupid somehow, it shouldn't need that imho. It also tries to build static variants of some build tools like autoconf and automake.. - but the point is still valid: Getting the full postgresql build to work on non-hydra-built-platforms is a lot more complex.

@wolfgangwalther
Copy link
Contributor Author

FYI pushed a fix for pdo_pgsql/pgsql exts in PHP.

I squashed that into the main libpq commit.

@wolfgangwalther
Copy link
Contributor Author

Try building pkgsStatic.libpq and pkgsStatic.postgresql on darwin. libpq succeeds - and is fairly quick to build*, because of fewer dependencies. Building the full postgresql pulls in some other dependencies, takes a lot longer - and then the build eventually fails while building a static perl.**

Addition: The same happens for me on pkgsCross.x86_64-freebsd.postgresql vs pkgsCross.x86_64-freebsd.libpq. I can build libpq for freebsd, but not the full postgresql, yet.

@wolfgangwalther
Copy link
Contributor Author

I'm not sure.
I'm slightly leaning towards this solution

So was I, when I started my comment above. Finding out about darwin and freebsd and the actual practical consequences, I convinced myself. Thus: Merging!

@wolfgangwalther wolfgangwalther merged commit 105c451 into NixOS:staging Jan 19, 2025
22 of 27 checks passed
@wolfgangwalther wolfgangwalther deleted the postgresql-libpq branch January 19, 2025 14:57
@Ma27
Copy link
Member

Ma27 commented Jan 19, 2025

After sleeping one night over it and reading your comment, I also agree (just ftr).

Thanks a lot for your work here!

@trofi
Copy link
Contributor

trofi commented Jan 19, 2025

Bisect says 546ece5 libpq: init at 17.2 broke the pg-dump-anon.tests eval in staging as:

$ nix build --no-link -f. pg-dump-anon.tests
error:
       … while evaluating the attribute 'anonymizer'
         at pkgs/by-name/pg/pg-dump-anon/package.nix:24:54:
           23|
           24|   passthru.tests = { inherit (nixosTests.postgresql) anonymizer; };
             |                                                      ^
           25|

       … while evaluating a branch condition
         at nixos/tests/all-tests.nix:21:5:
           20|   discoverTests = val:
           21|     if isAttrs val
             |     ^
           22|     then

       (stack trace truncated; use '--show-trace' to show the full, detailed trace)

       error: attribute 'pkgs' missing
       at nixos/tests/postgresql/anonymizer.nix:112:29:
          111|   lib.concatMapAttrs (n: p: { ${n} = makeTestFor p; }) (
          112|     lib.filterAttrs (_: p: !p.pkgs.anonymizer.meta.broken) pkgs.postgresqlVersions
             |                             ^
          113|   )
       Did you mean args?

@wolfgangwalther
Copy link
Contributor Author

Bisect says 546ece5 libpq: init at 17.2 broke the pg-dump-anon.tests eval in staging as:

Thanks for the report. Will look into it later today.

@Ma27
Copy link
Member

Ma27 commented Jan 20, 2025

The issue is that postgresqlVersions now also contains libpq which doesn't have a pkgs attribute. Can file a PR in a minute.

@Ma27 Ma27 mentioned this pull request Jan 20, 2025
13 tasks
Ma27 added a commit to Ma27/nixpkgs that referenced this pull request Jan 20, 2025
The `libpq` attribute from `postgresqlVersions` doesn't have a `pkgs`
attribute with extensions in it. Filtering for postgresql server
packages only fixes the problem.

Reported in NixOS#359659 (comment)
@trofi
Copy link
Contributor

trofi commented Jan 20, 2025

Another eval failure is pgjwt.tests in staging, I think it's a different place from the previous one:

$ nix build --no-link -f. pgjwt.tests
error:
       … while evaluating the attribute 'pgjwt'
         at pkgs/servers/sql/postgresql/ext/pgjwt.nix:26:5:
           25|   passthru.tests = lib.recurseIntoAttrs {
           26|     pgjwt = nixosTests.postgresql.pgjwt.passthru.override postgresql;
             |     ^
           27|

       … while evaluating a branch condition
         at nixos/tests/all-tests.nix:21:5:
           20|   discoverTests = val:
           21|     if isAttrs val
             |     ^
           22|     then

       (stack trace truncated; use '--show-trace' to show the full, detailed trace)

       error: attribute 'pkgs' missing
       at nixos/tests/postgresql/pgjwt.nix:53:29:
           52|   lib.concatMapAttrs (n: p: { ${n} = makeTestFor p; }) (
           53|     lib.filterAttrs (_: p: !p.pkgs.pgjwt.meta.broken) pkgs.postgresqlVersions
             |                             ^
           54|   )
       Did you mean args?

@wolfgangwalther
Copy link
Contributor Author

All of the postgresql nixos tests have the same pattern and should be fixed in #375292. Just merged that - can you check again?

@trofi
Copy link
Contributor

trofi commented Jan 21, 2025

Yeah, it's all fixed now. I probably picked a patch too early before it was applied to all places. Thank you!

@wolfgangwalther wolfgangwalther mentioned this pull request Feb 9, 2025
4 tasks
@sternenseemann
Copy link
Member

I have a downstream package (code) that uses crate2nix and libpq now failing during linking:

building '/nix/store/kz7b55mbdb33xvs1c8a3mrlin85hvz14-rust_paroxysm-0.1.0.drv'...
Running phase: unpackPhase
unpacking source archive /nix/store/q2g3840yly9kphv027d13mjdb6r91dwr-source
source root is source
Running phase: patchPhase
Running phase: updateAutotoolsGnuConfigScriptsPhase
Running phase: configurePhase
Running cd .
Running phase: buildPhase
Building paroxysm (src/main.rs)
Running rustc --crate-name paroxysm src/main.rs --crate-type bin -C opt-level=3 -C codegen-units=1 --remap-path-prefix=/build=/ --extern chrono=/nix/store/04zd7
sgmyqnp9cwzs5vzfgflqik1wkw9-rust_chrono-0.4.35-lib/lib/libchrono-9589492a42.rlib --extern config=/nix/store/p260c6wr1vhvnan22z3finifkgqbh37g-rust_config-0.9.3-l
ib/lib/libconfig-dc5b9dc33b.rlib --extern crimp=/nix/store/vh8zpmqmiri55akfjch4b2a15fijnn20-rust_crimp-4087.0.0-lib/lib/libcrimp-2e1b79220c.rlib --extern diesel
=/nix/store/im891dqq35h901yns6aksw32kcjalzb1-rust_diesel-1.4.8-lib/lib/libdiesel-d6db9037dc.rlib --extern env_logger=/nix/store/6w6gb1xw3jc77izb668y0b164pyica8n
-rust_env_logger-0.7.1-lib/lib/libenv_logger-11265d4397.rlib --extern failure=/nix/store/mqwh3wmqzibxn45i8wx3rrnd35ccfc7q-rust_failure-0.1.8-lib/lib/libfailure-
97a128d383.rlib --extern irc=/nix/store/yavyq3h2g2hvn7w2ybg49fv3xrzbzxd7-rust_irc-0.13.6-lib/lib/libirc-ac2556324d.rlib --extern lazy_static=/nix/store/mjq4zr7q
khfqkd3j90087wn12a98pp3k-rust_lazy_static-1.4.0-lib/lib/liblazy_static-7c83871282.rlib --extern log=/nix/store/7w7016wdbv5fhhzwapr93qnx0gwhqv52-rust_log-0.4.21-
lib/lib/liblog-e71958b098.rlib --extern rand=/nix/store/9vyb843ydg664jaakbr20glmqaaz310r-rust_rand-0.7.3-lib/lib/librand-e9431de555.rlib --extern regex=/nix/sto
re/a8fhkdd0nzrvnijyi3nz6qr62y2rm7hi-rust_regex-1.10.3-lib/lib/libregex-480d3157d3.rlib --extern serde=/nix/store/lqzml0lynx7jgw4skz24hsicyvmd6vcs-rust_serde-1.0
.197-lib/lib/libserde-e91c5e9a2a.rlib --cfg feature="default" --edition 2018 -C linker=/nix/store/4ijy8jbsiqmj37avrk83gn2m903486mr-gcc-wrapper-14-20241116/bin/c
c --out-dir target/bin -L dependency=target/deps -L native=/nix/store/97j7bkcdbjl2fa3k1ngydkzln6m62kj8-libpq-17.2-dev/lib -L native=/nix/store/a6lkdradawy6ybr5k
v9lh5x5rwa2aa30-curl-8.11.1/lib -L native=/nix/store/f1nih7ybzfmpgspzp6ixfh9vibdbkygh-openssl-3.3.2/lib -L native=/nix/store/jb442jir0a2x7zsk0d63xb6rh8p280ai-zl
ib-1.3.1/lib -L/nix/store/jb442jir0a2x7zsk0d63xb6rh8p280ai-zlib-1.3.1/lib --cap-lints allow -L native=/nix/store/97j7bkcdbjl2fa3k1ngydkzln6m62kj8-libpq-17.2-dev
/lib -L native=/nix/store/a6lkdradawy6ybr5kv9lh5x5rwa2aa30-curl-8.11.1/lib -L native=/nix/store/f1nih7ybzfmpgspzp6ixfh9vibdbkygh-openssl-3.3.2/lib -L native=/ni
x/store/jb442jir0a2x7zsk0d63xb6rh8p280ai-zlib-1.3.1/lib -L/nix/store/jb442jir0a2x7zsk0d63xb6rh8p280ai-zlib-1.3.1/lib --color always
error: linking with `/nix/store/4ijy8jbsiqmj37avrk83gn2m903486mr-gcc-wrapper-14-20241116/bin/cc` failed: exit status: 1
  |
  = note: LC_ALL="C" PATH="/nix/store/4i3a50ysjh079pxbpbnx9cg766sw1fr6-rustc-1.84.0/lib/rustlib/x86_64-unknown-linux-gnu/bin:/nix/store/4ijy8jbsiqmj37avrk83gn2m
903486mr-gcc-wrapper-14-20241116/bin:/nix/store/zs2gq6fkglrd28g1nxlb8waqq37cdc2z-gcc-14-20241116/bin:/nix/store/9lcg6rsqbmx6s35jzy86b86pkj0qhxjl-glibc-2.40-66-b
in/bin:/nix/store/wdap4cr3bnm685f27y9bb6q5b6q18msl-coreutils-9.5/bin:/nix/store/vrkxj51s4a1awh7m4p4f1w29wad5s20m-binutils-wrapper-2.43.1/bin:/nix/store/5h5ghy2q
f6l91l52j6m5vx473zi38vc3-binutils-2.43.1/bin:/nix/store/fyh0f9vqkdgifgi8n1zw5lm0z4iqlw6w-rustc-wrapper-1.84.0/bin:/nix/store/q01clim33r4zdcmmdymmzz6icalpx00s-ca
rgo-1.84.0/bin:/nix/store/n4xfh00cw7vnwnrlx9asp545z82pazgc-jq-1.7.1-bin/bin:/nix/store/f04zhapn8n8w6yrd35s8sd9qmjp8g9ry-patchelf-0.15.0/bin:/nix/store/wdap4cr3b
nm685f27y9bb6q5b6q18msl-coreutils-9.5/bin:/nix/store/032xw8dchwjipwqh6b3h70yc3mcmsqld-findutils-4.10.0/bin:/nix/store/dd7xqz1qwl0di4zb8rzj7r1ds8np9xqs-diffutils
-3.10/bin:/nix/store/bffnm1211li6y431irplzbjbccr0k884-gnused-4.9/bin:/nix/store/4lbfasv335vpk8rbcf3pgkag4rhg8jx8-gnugrep-3.11/bin:/nix/store/xpzl2sf58fqfpl64b1f
y1ihxay7k71li-gawk-5.3.1/bin:/nix/store/zlmk040fc3jax9s3gldwp5rfwc1hhajc-gnutar-1.35/bin:/nix/store/chwdy9qaxd13q8zvl0zd5r7ql2q116di-gzip-1.13/bin:/nix/store/hp
ppxlcfvjzrvvcvhcm47divp65gbwq1-bzip2-1.0.8-bin/bin:/nix/store/y0akgyz13jgxwm968bs8kay47zbxx638-gnumake-4.4.1/bin:/nix/store/fd118hwh7d1ncib4mdw56ylv3g9k0iyj-bas
h-5.2p37/bin:/nix/store/apqwjgbjj646wk2jkzr67l26djamn481-patch-2.7.6/bin:/nix/store/rrv4bd5i7rp2m7j8ix4kl8bzijhh8gd3-xz-5.6.3-bin/bin:/nix/store/qraqns84wjffzd8
d3dgbdcyxg41czbd6-file-5.46/bin" VSLANG="1033" "/nix/store/4ijy8jbsiqmj37avrk83gn2m903486mr-gcc-wrapper-14-20241116/bin/cc" "-m64" "/build/rustcdYvN1V/symbols.o
" "target/bin/paroxysm.paroxysm.db42c08d512cbd6b-cgu.0.rcgu.o" "target/bin/paroxysm.dr3hrvfnfyxg3o5w7sm1ydojl.rcgu.o" "-Wl,--as-needed" "-Wl,-Bstatic" "/nix/sto
re/6w6gb1xw3jc77izb668y0b164pyica8n-rust_env_logger-0.7.1-lib/lib/libenv_logger-11265d4397.rlib" "/nix/store/9jr4q7kg172lpbgqnqasr7v5qljzl5dv-rust_termcolor-1.4
.1-lib/lib/libtermcolor-00e0565947.rlib" "/nix/store/mkiwwpqa9d7xlz0lrzij8dyjnjknnf0f-rust_atty-0.2.14-lib/lib/libatty-48c3a74b5b.rlib" "/nix/store/gzinhrwkd13b
a8xx08bgi4hps7liaks1-rust_humantime-1.3.0-lib/lib/libhumantime-5f7828f287.rlib" "/nix/store/h8kgdkp9g84v09cmf79abr98bf5f8kyx-rust_quick-error-1.2.3-lib/lib/libq
uick_error-ffdfee4a87.rlib" "/nix/store/p260c6wr1vhvnan22z3finifkgqbh37g-rust_config-0.9.3-lib/lib/libconfig-dc5b9dc33b.rlib" "/nix/store/2c4824w9ysv33hn9gz87s3
bg6j49bccj-rust_rust-ini-0.13.0-lib/lib/libini-8fea8ed2a5.rlib" "/nix/store/rl494iy7m5gg5mazll420ph70x38m33w-rust_serde-hjson-0.8.2-lib/lib/libserde_hjson-94c3f
c6d3a.rlib" "/nix/store/27b48ww6p60316c8d31sfkb2dd5ikvz8-rust_num-traits-0.1.43-lib/lib/libnum_traits-48439615b5.rlib" "/nix/store/l8afd5qv0kclqb4m1gkphgdy2l5cb
g4s-rust_linked-hash-map-0.3.0-lib/lib/liblinked_hash_map-969422d237.rlib" "/nix/store/9nxair4gvns0vnxy4iz56mp0sxcmhc8i-rust_serde-0.8.23-lib/lib/libserde-6e2d4
80915.rlib" "/nix/store/9csn8zqjs75ic8fkf6w655iyy6qi4589-rust_lazy_static-0.2.11-lib/lib/liblazy_static-f7e12f94ae.rlib" "/nix/store/07689q2q401x2h4r3l9fs68anrn
d5vwq-rust_yaml-rust-0.4.5-lib/lib/libyaml_rust-ac6d6f7b49.rlib" "/nix/store/v0zhhr7cy2jvrg8zjj7rmdfj3lsfx0ys-rust_linked-hash-map-0.5.6-lib/lib/liblinked_hash_
map-ca7ec96bbe.rlib" "/nix/store/j1lfd9fm8wh0dj5l7a0gbisgqalsz196-rust_nom-4.2.3-lib/lib/libnom-869bc0162c.rlib" "/nix/store/vh8zpmqmiri55akfjch4b2a15fijnn20-ru
st_crimp-4087.0.0-lib/lib/libcrimp-2e1b79220c.rlib" "/nix/store/9ijwiqmz6rrd5cyimrpdh2x9w76lbzam-rust_serde_json-1.0.114-lib/lib/libserde_json-79d2bea86c.rlib"
"/nix/store/yfzrkfq7a4y25lks09jkr7gbkq94ld99-rust_itoa-1.0.10-lib/lib/libitoa-8d48f9d794.rlib" "/nix/store/4impl508ig2akg5ayvjzrbphvc9zmky3-rust_ryu-1.0.17-lib/
lib/libryu-e0b68ccf3d.rlib" "/nix/store/lln8917ab6v8q5g0pa3zcvrhb3cq1kc7-rust_curl-0.4.46-lib/lib/libcurl-e74587fd70.rlib" "/nix/store/aq7ynpaghwkhzmh6ykg6qjmxn
z7c7nya-rust_socket2-0.5.6-lib/lib/libsocket2-0b262066ba.rlib" "/nix/store/y0xh58rhq8v8qr7dk8czzcr2lrm65hj0-rust_curl-sys-0.4.72+curl-8.6.0-lib/lib/libcurl_sys-
c603b1f400.rlib" "/nix/store/a8fhkdd0nzrvnijyi3nz6qr62y2rm7hi-rust_regex-1.10.3-lib/lib/libregex-480d3157d3.rlib" "/nix/store/27alr5h5h84dfqnp2a5kadkvyf7fdkqp-r
ust_regex-automata-0.4.6-lib/lib/libregex_automata-74ec3d3cc2.rlib" "/nix/store/6nvl0zsbj9fljals7qvddr8wp6q77v0m-rust_aho-corasick-1.1.2-lib/lib/libaho_corasick
-e2db09bd01.rlib" "/nix/store/d1x0qw3z9k9kpq8inxh75c45c41a7gpj-rust_regex-syntax-0.8.2-lib/lib/libregex_syntax-598e1e8b2d.rlib" "/nix/store/9vyb843ydg664jaakbr2
0glmqaaz310r-rust_rand-0.7.3-lib/lib/librand-e9431de555.rlib" "/nix/store/jx2qwax4bc9cqg2pn9z5bh369pa5k0ld-rust_rand_chacha-0.2.2-lib/lib/librand_chacha-a2c5b32
f32.rlib" "/nix/store/iky184vfxppqhxs2rwyl62z5c2xac9m9-rust_ppv-lite86-0.2.17-lib/lib/libppv_lite86-81a59b0d45.rlib" "/nix/store/c03bk7lgszk5zfb9s6p5xw74hs68r8c
z-rust_rand_core-0.5.1-lib/lib/librand_core-c57651faac.rlib" "/nix/store/fh038i4cihljraqmz9snqcia20s6jw8k-rust_getrandom-0.1.16-lib/lib/libgetrandom-cf6e9fe81f.
rlib" "/nix/store/yavyq3h2g2hvn7w2ybg49fv3xrzbzxd7-rust_irc-0.13.6-lib/lib/libirc-ac2556324d.rlib" "/nix/store/83gxp4ynh840xfdjh9gs4pa0xnqjzrci-rust_toml-0.4.10
-lib/lib/libtoml-2d27bc35a9.rlib" "/nix/store/w0a086p0fm5bs0d65f937467ms7mcazr-rust_tokio-tls-0.2.1-lib/lib/libtokio_tls-43c0385d87.rlib" "/nix/store/420d5f7xfa
4a0cx1wyllv98q2v79gj2s-rust_tokio-timer-0.1.2-lib/lib/libtokio_timer-16770ca55c.rlib" "/nix/store/668ll1cbf6wsqji28wvk6rjplx7wr9bb-rust_slab-0.3.0-lib/lib/libsl
ab-f5086ba657.rlib" "/nix/store/2khrnqk662q7jfalzxfinb2bgdyp6sq4-rust_tokio-mockstream-1.1.0-lib/lib/libtokio_mockstream-f18ae024ed.rlib" "/nix/store/d7cxfvm8rf
vn4p433y5xzlmqawyc95i5-rust_tokio-core-0.1.18-lib/lib/libtokio_core-bc6a8bfac5.rlib" "/nix/store/6rgkyvb0dpzgb62dbdgjl9pxf83i9iqy-rust_scoped-tls-0.1.2-lib/lib/
libscoped_tls-dc787c4148.rlib" "/nix/store/qiz16y9jba8l7xj3yffl0mg8jgwngnhv-rust_tokio-0.1.22-lib/lib/libtokio-002556c734.rlib" "/nix/store/c715ayjy0g9r25ab28jg
lzgpkn0n56p4-rust_tokio-uds-0.2.7-lib/lib/libtokio_uds-ac4b4f5ee0.rlib" "/nix/store/zbpjvj3jwll5n3qajizavhsa827g2jqy-rust_mio-uds-0.6.8-lib/lib/libmio_uds-a4902
f6106.rlib" "/nix/store/4lj6rkm80lcwb0zjsc67il5r8jgqvxdv-rust_tokio-udp-0.1.6-lib/lib/libtokio_udp-349daf1df9.rlib" "/nix/store/gs0nbpa0h7fpqwxdxm2rldni526iyp0i
-rust_tokio-timer-0.2.13-lib/lib/libtokio_timer-7976686a40.rlib" "/nix/store/bv92rzg4svdagg0gwa8jvi5bli229ca3-rust_tokio-tcp-0.1.4-lib/lib/libtokio_tcp-eddafe95
2b.rlib" "/nix/store/ffixsgpidbg4j5vcj9v6v6s8hp3572wf-rust_tokio-reactor-0.1.12-lib/lib/libtokio_reactor-970cecf940.rlib" "/nix/store/448019bga44yh65hxwz86jzl4j
wx61hx-rust_tokio-sync-0.1.8-lib/lib/libtokio_sync-6847dd2fe1.rlib" "/nix/store/p503frh241nzsy9y4v9rq5ppkb5rz2rh-rust_fnv-1.0.7-lib/lib/libfnv-6b7bc73616.rlib"
"/nix/store/i3yvyh9alxgm39xlszga5gj8j9c2iahr-rust_parking_lot-0.9.0-lib/lib/libparking_lot-60a6e90df4.rlib" "/nix/store/0vg359ckfwj3c6gjd9gll0cfvzkrna3r-rust_pa
rking_lot_core-0.6.3-lib/lib/libparking_lot_core-139eeb1d94.rlib" "/nix/store/f59pagrsx8ix6p99ar0cdd41qicvfpvm-rust_smallvec-0.6.14-lib/lib/libsmallvec-126702eb
4f.rlib" "/nix/store/gkd8676kp2cm64nlzjh7mbdqqmr1kr6x-rust_lock_api-0.3.4-lib/lib/liblock_api-8015225b89.rlib" "/nix/store/vs2gadpzdazjp0lx1jqzci3sia3r9q7y-rust
_tokio-fs-0.1.7-lib/lib/libtokio_fs-7341eb33d5.rlib" "/nix/store/cxlzp1bcyaq7656l06drldssa5il9bxz-rust_tokio-threadpool-0.1.18-lib/lib/libtokio_threadpool-f4072
21b8c.rlib" "/nix/store/svl9y4b268x8fsw1gllrr75ykg8p8y4x-rust_crossbeam-queue-0.2.3-lib/lib/libcrossbeam_queue-8e9a812b3c.rlib" "/nix/store/zwkih5xi4pjzn90sxmyj
0jvc52ic167v-rust_crossbeam-deque-0.7.4-lib/lib/libcrossbeam_deque-65a9b0082f.rlib" "/nix/store/cjhn5ra8mffs5g33vk1a3hvwg3l16qpl-rust_crossbeam-epoch-0.8.2-lib/
lib/libcrossbeam_epoch-91c7a7115c.rlib" "/nix/store/lx4q0i3nbnnw3xggbf94nw9g0a9rm4bj-rust_memoffset-0.5.6-lib/lib/libmemoffset-4b0cae7adf.rlib" "/nix/store/qsh3
ipsihd3v2iwagw54wv6s6dch20r5-rust_maybe-uninit-2.0.0-lib/lib/libmaybe_uninit-8c50512844.rlib" "/nix/store/ix10mwjriw7pkxk6v8cii218qwnqvcmi-rust_tokio-current-th
read-0.1.7-lib/lib/libtokio_current_thread-cbe48e7106.rlib" "/nix/store/534iw6qdpgibwj09wxi4wki0z6hp56h1-rust_tokio-executor-0.1.10-lib/lib/libtokio_executor-5d
ba00f3d2.rlib" "/nix/store/8vhg0dnai1rpp1v3jdw56lr3ar2xgank-rust_crossbeam-utils-0.7.2-lib/lib/libcrossbeam_utils-9c0a2a56d5.rlib" "/nix/store/mjq4zr7qkhfqkd3j9
0087wn12a98pp3k-rust_lazy_static-1.4.0-lib/lib/liblazy_static-7c83871282.rlib" "/nix/store/7nzvx9qd84rxr7nk32r2a8mppm7i8g3f-rust_num_cpus-1.16.0-lib/lib/libnum_
cpus-251b492d72.rlib" "/nix/store/2i5bqcq065hvvh0pbjlnfzyiwxg3a6fx-rust_mio-0.6.23-lib/lib/libmio-3c33f395d1.rlib" "/nix/store/hzh3ygjxak7pac0pj169pgdv2znws0k8-
rust_slab-0.4.9-lib/lib/libslab-239d126dd8.rlib" "/nix/store/mh1r0zic75mkzssxdj1cwdyz8v74sxmn-rust_net2-0.2.39-lib/lib/libnet2-4699178510.rlib" "/nix/store/m4sy
kgv5x5vc9c1mg31vxb4rs3pg8p9v-rust_cfg-if-0.1.10-lib/lib/libcfg_if-fcffd837e5.rlib" "/nix/store/gbxslrc71lv4y9rvcp3ixih6y2mpb71s-rust_tokio-codec-0.1.2-lib/lib/l
ibtokio_codec-5245b92a42.rlib" "/nix/store/4q5lw8wgc2i7ysac7g1sr6xf5zl191gz-rust_tokio-io-0.1.13-lib/lib/libtokio_io-b6fea0d4fc.rlib" "/nix/store/lqzml0lynx7jgw
4skz24hsicyvmd6vcs-rust_serde-1.0.197-lib/lib/libserde-e91c5e9a2a.rlib" "/nix/store/45yz54swysp5dfp6d3vsyd18nb1635ff-rust_native-tls-0.2.11-lib/lib/libnative_tl
s-4e98fe8fb2.rlib" "/nix/store/7saxckmqj0wqivp3sc1aiahh4vis5rj6-rust_openssl-probe-0.1.5-lib/lib/libopenssl_probe-1c527733a4.rlib" "/nix/store/4jgfi8f55dw5xp5yd
27hy5cc157x9fjg-rust_openssl-0.10.64-lib/lib/libopenssl-f5c8d6669b.rlib" "/nix/store/ck6mcm74hadw5chjjv1xjbbf4rzla64g-rust_once_cell-1.19.0-lib/lib/libonce_cell
-9e199ec48e.rlib" "/nix/store/an8rfc9yqrzjm6gzjqb86y3xnvh8dgsv-rust_bitflags-2.4.2-lib/lib/libbitflags-c640aaf3a6.rlib" "/nix/store/p1lxh8jxiz8ycp0z95qci5x4qda0
8wcj-rust_foreign-types-0.3.2-lib/lib/libforeign_types-f7ff1020cb.rlib" "/nix/store/nh401hplm5bbgygr8s6v02grvpd2pxwz-rust_foreign-types-shared-0.1.1-lib/lib/lib
foreign_types_shared-b973a19705.rlib" "/nix/store/dnjrzjys0mjlyklwxsw6pn7qlxp1kaa7-rust_openssl-sys-0.9.101-lib/lib/libopenssl_sys-d30d32e07f.rlib" "/nix/store/
8dk7mqx27ydwd2i2rbf4dgr4c37bqcr5-rust_futures-0.1.31-lib/lib/libfutures-eb4173aa09.rlib" "/nix/store/jhssyz2cc24xlpn3c3yisqi0apwkdy1k-rust_encoding-0.2.33-lib/l
ib/libencoding-c3eb5b03c3.rlib" "/nix/store/rl1kk8jkssrwaanb1h0x0vv13b9akx9p-rust_encoding-index-tradchinese-1.20141219.5-lib/lib/libencoding_index_tradchinese-
d18ad03028.rlib" "/nix/store/yx5nf8y9rfm6kaqp6g8jl9v681mfr3ya-rust_encoding-index-simpchinese-1.20141219.5-lib/lib/libencoding_index_simpchinese-bc415b7674.rlib
" "/nix/store/lx0zq9dmbw2icjx4gha9kwr3222zfc7n-rust_encoding-index-japanese-1.20141219.5-lib/lib/libencoding_index_japanese-ec12a0973d.rlib" "/nix/store/bn6xgz7
jc2crvgnks8c7xsa90cbpfd05-rust_encoding-index-korean-1.20141219.5-lib/lib/libencoding_index_korean-666e20f655.rlib" "/nix/store/v3zsa8kc55vcdb35180v3sxacx8sr81q
-rust_encoding-index-singlebyte-1.20141219.5-lib/lib/libencoding_index_singlebyte-bd77572b77.rlib" "/nix/store/1ncb031gspncfa5cy48445aqnp5m271k-rust_bytes-0.4.1
2-lib/lib/libbytes-2b207be983.rlib" "/nix/store/cp4hlfyv71aqjj1fwi2acjxrxcjd1wvc-rust_iovec-0.1.4-lib/lib/libiovec-82443d4f7a.rlib" "/nix/store/97f468048zng7gz5
ll42rn0vihbkp1vz-rust_bufstream-0.1.4-lib/lib/libbufstream-74a67935ba.rlib" "/nix/store/mqwh3wmqzibxn45i8wx3rrnd35ccfc7q-rust_failure-0.1.8-lib/lib/libfailure-9
7a128d383.rlib" "/nix/store/gly6crij8g7sfyn2l22dxlgg7rgpsjhf-rust_backtrace-0.3.69-lib/lib/libbacktrace-1c723cff08.rlib" "/nix/store/h59wrs46c5523njyvzrv5q5kc5y
3ppsc-rust_miniz_oxide-0.7.2-lib/lib/libminiz_oxide-f100d95b29.rlib" "/nix/store/aqihy6f4xkpc4lcw5g4h3yj6qfsk46va-rust_adler-1.0.2-lib/lib/libadler-6d4c8b1470.r
lib" "/nix/store/540aiybpf1im1g56wznf1kh32lr7v6ka-rust_object-0.32.2-lib/lib/libobject-1eb7537e2a.rlib" "/nix/store/r0vyh083pbm131g853fkh0bd22b800zd-rust_memchr
-2.7.1-lib/lib/libmemchr-2e9dc17489.rlib" "/nix/store/4lbnsrdvcfy75x4cwlhhyz5v3v3z2zcl-rust_addr2line-0.21.0-lib/lib/libaddr2line-e1dba7b8ea.rlib" "/nix/store/f
x99izmb2dkwg2gvska92zwdmdx9zs04-rust_gimli-0.28.1-lib/lib/libgimli-14423a5efe.rlib" "/nix/store/cmi5xc0050sr778ws0h1417kxs3l0p15-rust_rustc-demangle-0.1.23-lib/
lib/librustc_demangle-edebd6df1f.rlib" "/nix/store/im891dqq35h901yns6aksw32kcjalzb1-rust_diesel-1.4.8-lib/lib/libdiesel-d6db9037dc.rlib" "/nix/store/skl3nj2b1yd
lsjpsljcccdfn43ff86sa-rust_pq-sys-0.4.8-lib/lib/libpq_sys-b791313bfc.rlib" "/nix/store/04zd7sgmyqnp9cwzs5vzfgflqik1wkw9-rust_chrono-0.4.35-lib/lib/libchrono-958
9492a42.rlib" "/nix/store/qi8n4dddjij6ri03ii6lfqllnxfjxd5c-rust_num-traits-0.2.18-lib/lib/libnum_traits-05b262dbb0.rlib" "/nix/store/s4zzvh40m6nhbf6xjbpsja6cn4c
np4f3-rust_iana-time-zone-0.1.60-lib/lib/libiana_time_zone-85678b454e.rlib" "/nix/store/98dhrfvhyhw1s20lnx6xmg3rwp5cf8r8-rust_r2d2-0.8.10-lib/lib/libr2d2-7430a6
d69a.rlib" "/nix/store/0jqmhinjc1f3kssw9hrngcpfdfrpq76w-rust_scheduled-thread-pool-0.2.7-lib/lib/libscheduled_thread_pool-630468dd23.rlib" "/nix/store/s6ccjijf9
isabqdkqag2bvvmjxc9vdsz-rust_parking_lot-0.12.1-lib/lib/libparking_lot-dcf7704c56.rlib" "/nix/store/lwjg3l3wnry5ps0v8llkjfz4da0wnzl9-rust_parking_lot_core-0.9.9
-lib/lib/libparking_lot_core-b893f687ea.rlib" "/nix/store/q4xv5pmmlns66nyisv1nq4jirw04vg2r-rust_libc-0.2.153-lib/lib/liblibc-084418a33c.rlib" "/nix/store/38r3ig
mwmg2apcdr68jhyi64z2m3sl8j-rust_cfg-if-1.0.0-lib/lib/libcfg_if-11ac80c792.rlib" "/nix/store/2garkqxk5bfgcw7f6yh1wbjdz9yfxc20-rust_smallvec-1.13.1-lib/lib/libsma
llvec-1494d69910.rlib" "/nix/store/w6g5mgwzp6lh7cnvskzv072111nafm15-rust_lock_api-0.4.11-lib/lib/liblock_api-b33d1a965f.rlib" "/nix/store/azpgmvxzdzxm93kgnk4q24
kz18c7jf1b-rust_scopeguard-1.2.0-lib/lib/libscopeguard-7f36677088.rlib" "/nix/store/7w7016wdbv5fhhzwapr93qnx0gwhqv52-rust_log-0.4.21-lib/lib/liblog-e71958b098.r
lib" "/nix/store/flsr0rhh3zlnbp0ndpjf0y055y8v7wcm-rust_byteorder-1.5.0-lib/lib/libbyteorder-9b785da185.rlib" "/nix/store/gwz0d4ih7wkxnz6c7n3x3rgrc2amh8np-rust_b
itflags-1.3.2-lib/lib/libbitflags-25edeaf30b.rlib" "/nix/store/4i3a50ysjh079pxbpbnx9cg766sw1fr6-rustc-1.84.0/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-196
dff1c3efa0a58.rlib" "/nix/store/4i3a50ysjh079pxbpbnx9cg766sw1fr6-rustc-1.84.0/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-b3d8d7b28a5d013e.rlib" "/
nix/store/4i3a50ysjh079pxbpbnx9cg766sw1fr6-rustc-1.84.0/lib/rustlib/x86_64-unknown-linux-gnu/lib/libobject-bf436ce5d4c97b2f.rlib" "/nix/store/4i3a50ysjh079pxbpb
nx9cg766sw1fr6-rustc-1.84.0/lib/rustlib/x86_64-unknown-linux-gnu/lib/libmemchr-5de322c2eca6ca70.rlib" "/nix/store/4i3a50ysjh079pxbpbnx9cg766sw1fr6-rustc-1.84.0/
lib/rustlib/x86_64-unknown-linux-gnu/lib/libaddr2line-49faebb0499e8d70.rlib" "/nix/store/4i3a50ysjh079pxbpbnx9cg766sw1fr6-rustc-1.84.0/lib/rustlib/x86_64-unknow
n-linux-gnu/lib/libgimli-50f1b4a279c70aea.rlib" "/nix/store/4i3a50ysjh079pxbpbnx9cg766sw1fr6-rustc-1.84.0/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_dema
ngle-6bc72d4f2a3739c6.rlib" "/nix/store/4i3a50ysjh079pxbpbnx9cg766sw1fr6-rustc-1.84.0/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd_detect-58fb8ef72b214fa1.rl
ib" "/nix/store/4i3a50ysjh079pxbpbnx9cg766sw1fr6-rustc-1.84.0/lib/rustlib/x86_64-unknown-linux-gnu/lib/libhashbrown-745f4cc6aaa79b79.rlib" "/nix/store/4i3a50ysj
h079pxbpbnx9cg766sw1fr6-rustc-1.84.0/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_alloc-421642c7d95e73b4.rlib" "/nix/store/4i3a50ysjh079pxbpb
nx9cg766sw1fr6-rustc-1.84.0/lib/rustlib/x86_64-unknown-linux-gnu/lib/libminiz_oxide-f33d165bc6f3f3fd.rlib" "/nix/store/4i3a50ysjh079pxbpbnx9cg766sw1fr6-rustc-1.
84.0/lib/rustlib/x86_64-unknown-linux-gnu/lib/libadler-f5f122938b1e62d0.rlib" "/nix/store/4i3a50ysjh079pxbpbnx9cg766sw1fr6-rustc-1.84.0/lib/rustlib/x86_64-unkno
wn-linux-gnu/lib/libunwind-44ac131d22602259.rlib" "/nix/store/4i3a50ysjh079pxbpbnx9cg766sw1fr6-rustc-1.84.0/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcfg_if-a
59f73db020e6d43.rlib" "/nix/store/4i3a50ysjh079pxbpbnx9cg766sw1fr6-rustc-1.84.0/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-24e2f7d7aab1bbe4.rlib" "/nix/st
ore/4i3a50ysjh079pxbpbnx9cg766sw1fr6-rustc-1.84.0/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-d643836b32ccf059.rlib" "/nix/store/4i3a50ysjh079pxbpbnx9cg76
6sw1fr6-rustc-1.84.0/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_core-ea0b03a475af528a.rlib" "/nix/store/4i3a50ysjh079pxbpbnx9cg766sw1fr6-ru
stc-1.84.0/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-2d15e7de1cd31991.rlib" "/nix/store/4i3a50ysjh079pxbpbnx9cg766sw1fr6-rustc-1.84.0/lib/rustlib/x86_64-
unknown-linux-gnu/lib/libcompiler_builtins-16843be116483ece.rlib" "-Wl,-Bdynamic" "-lcurl" "-lssl" "-lcrypto" "-lpq" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm"
 "-ldl" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "/nix/store/97j7bkcdbjl2fa3k1ngydkzln6m62kj8-libpq-17.2-dev/lib" "-L" "/nix/store/a6lkdradawy6ybr5k
v9lh5x5rwa2aa30-curl-8.11.1/lib" "-L" "/nix/store/f1nih7ybzfmpgspzp6ixfh9vibdbkygh-openssl-3.3.2/lib" "-L" "/nix/store/jb442jir0a2x7zsk0d63xb6rh8p280ai-zlib-1.3
.1/lib" "-L" "/nix/store/jb442jir0a2x7zsk0d63xb6rh8p280ai-zlib-1.3.1/lib" "-L" "/nix/store/97j7bkcdbjl2fa3k1ngydkzln6m62kj8-libpq-17.2-dev/lib" "-L" "/nix/store
/a6lkdradawy6ybr5kv9lh5x5rwa2aa30-curl-8.11.1/lib" "-L" "/nix/store/f1nih7ybzfmpgspzp6ixfh9vibdbkygh-openssl-3.3.2/lib" "-L" "/nix/store/jb442jir0a2x7zsk0d63xb6
rh8p280ai-zlib-1.3.1/lib" "-L" "/nix/store/jb442jir0a2x7zsk0d63xb6rh8p280ai-zlib-1.3.1/lib" "-L" "/nix/store/4i3a50ysjh079pxbpbnx9cg766sw1fr6-rustc-1.84.0/lib/r
ustlib/x86_64-unknown-linux-gnu/lib" "-o" "target/bin/paroxysm" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-Wl,-O1" "-nodefaultlibs"
  = note: /nix/store/5h5ghy2qf6l91l52j6m5vx473zi38vc3-binutils-2.43.1/bin/ld: cannot find -lpq: No such file or directory
          collect2: error: ld returned 1 exit status
error: aborting due to 1 previous error
builder for '/nix/store/kz7b55mbdb33xvs1c8a3mrlin85hvz14-rust_paroxysm-0.1.0.drv' failed with exit code 1

crate2nix output didn't have to change at all since it uses defaultCrateOverrides, so I suspect this may have something to do with this change. Things I noticed:

  • pq-sys crate builds fine.
  • The problem appears to be that it tries to link against libpq in its dev output which doesn't work. The .pc file correctly prescribes out as libdir, though.

@wolfgangwalther
Copy link
Contributor Author

Seems like the pg_config that libpq is shipping is returning this:

LIBDIR = /nix/store/97j7bkcdbjl2fa3k1ngydkzln6m62kj8-libpq-17.2-dev/lib

We'll essentially need the same as for postgresql's pg_config, where we do this: https://github.com/NixOS/nixpkgs/blob/master/pkgs/servers/sql/postgresql/pg_config.sh

I originally intended to not ship pg_config in libpq at all and rely entirely on pkg-config instead. But that didn't work out well, too many packages needed pg_config. Odd, that they still worked, given that it returns the wrong LIBDIR.

The .pc file correctly prescribes out as libdir, though.

Ultimately, this means that in your case pkg-config seems not to be used, but pg_config is.

I found https://github.com/sgrif/pq-sys?tab=readme-ov-file#building, which mentions that pg_config --libdir is used as the last place to look at, but that doesn't really explain why pq-sys builds fine for you. Or maybe it does?

@sternenseemann
Copy link
Member

that doesn't really explain why pq-sys builds fine for you

Well it does since the rust libs aren't dynamic, so they don't actually need to link the library against the system library. The pg-sys crate only stores link information for later which comes out wrong:

> cat /nix/store/skl3nj2b1ydlsjpsljcccdfn43ff86sa-rust_pq-sys-0.4.8-lib/lib/link 

-L native=/nix/store/97j7bkcdbjl2fa3k1ngydkzln6m62kj8-libpq-17.2-dev/lib

@wolfgangwalther
Copy link
Contributor Author

Ok. I'll prepare a PR to fix pg_config in libpq.

@sternenseemann
Copy link
Member

Ah, the problem is that the use of pkg-config is gated behind a cargo feature (because it uses the pkg_config crate) which is terrible for us since the user controls that via Cargo.lock, not us (i.e. I don't think we can force features on via crate overrides).

@sternenseemann
Copy link
Member

Another option would be to set one of the environment variables via defaultCrateOverrides.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: continuous integration Affects continuous integration (CI) in Nixpkgs, including Ofborg and GitHub Actions 6.topic: games Gaming on NixOS 6.topic: lua Lua is a powerful, efficient, lightweight, embeddable scripting language. 6.topic: ocaml OCaml is a general-purpose, high-level, multi-paradigm programming language. 6.topic: php PHP is a general-purpose scripting language geared towards web development. 6.topic: python Python is a high-level, general-purpose programming language. 6.topic: qt/kde Object-oriented framework for GUI creation 6.topic: ruby A dynamic, open source programming language with a focus on simplicity and productivity. 6.topic: rust General-purpose programming language emphasizing performance, type safety, and concurrency. 8.has: package (new) This PR adds a new package 10.rebuild-darwin: 1001-2500 This PR causes many rebuilds on Darwin and should most likely target the staging branches. 10.rebuild-linux: 2501-5000 This PR causes many rebuilds on Linux and should target the staging branches.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants