{ description = "Cross compiling a rust program for windows"; inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; crane = { url = "github:ipetkov/crane"; inputs.nixpkgs.follows = "nixpkgs"; }; fenix = { url = "github:nix-community/fenix"; inputs.nixpkgs.follows = "nixpkgs"; }; flake-utils.url = "github:numtide/flake-utils"; }; outputs = { self, nixpkgs, crane, fenix, flake-utils }: flake-utils.lib.eachDefaultSystem (system: let pkgs = (import nixpkgs) { inherit system; }; toolchain = with fenix.packages.${system}; combine [ minimal.rustc minimal.cargo targets.x86_64-pc-windows-gnu.latest.rust-std ]; craneLib = (crane.mkLib pkgs).overrideToolchain toolchain; in { packages.default = craneLib.buildPackage { src = craneLib.cleanCargoSource ./.; strictDeps = true; doCheck = false; CARGO_BUILD_TARGET = "x86_64-pc-windows-gnu"; depsBuildBuild = with pkgs; [ pkgsCross.mingwW64.stdenv.cc pkgsCross.mingwW64.windows.pthreads ]; }; } ); }