Cross Compiling: Difference between revisions

imported>Jtojnar
m do not use pkgconfig alias
imported>Symphorien
show how to use pkgsCross to get a shell, and remove mentions of pre-18.09
Line 4: Line 4:
Quick example to cross compile a package: [[Cheatsheet#Cross-compile_packages]].
Quick example to cross compile a package: [[Cheatsheet#Cross-compile_packages]].


== Cross-Compiling in nixpkgs unstable (pre-18.09) ==
== Cross-Compiling a package in nixpkgs ==
A lot has happened in 2018 and now cross-compilation is well supported within the unstable branch of nixpkgs.
Cross-compilation is well supported in nixpkgs since 18.09.
The basic idea is to use <code>pkgsCross.platform</code> instead of <code>pkgs</code>:
The basic idea is to use <code>pkgsCross.platform</code> instead of <code>pkgs</code>:
<syntaxHighlight lang=bash>
<syntaxHighlight lang=bash>
nix build -f channel:nixos-unstable pkgsCross.raspberryPi.emacs
nix-build '<nixpkgs>' -A pkgsCross.raspberryPi.openssl
</syntaxHighlight>
</syntaxHighlight>


Line 34: Line 34:
};
};
in
in
...
mkShell {}
</syntaxhighlight>
 
Even shorter:
<syntaxhighlight lang="nix">
let pkgs = import <nixpkgs> {}; in
pkgs.pkgsCross.armv7l-hf-multiplatform.mkShell {}
</syntaxhighlight>
</syntaxhighlight>