mirror of
https://github.com/ipetkov/crane.git
synced 2024-11-26 09:08:57 +03:00
85e31d408a
* i.e. if we neither set localSystem/crossSystem, nor add overlays, we can directly utilize `nixpkgs.legacyPackages.${system}` directly and avoid re-evaluating nixpkgs an additional time
60 lines
1.4 KiB
Nix
60 lines
1.4 KiB
Nix
{
|
|
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 = { nixpkgs, crane, fenix, flake-utils, ... }:
|
|
flake-utils.lib.eachDefaultSystem (system:
|
|
let
|
|
pkgs = nixpkgs.legacyPackages.${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;
|
|
|
|
my-crate = craneLib.buildPackage {
|
|
src = craneLib.cleanCargoSource (craneLib.path ./.);
|
|
|
|
strictDeps = true;
|
|
doCheck = false;
|
|
|
|
CARGO_BUILD_TARGET = "x86_64-pc-windows-gnu";
|
|
|
|
depsBuildBuild = with pkgs; [
|
|
pkgsCross.mingwW64.stdenv.cc
|
|
pkgsCross.mingwW64.windows.pthreads
|
|
];
|
|
};
|
|
in
|
|
{
|
|
packages = {
|
|
inherit my-crate;
|
|
default = my-crate;
|
|
};
|
|
|
|
checks = {
|
|
inherit my-crate;
|
|
};
|
|
}
|
|
);
|
|
}
|