Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions docs/cross_compilation.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,12 @@ To try it,
2. `nix develop` to enter the development environment.
3. `make run` to build and run the program in an emulator.

Another example without `mkRustBin` can be seen in
[`examples/cross-mingw/flake.nix`](../examples/cross-mingw/flake.nix) (cross-compiling to Windows).
To try it,
1. `cd` into `examples/cross-mingw`.
2. `nix develop` to enter the development environment.
3. `make run` to build and run the program with Wine.

[wiki-cross]: https://wiki.nixos.org/wiki/Cross_Compiling#How_to_specify_dependencies
[flake-cross-issue]: https://github.com/NixOS/nix/issues/5157
38 changes: 38 additions & 0 deletions examples/cross-mingw/flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Example flake for `nix develop`.
# See docs/cross_compilation.md for details.
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixpkgs-unstable";
Comment thread
julius-boettger marked this conversation as resolved.
Outdated
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
};

outputs = { self, nixpkgs, rust-overlay, ... }:
let
system = "x86_64-linux";
pkgs = import nixpkgs {
inherit system;
overlays = [ (import rust-overlay) ];
Comment thread
julius-boettger marked this conversation as resolved.
Outdated
crossSystem.config = "x86_64-w64-mingw32";
};
in
{
devShells.${system} = {
default = pkgs.callPackage (
{ mkShell, stdenv, rust-bin, windows, wine64 }:
mkShell {
nativeBuildInputs = [
rust-bin.stable.latest.minimal
];

depsBuildBuild = [ wine64 ];
buildInputs = [ windows.pthreads ];

CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER = "${stdenv.cc.targetPrefix}cc";
CARGO_TARGET_X86_64_PC_WINDOWS_GNU_RUNNER = "wine64";
}) {};
};
};
}