diff options
Diffstat (limited to 'nixpkgs/doc/stdenv/cross-compilation.chapter.md')
-rw-r--r-- | nixpkgs/doc/stdenv/cross-compilation.chapter.md | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/nixpkgs/doc/stdenv/cross-compilation.chapter.md b/nixpkgs/doc/stdenv/cross-compilation.chapter.md index e659e1803807..76c931ba047a 100644 --- a/nixpkgs/doc/stdenv/cross-compilation.chapter.md +++ b/nixpkgs/doc/stdenv/cross-compilation.chapter.md @@ -15,7 +15,9 @@ Nixpkgs follows the [conventions of GNU autoconf](https://gcc.gnu.org/onlinedocs In Nixpkgs, these three platforms are defined as attribute sets under the names `buildPlatform`, `hostPlatform`, and `targetPlatform`. They are always defined as attributes in the standard environment. That means one can access them like: ```nix -{ stdenv, fooDep, barDep, ... }: ...stdenv.buildPlatform... +{ stdenv, fooDep, barDep, ... }: { + # ...stdenv.buildPlatform... +} ``` `buildPlatform` @@ -127,7 +129,9 @@ Some frequently encountered problems when packaging for cross-compilation should Many packages assume that an unprefixed binutils (`cc`/`ar`/`ld` etc.) is available, but Nix doesn't provide one. It only provides a prefixed one, just as it only does for all the other binutils programs. It may be necessary to patch the package to fix the build system to use a prefix. For instance, instead of `cc`, use `${stdenv.cc.targetPrefix}cc`. ```nix -makeFlags = [ "CC=${stdenv.cc.targetPrefix}cc" ]; +{ + makeFlags = [ "CC=${stdenv.cc.targetPrefix}cc" ]; +} ``` #### How do I avoid compiling a GCC cross-compiler from source? {#cross-qa-avoid-compiling-gcc-cross-compiler} @@ -142,7 +146,9 @@ $ nix-build '<nixpkgs>' -A pkgsCross.raspberryPi.hello Add the following to your `mkDerivation` invocation. ```nix -depsBuildBuild = [ buildPackages.stdenv.cc ]; +{ + depsBuildBuild = [ buildPackages.stdenv.cc ]; +} ``` #### My package’s testsuite needs to run host platform code. {#cross-testsuite-runs-host-code} @@ -150,7 +156,9 @@ depsBuildBuild = [ buildPackages.stdenv.cc ]; Add the following to your `mkDerivation` invocation. ```nix -doCheck = stdenv.buildPlatform.canExecute stdenv.hostPlatform; +{ + doCheck = stdenv.buildPlatform.canExecute stdenv.hostPlatform; +} ``` #### Package using Meson needs to run binaries for the host platform during build. {#cross-meson-runs-host-code} @@ -159,12 +167,14 @@ Add `mesonEmulatorHook` to `nativeBuildInputs` conditionally on if the target bi e.g. -``` -nativeBuildInputs = [ - meson -] ++ lib.optionals (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) [ - mesonEmulatorHook -]; +```nix +{ + nativeBuildInputs = [ + meson + ] ++ lib.optionals (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) [ + mesonEmulatorHook + ]; +} ``` Example of an error which this fixes. |