Cross Compiling: Difference between revisions
imported>Srhb m typo |
imported>Mic92 short faq on build inputs |
||
Line 10: | Line 10: | ||
nix build -f channel:nixos-unstable pkgsCross.raspberryPi.emacs | nix build -f channel:nixos-unstable pkgsCross.raspberryPi.emacs | ||
</syntaxHighlight> | </syntaxHighlight> | ||
== How to specify dependencies == | |||
Depending in which if packages are required at build time or at runtime they need to go to different inputs the derivation. | |||
* If it is used at build-time it's <code>depsBuildXXX</code> | |||
** compiler producing native binaries go to <code>depsBuildBuild</code> | |||
** compiler producing cross binaries, all setup hooks and programs executed by the builder go to <code>depsBuildHost</code> | |||
*** common examples: <code>pkgconfig, autoreconfHook, makeWrapper, intltool, bison, flex</code> | |||
* If it is used at run-time it's <code>depsHostXXX</code>. [Stack linking doesn't effect this, even if it allows us to forget where things came from.] | |||
** if it’s an interpreter that will be needed by an installed script, it should go in <code>depsHostTarget</code>. | |||
** otherwise it is probably only needed at build time and can go in <code>depsBuildHost</code> | |||
* If it is a tool and "acts" (e.g. helps build) on build-time stuff, then it's <code>depsXXXBuild</code> | |||
* If it is a tool and "acts" on run-time stuff, then it's <code>depsXXXHost</code> | |||
* if it is not a tool, it's <code>depsXXX(XXX+1)</code>(build + 1 == host, host +1 == target) for backwards compatibility, use <code>nativeBuildInputs</code> instead of <code>depsBuildHost</code> and <code>buildInputs</code> instead of <code>depsHostTarget</code>. | |||
Source: https://github.com/NixOS/nixpkgs/pull/50881#issuecomment-440772499 | |||
== References == | == References == |
Revision as of 02:35, 23 November 2018
For building arm software check out the Article NixOS on ARM
If you are looking for building 32bit software, check out Packaging/32bit Applications
Quick example to cross compile a package: Cheatsheet#Cross-compile_packages.
Cross-Compiling in nixpkgs unstable (pre-18.09)
A lot has happened in 2018 and now cross-compilation is well supported within the unstable branch of nixpkgs.
The basic idea is to use pkgsCross.platform
instead of pkgs
:
nix build -f channel:nixos-unstable pkgsCross.raspberryPi.emacs
How to specify dependencies
Depending in which if packages are required at build time or at runtime they need to go to different inputs the derivation.
- If it is used at build-time it's
depsBuildXXX
- compiler producing native binaries go to
depsBuildBuild
- compiler producing cross binaries, all setup hooks and programs executed by the builder go to
depsBuildHost
- common examples:
pkgconfig, autoreconfHook, makeWrapper, intltool, bison, flex
- common examples:
- compiler producing native binaries go to
- If it is used at run-time it's
depsHostXXX
. [Stack linking doesn't effect this, even if it allows us to forget where things came from.]- if it’s an interpreter that will be needed by an installed script, it should go in
depsHostTarget
. - otherwise it is probably only needed at build time and can go in
depsBuildHost
- if it’s an interpreter that will be needed by an installed script, it should go in
- If it is a tool and "acts" (e.g. helps build) on build-time stuff, then it's
depsXXXBuild
- If it is a tool and "acts" on run-time stuff, then it's
depsXXXHost
- if it is not a tool, it's
depsXXX(XXX+1)
(build + 1 == host, host +1 == target) for backwards compatibility, usenativeBuildInputs
instead ofdepsBuildHost
andbuildInputs
instead ofdepsHostTarget
.
Source: https://github.com/NixOS/nixpkgs/pull/50881#issuecomment-440772499
References
- Nixpkgs manual on cross compiling
- Introduction to Cross Compilation with nix by Matthew Bauer