Skip to content

Using addAttrsToDerivation with nativeBuildInputs causes the derivation's nativeBuildInputs to be ignored #6

@vs49688

Description

@vs49688

When building with any of the devkitNix.stdenv* stdenv's, the derivation's nativeBuildInputs are completely ignored, e.g.:

devkitNix.stdenvA64.stdenv.mkDerivation(finalAttrs: {
  nativeBuildInputs = [ cmake ];
})

nativeBuildInputs ends up just being [ devkitA64 ].

This is because addAttrsToDerivation doesn't handle merging lists well, it just overwrites them:

        stdenvA64 = pkgs.stdenvAdapters.addAttrsToDerivation {
          nativeBuildInputs = [ devkitA64 ];
          env.DEVKITPRO = devkitA64 + "/opt/devkitpro";
        } pkgs.stdenvNoCC;

You can confirm this by commenting nativeBuildInputs = [ devkitA64 ]; - the build fails of course, but nativeBuildInputs now contains cmake.

I'm not sure what the best solution here is tbh.

If this is addAttrsToDerivation:

  addAttrsToDerivation =
    extraAttrs: stdenv:
    stdenv.override (old: {
      mkDerivationFromStdenv = extendMkDerivationArgs old (_: extraAttrs);
    });

immediately above it is propagateBuildInputs, so maybe this could be tweaked to do the same except with nativeBuildInputs?

  propagateBuildInputs =
    stdenv:
    stdenv.override (old: {
      mkDerivationFromStdenv = extendMkDerivationArgs old (args: {
        propagatedBuildInputs = (args.propagatedBuildInputs or [ ]) ++ (args.buildInputs or [ ]);
        buildInputs = [ ];
      });
    });

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions