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

meson: cross-compilation breaks when not using callPackage #67880

Closed
lukateras opened this issue Sep 1, 2019 · 6 comments
Closed

meson: cross-compilation breaks when not using callPackage #67880

lukateras opened this issue Sep 1, 2019 · 6 comments
Labels
0.kind: bug 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md

Comments

@lukateras
Copy link
Member

Describe the bug

Cross-compilation will break for derivations that depend on Meson unless wrapped in callPackage. Derivations that use callPackage work fine.

To Reproduce

Create default.nix:

let
  pkgs = (import <nixpkgs> {}).pkgsCross.musl64;
in

with pkgs;

stdenv.mkDerivation {
  name = "example";
  nativeBuildInputs = [ meson ninja ];
}

Run nix-build. It will fail with:

error: attribute 'targetPlatform' missing, at /nix/store/jc62lsfijc5qab87yrbi6aag67jd0lr8-source/pkgs/development/tools/build-managers/meson/default.nix:82:17

Which points to:

system = '${targetPackages.stdenv.targetPlatform.parsed.kernel.name}'

Expected behavior

If you modify default.nix to wrap derivation in callPackage, like this, you can successfully cross-compile a package that depends on Meson:

let
  pkgs = (import <nixpkgs> {}).pkgsCross.musl64;
in

with pkgs;

callPackage ({ stdenv, fetchFromGitHub, meson, ninja }: stdenv.mkDerivation {
  name = "example";
  # This can be any Meson project, providing one without deps as an example:
  src = fetchFromGitHub {
    owner = "transumption-unstable";
    repo = "subnetgen";
    rev = "f386dacfb54db2302c0b6905edfd486e94adf42c";
    sha256 = "0szsmzgsrkkm56d37qp9inj06ik71hkn64fnims2wjn9izk3fpq2";
  };
  nativeBuildInputs = [ meson ninja ];
}) {}

Additional context

Seems that targetPackages.stdenv.targetPlatform is missing for pkgsCross.* unless using callPackage. I wonder if it's always true that stdenv.targetPlatform == targetPackages.stdenv.targetPlatform.

Metadata

Reproducible in the latest nixos-unstable:

import (fetchTarball {
  url = "https://github.com/NixOS/nixpkgs/tarball/8d1510abfb592339e13ce8f6db6f29c1f8b72924";
  sha256 = "0i4jscq2qy2vn9kr8ix9gr8ncf9dss24y09jrqhlpcpryi4i98dc";
})

Maintainer information:

attribute: meson
module:

cc @jtojnar @Ericson2314

@symphorien
Copy link
Member

This looks like a duplicate of #49526

@lukateras
Copy link
Member Author

lukateras commented Sep 1, 2019

Hm, interesting. It might be possible to fix this in isolation, though.

@anna328p
Copy link
Member

I am also experiencing this issue.

@Ericson2314
Copy link
Member

This is expected. See splice.nix (no link cause on phone sorry). It is evil but I know no alternative other than a big refactor. Without splicing you need to explicitly use pkgs* to take packages from the right package set. There's nothing wrong with that, except that it's possible to forget.

@stale
Copy link

stale bot commented Jul 27, 2020

Hello, I'm a bot and I thank you in the name of the community for opening this issue.

To help our human contributors focus on the most-relevant reports, I check up on old issues to see if they're still relevant. This issue has had no activity for 180 days, and so I marked it as stale, but you can rest assured it will never be closed by a non-human.

The community would appreciate your effort in checking if the issue is still valid. If it isn't, please close it.

If the issue persists, and you'd like to remove the stale label, you simply need to leave a comment. Your comment can be as simple as "still important to me". If you'd like it to get more attention, you can ask for help by searching for maintainers and people that previously touched related code and @ mention them in a comment. You can use Git blame or GitHub's web interface on the relevant files to find them.

Lastly, you can always ask for help at our Discourse Forum or at #nixos' IRC channel.

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jul 27, 2020
@Ericson2314
Copy link
Member

I think this is fixed; stuff still breaks without callPackage because evil splicing, but there's nothing Meson specific about it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: bug 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md
Projects
None yet
Development

No branches or pull requests

4 participants