Cross Compiling: Difference between revisions
→Tips and tricks: NixOS config example |
Phanirithvij (talk | contribs) m add another way via nix-build cli to cross compile |
||
| Line 20: | Line 20: | ||
</syntaxhighlight>You can perform the same operations using the CLI, and Nix will correctly evaluate the <code>localSystem</code> based on your current system:<syntaxhighlight lang="bash"> | </syntaxhighlight>You can perform the same operations using the CLI, and Nix will correctly evaluate the <code>localSystem</code> based on your current system:<syntaxhighlight lang="bash"> | ||
nix-build '<nixpkgs>' -A pkgsCross.aarch64-multiplatform.hello # nix-legacy | nix-build '<nixpkgs>' -A pkgsCross.aarch64-multiplatform.hello # nix-legacy | ||
nix-build '<nixpkgs>' --arg crossSystem '(import <nixpkgs> {}).lib.systems.examples.aarch64-multiplatform' -A hello # alternative way | |||
nix build nixpkgs#pkgsCross.aarch64-multiplatform.hello # nix3 | nix build nixpkgs#pkgsCross.aarch64-multiplatform.hello # nix3 | ||
</syntaxhighlight>All of the above snippets will resolve to the exact same derivation result, which will provide a binary for GNU Hello that can execute only on an <code>aarch64</code> system. There are many other systems <code>pkgsCross</code> has defined, you can see an exhaustive list of all of them on your system:<syntaxhighlight lang="bash"> | </syntaxhighlight>All of the above snippets will resolve to the exact same derivation result, which will provide a binary for GNU Hello that can execute only on an <code>aarch64</code> system. There are many other systems <code>pkgsCross</code> has defined, you can see an exhaustive list of all of them on your system:<syntaxhighlight lang="bash"> | ||