Skip to content

Commit 6a3c31f

Browse files
committed
nixpkgs: Update submodule to latest master
1 parent 7e1c5d4 commit 6a3c31f

File tree

3 files changed

+128
-11
lines changed

3 files changed

+128
-11
lines changed

nixpkgs

Submodule nixpkgs updated 5681 files

nixpkgs.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77
if builtins.pathExists ./nixpkgs/pkgs
88
then import ./nixpkgs {}
99
# Pinned nixpkgs version; should be kept up-to-date with our submodule.
10-
else import (fetchTarball https://github.com/nh2/nixpkgs/archive/a2d7e9b875e8ba7fd15b989cf2d80be4e183dc72.tar.gz) {}
10+
else import (fetchTarball https://github.com/nh2/nixpkgs/archive/4650168465cd411dcc4bd5096c1eba5f02981cc3.tar.gz) {}

survey/default.nix

Lines changed: 126 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,75 @@ let
445445
then static_package
446446
else throw "If you see this, nixpkgs #61682 has been fixed and ${name} should be overridden";
447447

448+
# Takes a zlib derivation and overrides it to have both .a and .so files.
449+
statify_zlib = zlib_drv:
450+
(zlib_drv.override {
451+
static = false;
452+
shared = true;
453+
}).overrideAttrs (old: { dontDisableStatic = true; });
454+
455+
# Takes a curl derivation and overrides it to have both .a and .so files,
456+
# and have the `curl` executable be statically linked.
457+
statify_curl_including_exe = curl_drv:
458+
(curl_drv.override (old: {
459+
# Disable gss support, because that requires `krb5`, which
460+
# (as mentioned in note [krb5 can only be static XOR shared]) is a
461+
# library that cannot build both .a and .so files in its build system.
462+
# That means that if we enable it, we can no longer build the
463+
# dynamically-linked `curl` binary from the overlay
464+
# `archiveFilesOverlay` below where `statify_curl_including_exe` is used.
465+
gssSupport = false;
466+
zlib = statify_zlib old.zlib;
467+
})).overrideAttrs (old: {
468+
dontDisableStatic = true;
469+
470+
# Additionally, flags to also build a static `curl` executable:
471+
472+
# Note: It is important that in the eventual `libtool` invocation,
473+
# `-all-static` comes before (or instead of) `-static`.
474+
# This is because the first of them "wins setting the mode".
475+
# See https://lists.gnu.org/archive/html/libtool/2006-12/msg00047.html
476+
# libtool makes various problems with static linking.
477+
# Some of them are is well-described by
478+
# https://github.com/sabotage-linux/sabotage/commit/57a989a2e23c9e46501da1227f371da59d212ae4
479+
# However, so far, `-all-static` seems to have the same effect
480+
# of convincing libtool to NOT drop the `-static` flag.
481+
# Other places where this was dicussed (in case you have to debug this in
482+
# the future) are:
483+
# https://debbugs.gnu.org/cgi/bugreport.cgi?bug=11064
484+
# https://github.com/esnet/iperf/issues/632
485+
# Another common thing that people do is to pass `-static --static`,
486+
# with the intent that `--static` isn't eaten by libtool but still
487+
# accepted by e.g. gcc. In our case as of writing (nixpkgs commit bc94dcf50),
488+
# this isn't enough. That is because:
489+
# * The `--with-*=/path` options given to curl's `./configure`
490+
# are usually `.lib` split outputs that contain only headers and
491+
# pkg-config `.pc` files. OK so far.
492+
# * For some of these, e.g. for libssh2, curl's `./configure` turns them
493+
# into `LDFLAGS=-L/...libssh2-dev/lib`, which doesn't do anything to
494+
# libtool, gcc or ld, because `*-dev/lib` contains only `lib/pkgconfig`
495+
# and no libraries.
496+
# * But for others, e.g. for libnghttp2, curl's `./configure` resolves
497+
# them by taking the actual `-L` flags out of the `.pc` file, and turns
498+
# them into e.g. `LDFLAGS=-L/...nghttp2-lib/lib`, which contains
499+
# `{ *.la, *.a, *.so }`.
500+
# * When libtool is invoked with such `LDFLAGS`, it adds two entries to
501+
# `./lib/libcurl.la`'s `dependency_libs=`: `-L/...nghttp2-lib/lib` and
502+
# `/...nghttp2-lib/lib/*.la`.
503+
# When the `.la` path is given, libtool will read it, and pass the
504+
# `.so` file referred to within as a positional argument to e.g. gcc,
505+
# even when linking statically, which will result in linker error
506+
# ld: attempted static link of dynamic object `/...-nghttp2-lib/lib/libnghttp2.so'
507+
# I believe this is what
508+
# https://github.com/sabotage-linux/sabotage/commit/57a989a2e23c9e46501da1227f371da59d212ae4
509+
# fixes.
510+
# If we pass `-all-static` to libtool, it won't do the things in the last
511+
# bullet point, causing static linking to succeed.
512+
makeFlags = [ "curl_LDFLAGS=-all-static" ];
513+
# TODO This will become unnecessary once https://github.com/NixOS/nixpkgs/pull/66490 is merged
514+
LDFLAGS = [ "-lz" ];
515+
});
516+
448517
# Overlay that enables `.a` files for as many system packages as possible.
449518
# This is in *addition* to `.so` files.
450519
# See also https://github.com/NixOS/nixpkgs/issues/61575
@@ -483,12 +552,18 @@ let
483552
patchelf_static = previous.patchelf.overrideAttrs (old: { dontDisableStatic = true; });
484553
pcre_static = previous.pcre.overrideAttrs (old: { dontDisableStatic = true; });
485554
xz_static = previous.xz.overrideAttrs (old: { dontDisableStatic = true; });
555+
# TODO All 3 zlibs below can be simplified/removed once https://github.com/NixOS/nixpkgs/pull/66490 is available
486556
zlib_static = (previous.zlib.override {
487557
static = true;
488558
shared = true;
489559
# If both `static` and `dynamic` are enabled, then the zlib package
490560
# puts the static libs into the `.static` split-output.
491561
}).static;
562+
zlib_static_only = (previous.zlib.override {
563+
static = true;
564+
shared = false;
565+
});
566+
zlib_both = statify_zlib previous.zlib;
492567
# Also override the original packages with a throw (which as of writing
493568
# has no effect) so we can know when the bug gets fixed in the future.
494569
acl = issue_61682_throw "acl" previous.acl;
@@ -555,20 +630,62 @@ let
555630

556631
openblas = previous.openblas.override { enableStatic = true; };
557632

633+
openssl = previous.openssl.override { static = true; };
634+
558635
krb5 = previous.krb5.override {
559-
# Note krb5 does not support building both static and shared at the same time.
636+
# Note [krb5 can only be static XOR shared]
637+
# krb5 does not support building both static and shared at the same time.
638+
# That means *anything* on top of this overlay trying to link krb5
639+
# dynamically from this overlay will fail with linker errors.
560640
staticOnly = true;
561641
};
562642

563-
openssl = previous.openssl.override { static = true; };
643+
# See comments on `statify_curl_including_exe` for the interaction with krb5!
644+
curl = statify_curl_including_exe previous.curl;
645+
646+
# TODO: All of this can be removed once https://github.com/NixOS/nixpkgs/pull/66506
647+
# is available.
648+
# Given that we override `krb5` (above) in this overlay so that it has
649+
# static libs only, the `curl` used by `fetchurl` (e.g. via `fetchpatch`,
650+
# which some packages may use) cannot be dynamically linked against it.
651+
# Note this `curl` via `fetchurl` is NOT EXACTLY the same curl as our `curl` above
652+
# in the overlay, but has a peculiarity:
653+
# It forces `gssSupport = true` on Linux, undoing us setting it to `false` above!
654+
# See https://github.com/NixOS/nixpkgs/blob/73493b2a2df75b487c6056e577b6cf3e6aa9fc91/pkgs/top-level/all-packages.nix#L295
655+
# So we have to turn it back off again here, *inside* `fetchurl`.
656+
# Because `fetchurl` is a form of boostrap package,
657+
# (which make ssense, as `curl`'s source code itself must be fetchurl'd),
658+
# we can't just `fetchurl.override { curl = the_curl_from_the_overlay_above; }`;
659+
# that would give an infinite evaluation loop.
660+
# Instead, we have override the `curl` *after* `all-packages.nix` has force-set
661+
# `gssSupport = false`.
662+
# Other alternatives are to just use a statically linked `curl` binary for
663+
# `fetchurl`, or to keep `gssSupport = true` and give it a `krb5` that has
664+
# static libs switched off again.
665+
#
666+
# Note: This needs the commit from https://github.com/NixOS/nixpkgs/pull/66503 to work,
667+
# which allows us to do `fetchurl.override`.
668+
fetchurl = previous.fetchurl.override (old: {
669+
curl =
670+
# We have the 3 choices mentioned above:
564671

565-
# Disable gss support, because that requires `krb5`,
566-
# which (as mentioned above) is a library that cannot build both
567-
# .a and .so files in its build system.
568-
# That means that if we enable it, we can no longer build the
569-
# dynamically-linked `curl` binary from this overlay.
570-
curl = (previous.curl.override { gssSupport = false; }).overrideAttrs (old: {
571-
dontDisableStatic = true;
672+
# 1) Turning `gssSupport` back off:
673+
674+
(old.curl.override { gssSupport = false; }).overrideAttrs (old: {
675+
makeFlags = builtins.filter (x: x != "curl_LDFLAGS=-all-static") (old.makeFlags or []);
676+
});
677+
678+
# 2) Static `curl` binary:
679+
680+
# statify_curl old.curl;
681+
682+
# 3) Non-statick krb5:
683+
684+
# (old.curl.override (old: {
685+
# libkrb5 = old.libkrb5.override { staticOnly = false; };
686+
# })).overrideAttrs (old: {
687+
# makeFlags = builtins.filter (x: x != "curl_LDFLAGS=-all-static") old.makeFlags;
688+
# });
572689
});
573690
};
574691

0 commit comments

Comments
 (0)