Cross Compiling: Difference between revisions
imported>Symphorien add a link to the examples of target systems in nixpkgs |
imported>Symphorien →How to obtain a shell with a cross compiler: mention using callPackage to have native build inputs |
||
| Line 29: | Line 29: | ||
Examples of how to specify your target system can be found in [https://github.com/NixOS/nixpkgs/blob/master/lib/systems/examples.nix lib/systems/examples.nix]. | Examples of how to specify your target system can be found in [https://github.com/NixOS/nixpkgs/blob/master/lib/systems/examples.nix lib/systems/examples.nix]. | ||
The example above does not work as is with build dependencies (<code>nativeBuildInputs</code>). A solution is to use <code>callPackage</code> to enable splicing: | |||
<syntaxhighlight lang="nix"> | |||
let pkgs = import <nixpkgs> { | |||
crossSystem = { | |||
config = "aarch64-unknown-linux-gnu"; | |||
}; | |||
}; | |||
in | |||
pkgs.callPackage ( | |||
{mkShell, pkg-config, zlib}: | |||
mkShell { | |||
nativeBuildInputs = [ pkg-config ]; # you build dependencies here | |||
buildInputs = [ zlib ]; # your dependencies here | |||
} | |||
) {} | |||
</syntaxhighlight> | |||
See also {{issue|49526}}. | |||
== How to specify dependencies == | == How to specify dependencies == | ||