Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

curl overrides are discarded when pulled in via fetchpatch, but overrideAttrs are not #66499

Closed
nh2 opened this issue Aug 12, 2019 · 8 comments
Closed
Labels
0.kind: question Requests for a specific question to be answered

Comments

@nh2
Copy link
Contributor

nh2 commented Aug 12, 2019

I have this blocker problem currently for musl builds in static-haskell-nix:

When I override curl in an overlay, while also adding a fetchpatch to the proper libdrm/default.nix, then the the fetchpatch causes curl to build and fail with linker error.

That is because while it does build the curl from my overlay, it seems to ignore what I've given in .override (e.g. I give gssSupport = false, but inside e.g. configurePhase it's still true again).

I basically do in my overlay

{
  curl = (previous.curl.override { gssSupport = false; }).overrideAttrs (old: {
    makeFlags = ["V=1"];
  });
}

and observe that the V=1 is in effect, but the gssSupport = false is not.

(I see that in nix show-derivation on the .drv.)

What's going on here?


cc from IRC: @matthewbauer @Ericson2314 @dtzWill @cleverca22

Environment

commit bc94dcf

@nh2 nh2 added the 0.kind: question Requests for a specific question to be answered label Aug 12, 2019
nh2 added a commit to nh2/static-haskell-nix that referenced this issue Aug 12, 2019
Repro with:

    NIX_PATH=. nix-build --no-link survey/default.nix --arg disableOptimization true -A pkgs.libdrm
@nh2
Copy link
Contributor Author

nh2 commented Aug 12, 2019

To repro this:

git clone --recursive https://github.com/nh2/static-haskell-nix.git -b nixpkgs-66499-problem-repro-curl-override-discarded
cd static-haskell-nix
NIX_PATH=. nix-build --no-link survey/default.nix --arg disableOptimization true -A pkgs.libdrm

(this is the branch in nh2/static-haskell-nix#45)


It prints

...
trace: gssSupport true
these derivations will be built:
  /nix/store/bkk1f6ls0rm6xz4l2fyy9gxlzlfafy7x-curl-7.64.1.drv
  /nix/store/2hcg7wnzyqamdy68y1rhcpqf0gap1jl9-musl-ioctl.patch.drv
  /nix/store/150vlxnw31ida8wr45fknywjm8kkn7hs-libdrm-2.4.97.drv
building '/nix/store/bkk1f6ls0rm6xz4l2fyy9gxlzlfafy7x-curl-7.64.1.drv'...
...
configuring

gssSupport true

exiting
builder for '/nix/store/bkk1f6ls0rm6xz4l2fyy9gxlzlfafy7x-curl-7.64.1.drv' failed with exit code 1

And

% nix show-derivation /nix/store/bkk1f6ls0rm6xz4l2fyy9gxlzlfafy7x-curl-7.64.1.drv | grep -E 'configureFlags|makeFlags'
      "configureFlags": "--without-ca-bundle --without-ca-path --with-ca-fallback --disable-manual --with-ssl=/nix/store/c7ax9w05g2vp36wm0j695fbh89dma2rq-openssl-1.0.2r-dev --without-gnutls --with-libssh2=/nix/store/a6crgyyg9v9splnidqmz2530q888cf6l-libssh2-1.8.2-dev --disable-ldap --disable-ldaps --without-libidn --without-brotli --with-gssapi=/nix/store/q82pls5sglxi3bi49r7m736kz01pqmkc-libkrb5-1.17-dev",
      "makeFlags": "curl_LDFLAGS=-all-static V=1",

shows that my makeFlags from here made it in but --with-gssapi is given even though I give gssSupport = false here.

@nh2
Copy link
Contributor Author

nh2 commented Aug 12, 2019

Is there some magic somewhere that makes that fetchpatch -> fetchurl -> curl discards curl.override in overlays but retains curl.overrideAttrs?

@nh2
Copy link
Contributor Author

nh2 commented Aug 12, 2019

Some info from @infinisil:

Not sure, but curl is a bit special in that a modified version is used for pkgs.fetchurl

curl = buildPackages.curl.override rec {

There buildPackages.curl is used with gssSupport overwritten

I confirmed:

that place certainly seems to be very involved in the problem, if I set gssSupport = false; then it's false in my build

So indeed that place just overrides my .override but not my overrideAttrs.

How can I make my .override take precedence?

@infinisil
Copy link
Member

infinisil commented Aug 12, 2019

Maybe something like

self: super: {
  fetchurl = super.fetchurl.override (old: {
    curl = old.curl.override {
      gssSupport = false;
      # ...
    };
  });
}

@nh2
Copy link
Contributor Author

nh2 commented Aug 12, 2019

I should also mention why I actually want to do that:

In my overlay, I want to have libcurl and libkrb5 have static libraries (.a files).

So I do

{
    krb5 = previous.krb5.override {
      # Note krb5 does not support building both static and shared at the same time.
      # That means *anything* on top of this overlay trying to link krb5
      # dynamically from this overlay will fail with linker errors.
      staticOnly = true;
    };

    # Disable gss support, because that requires `krb5`,
    # which (as mentioned above) is a library that cannot build both
    # .a and .so files in its build system.
    # That means that if we enable it, we can no longer build the
    # dynamically-linked `curl` binary from this overlay.
    # But `fetchurl`, `fetchpatch` and so on by default depend on dynamically
    # linked `curl` binaries.
    curl = (previous.curl.override { gssSupport = false; }).overrideAttrs (old: {
      dontDisableStatic = true;
    });
}

See the dilemma? Having krb5 .a files means there will be no .so files for it, which means curl can't find krb5 .so files, so I must disable that feature for curl.

@nh2
Copy link
Contributor Author

nh2 commented Aug 12, 2019

fetchurl = super.fetchurl.override (old: {

That doesn't work, because super.fetchurl is a function taking { url, ... }, not a derivation, so it doesn't have an .override attribute.

It seems fetchurl can't be overridden.

@nh2
Copy link
Contributor Author

nh2 commented Aug 12, 2019

@infinisil said:

Try changing nixpkgs fetchurl = import ../build-support/fetchurl to `fetchurl = callPackage ...

Indeed callPackage seems to make it work.

me:

Should that be changed this way?

@infinisil siad:

Yeah I'd say so
Seeing the eval stats for that will be interesting

nh2 added a commit to nh2/nixpkgs that referenced this issue Aug 12, 2019
This provides a workaround for NixOS#66499, because this way
NixOS#66499 (comment)

    self: super: {
      fetchurl = super.fetchurl.override (old: {
        curl = old.curl.override {
          gssSupport = false;
          # ...
        };
      });
    }

works as expected.
@nh2
Copy link
Contributor Author

nh2 commented Aug 13, 2019

I found the fix in #66506.

nh2 added a commit to nh2/nixpkgs that referenced this issue Aug 13, 2019
This provides a workaround for NixOS#66499, because this way
NixOS#66499 (comment)

    self: super: {
      fetchurl = super.fetchurl.override (old: {
        curl = old.curl.override {
          gssSupport = false;
          # ...
        };
      });
    }

works as expected.
nh2 added a commit to nh2/nixpkgs that referenced this issue Aug 13, 2019
…6499.

The original intent in commit

    a1fec86 treewide: assemble all `fetchurlBoot` uses in overrides to `fetchurl` itself

was to turn `gssSupport` *off* on Darwin, but the code actually also forced
it *on* on Linux.
This resulted in previous (e.g. overlays) `.override { gssSupport = false; }`
being ignored (NixOS#66499).

This commit fixes it by just respecting the old value when it doesn't need
to be forced to off.
nh2 added a commit to nh2/nixpkgs that referenced this issue Aug 14, 2019
This provides a workaround for NixOS#66499, because this way
NixOS#66499 (comment)

    self: super: {
      fetchurl = super.fetchurl.override (old: {
        curl = old.curl.override {
          gssSupport = false;
          # ...
        };
      });
    }

works as expected.
nh2 added a commit to nh2/nixpkgs that referenced this issue Aug 14, 2019
…6499.

The original intent in commit

    a1fec86 treewide: assemble all `fetchurlBoot` uses in overrides to `fetchurl` itself

was to turn `gssSupport` *off* on Darwin, but the code actually also forced
it *on* on Linux.
This resulted in previous (e.g. overlays) `.override { gssSupport = false; }`
being ignored (NixOS#66499).

This commit fixes it by just respecting the old value when it doesn't need
to be forced to off.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: question Requests for a specific question to be answered
Projects
None yet
Development

No branches or pull requests

2 participants