|
589 | 589 | ) |
590 | 590 | ]; |
591 | 591 |
|
| 592 | + |
| 593 | + # For static builds, all `buildInputs` should become `propagatedBuildInputs`. |
| 594 | + # This is because a final link will necessarily have access to all recursive |
| 595 | + # dependencies. |
| 596 | + # |
| 597 | + # (`pkgsStatic` does this too, as `makeStatic` in `adapters.nix` uses |
| 598 | + # the `propagateBuildInputs` adapter.) |
| 599 | + # |
| 600 | + # Examples where this matters: |
| 601 | + # |
| 602 | + # * `pkg-config`: |
| 603 | + # * `libwebp` depends on `libtiff` which depends on `lerc`. |
| 604 | + # `libtiff-4.pc` correctly declares (with my patch |
| 605 | + # https://gitlab.com/libtiff/libtiff/-/merge_requests/633): |
| 606 | + # |
| 607 | + # Libs.private: -llzma -lLerc -ljpeg -ldeflate -lz -lm |
| 608 | + # Requires.private: liblzma Lerc libjpeg libdeflate zlib |
| 609 | + # |
| 610 | + # But the `.pc` file does not include the path on which `libLerc.a` |
| 611 | + # can be found. |
| 612 | + # Thus we would normally get error: |
| 613 | + # |
| 614 | + # cannot find -lLerc: No such file or directory |
| 615 | + # |
| 616 | + # That is supposed to be resolved via `pkg-config --static --libs libtiff-4`, |
| 617 | + # which is supposed to chase down the `Requires.private: Lerc` dependency, |
| 618 | + # finding the correct path of `libLerc.a` from `Lerc.pc`. |
| 619 | + # But for that to work `Lerc.pc` must be on `PKG_CONFIG_PATH`. |
| 620 | + # nixpkgs includes the `PKG_CONFIG_PATH` of `lerc` in the build |
| 621 | + # of `libwebp` only if `lerc` is in `propagatedBuildInputs` of `libtiff`. |
| 622 | + propagatedBuildInputsOverlay = final: previous: { |
| 623 | + # Doing this like `pkgsStatic` does it via `makeStatic` in `adapters.nix`. |
| 624 | + # Problem build error: |
| 625 | + # error: build of '/nix/store/...-stdenv-linux.drv' failed: output '/nix/store/...-stdenv-linux' is not allowed to refer to the following paths: |
| 626 | + # /nix/store/...-binutils-patchelfed-ld-wrapper-2.41 |
| 627 | + # /nix/store/...-pcre2-10.43-dev |
| 628 | + # /nix/store/...-gmp-with-cxx-6.3.0-dev |
| 629 | + # /nix/store/...-musl-iconv-1.2.3 |
| 630 | + # /nix/store/...-binutils-2.41 |
| 631 | + # /nix/store/...-bootstrap-tools |
| 632 | + stdenv = previous.stdenvAdapters.propagateBuildInputs previous.stdenv; |
| 633 | + }; |
| 634 | + |
| 635 | + # Workaround to the above, overriding packages manually that need it. |
| 636 | + propagatedBuildInputsManuallyOverlay = final: previous: { |
| 637 | + |
| 638 | + # Needs |
| 639 | + # https://github.com/NixOS/nixpkgs/pull/320105 |
| 640 | + # to work, but we still have to have `lerc` in `propagatedBuildInputs` |
| 641 | + # so that downstream packages such as `libwebp` can see `lerc`'s `.pc` file. |
| 642 | + libtiff = previous.libtiff.overrideAttrs (oldAttrs: { |
| 643 | + propagatedBuildInputs = (oldAttrs.propagatedBuildInputs or []) ++ [ |
| 644 | + final.lerc |
| 645 | + ]; |
| 646 | + }); |
| 647 | + |
| 648 | + }; |
| 649 | + |
| 650 | + # pkgsPropagatedBuildInputs = pkgs.extend propagatedBuildInputsOverlay; |
| 651 | + pkgsPropagatedBuildInputs = pkgs.extend propagatedBuildInputsManuallyOverlay; |
| 652 | + |
| 653 | + |
592 | 654 | applyDontDisableStatic = pkgsSet: lib.mapAttrs (pkgName: pkgValue: |
593 | 655 | if pkgValue ? overrideAttrs then |
594 | 656 | pkgValue.overrideAttrs (old: { dontDisableStatic = true; }) |
|
601 | 663 | xorg = applyDontDisableStatic previous.xorg; |
602 | 664 | }; |
603 | 665 |
|
604 | | - pkgsDontDisableStatic = pkgs.extend dontDisableStaticOverlay; |
| 666 | + pkgsDontDisableStatic = pkgsPropagatedBuildInputs.extend dontDisableStaticOverlay; |
605 | 667 |
|
606 | 668 |
|
607 | 669 | # Overlay that enables `.a` files for as many system packages as possible. |
|
1723 | 1785 | inherit lib; |
1724 | 1786 |
|
1725 | 1787 | inherit pkgsWithGhc; |
| 1788 | + inherit pkgsPropagatedBuildInputs; |
1726 | 1789 | inherit pkgsDontDisableStatic; |
1727 | 1790 | inherit pkgsWithArchiveFiles; |
1728 | 1791 | inherit pkgsWithStaticHaskellBinaries; |
|
0 commit comments