Skip to content

Build failure: libedit when using stdenvAdapters.withCFlags #273746

@magneticflux-

Description

@magneticflux-

Steps To Reproduce

Steps to reproduce the behavior:

  1. Use pkgs.stdenvAdapters.withCFlags to set env.NIX_CFLAGS_COMPILE
  2. build libedit

Build log

       … while calling anonymous lambda

         at /nix/store/ddz33fxapd2hsalbhrz5cd7rqb74jrhc-source/pkgs/development/libraries/libedit/default.nix:1:1:

            1| { lib, stdenv, fetchurl, ncurses }:
             | ^
            2|

       … from call site

         at /nix/store/ddz33fxapd2hsalbhrz5cd7rqb74jrhc-source/pkgs/development/libraries/libedit/default.nix:3:1:

            2|
            3| stdenv.mkDerivation rec {
             | ^
            4|   pname = "libedit";

       … while calling anonymous lambda

         at /nix/store/ddz33fxapd2hsalbhrz5cd7rqb74jrhc-source/pkgs/stdenv/adapters.nix:23:83:

           22|   # Wrap the original `mkDerivation` providing extra args to it.
           23|   extendMkDerivationArgs = old: f: withOldMkDerivation old (_: mkDerivationSuper: args:
             |                                                                                   ^
           24|     (mkDerivationSuper args).overrideAttrs f);

       … from call site

         at /nix/store/ddz33fxapd2hsalbhrz5cd7rqb74jrhc-source/pkgs/stdenv/adapters.nix:24:5:

           23|   extendMkDerivationArgs = old: f: withOldMkDerivation old (_: mkDerivationSuper: args:
           24|     (mkDerivationSuper args).overrideAttrs f);
             |     ^
           25|

       … while calling anonymous lambda

         at /nix/store/ddz33fxapd2hsalbhrz5cd7rqb74jrhc-source/pkgs/stdenv/generic/make-derivation.nix:92:8:

           91|     mkDerivationSimple
           92|       (f0:
             |        ^
           93|         let

       … from call site

         at /nix/store/ddz33fxapd2hsalbhrz5cd7rqb74jrhc-source/pkgs/stdenv/generic/make-derivation.nix:102:11:

          101|         in
          102|           makeDerivationExtensible (self: attrs // (if builtins.isFunction f0 || f0?__functor then f self attrs else f0)))
             |           ^
          103|       attrs;

       … while calling 'makeDerivationExtensible'

         at /nix/store/ddz33fxapd2hsalbhrz5cd7rqb74jrhc-source/pkgs/stdenv/generic/make-derivation.nix:51:30:

           50|   # Based off lib.makeExtensible, with modifications:
           51|   makeDerivationExtensible = rattrs:
             |                              ^
           52|     let

       … from call site

         at /nix/store/ddz33fxapd2hsalbhrz5cd7rqb74jrhc-source/pkgs/stdenv/generic/make-derivation.nix:84:9:

           83|       finalPackage =
           84|         mkDerivationSimple overrideAttrs args;
             |         ^
           85|

       … while calling 'mkDerivationSimple'

         at /nix/store/ddz33fxapd2hsalbhrz5cd7rqb74jrhc-source/pkgs/stdenv/generic/make-derivation.nix:118:1:

          117| #   Explanation about derivations in general
          118| {
             | ^
          119|

       … from call site

         at /nix/store/ddz33fxapd2hsalbhrz5cd7rqb74jrhc-source/pkgs/stdenv/generic/make-derivation.nix:548:1:

          547|
          548| extendDerivation
             | ^
          549|   validity.handled

       … while calling 'extendDerivation'

         at /nix/store/ddz33fxapd2hsalbhrz5cd7rqb74jrhc-source/lib/customisation.nix:237:43:

          236|   */
          237|   extendDerivation = condition: passthru: drv:
             |                                           ^
          238|     let

       … from call site

         at /nix/store/ddz33fxapd2hsalbhrz5cd7rqb74jrhc-source/pkgs/stdenv/generic/make-derivation.nix:597:33:

          596|    passthru)
          597|   (derivation (derivationArg // optionalAttrs envIsExportable checkedEnv));
             |                                 ^
          598|

       … while calling 'optionalAttrs'

         at /nix/store/ddz33fxapd2hsalbhrz5cd7rqb74jrhc-source/lib/attrsets.nix:795:5:

          794|     # The attribute set to return if `cond` is `true`.
          795|     as:
             |     ^
          796|     if cond then as else {};

       … from call site

         at /nix/store/ddz33fxapd2hsalbhrz5cd7rqb74jrhc-source/pkgs/stdenv/generic/make-derivation.nix:539:12:

          538|       "When using structured attributes, `env` must be an attribute set of environment variables.";
          539|     assert assertMsg (overlappingNames == [ ])
             |            ^
          540|       "The ‘env’ attribute set cannot contain any attributes passed to derivation. The following attributes are overlapping: ${concatStringsSep ", " overlappingNames}";

       … while calling 'assertMsg'

         at /nix/store/ddz33fxapd2hsalbhrz5cd7rqb74jrhc-source/lib/asserts.nix:23:5:

           22|     # Message to throw in case `pred` fails
           23|     msg:
             |     ^
           24|     pred || builtins.throw msg;

       error: The ‘env’ attribute set cannot contain any attributes passed to derivation. The following attributes are overlapping: NIX_CFLAGS_COMPILE

Additional context

This seems to have been triggered these two PRs:
#225929
#270143

This issue directed me where to look: #268767

Testing with this overlay to migrate to env.NIX_CFLAGS_COMPILE fixes the issue for me:

overlays = [
  (final: prev: {
    libedit = prev.stdenv.mkDerivation rec {
      pname = "libedit";
      version = "20221030-3.1";
      src = prev.fetchurl {
        url = "https://thrysoee.dk/editline/${pname}-${version}.tar.gz";
        sha256 = "sha256-8JJaWt9LG/EW7hl2a32qdmkXrsGYdHlDscTt9npL4rs=";
      };
      outputs = [ "out" "dev" ];
      # Have `configure' avoid `/usr/bin/nroff' in non-chroot builds.
      # NROFF = "${groff}/bin/nroff";
      # GCC automatically include `stdc-predefs.h` while Clang does not do
      # this by default. While Musl is ISO 10646 compliant, doesn't define
      # __STDC_ISO_10646__. This definition is in `stdc-predefs.h` that's
      # why libedit builds just fine with GCC and Musl.
      # There is a DR to fix this issue with Clang which is not merged
      # yet.
      # https://reviews.llvm.org/D137043
      env.NIX_CFLAGS_COMPILE = lib.optional
        (prev.stdenv.targetPlatform.isMusl && prev.stdenv.cc.isClang)
        "-D__STDC_ISO_10646__=201103L";
      patches = [ ./01-cygwin.patch ];
      propagatedBuildInputs = [ prev.ncurses ];
      postInstall = ''
        find $out/lib -type f | grep '\.\(la\|pc\)''$' | xargs sed -i \
          -e 's,-lncurses[a-z]*,-L${prev.ncurses.out}/lib -lncursesw,g'
      '';
      meta = with lib; {
        homepage = "http://www.thrysoee.dk/editline/";
        description = "A port of the NetBSD Editline library (libedit)";
        license = licenses.bsd3;
        platforms = platforms.all;
      };
    };
  })
];

Notify maintainers

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
output here

Add a 👍 reaction to issues you find important.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions