2023-01-07 04:11:42 +03:00
|
|
|
{
|
|
|
|
description = "Cross compiling a rust program for windows";
|
|
|
|
|
|
|
|
inputs = {
|
|
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
|
|
|
|
2024-08-30 02:29:16 +03:00
|
|
|
crane.url = "github:ipetkov/crane";
|
2023-01-07 04:11:42 +03:00
|
|
|
|
|
|
|
fenix = {
|
|
|
|
url = "github:nix-community/fenix";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
|
|
|
|
|
|
|
flake-utils.url = "github:numtide/flake-utils";
|
|
|
|
};
|
|
|
|
|
2023-11-05 21:42:08 +03:00
|
|
|
outputs = { nixpkgs, crane, fenix, flake-utils, ... }:
|
2023-01-07 04:11:42 +03:00
|
|
|
flake-utils.lib.eachDefaultSystem (system:
|
|
|
|
let
|
2023-11-26 21:37:43 +03:00
|
|
|
pkgs = nixpkgs.legacyPackages.${system};
|
2023-01-07 04:11:42 +03:00
|
|
|
|
|
|
|
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;
|
2023-10-17 05:56:16 +03:00
|
|
|
|
|
|
|
my-crate = craneLib.buildPackage {
|
2024-06-11 06:53:46 +03:00
|
|
|
src = craneLib.cleanCargoSource ./.;
|
2023-01-07 04:11:42 +03:00
|
|
|
|
|
|
|
strictDeps = true;
|
|
|
|
doCheck = false;
|
|
|
|
|
|
|
|
CARGO_BUILD_TARGET = "x86_64-pc-windows-gnu";
|
|
|
|
|
2024-04-21 06:06:32 +03:00
|
|
|
# fixes issues related to libring
|
|
|
|
TARGET_CC = "${pkgs.pkgsCross.mingwW64.stdenv.cc}/bin/${pkgs.pkgsCross.mingwW64.stdenv.cc.targetPrefix}cc";
|
|
|
|
|
|
|
|
#fixes issues related to openssl
|
|
|
|
OPENSSL_DIR = "${pkgs.openssl.dev}";
|
|
|
|
OPENSSL_LIB_DIR = "${pkgs.openssl.out}/lib";
|
|
|
|
OPENSSL_INCLUDE_DIR = "${pkgs.openssl.dev}/include/";
|
|
|
|
|
2023-01-07 04:11:42 +03:00
|
|
|
depsBuildBuild = with pkgs; [
|
|
|
|
pkgsCross.mingwW64.stdenv.cc
|
|
|
|
pkgsCross.mingwW64.windows.pthreads
|
|
|
|
];
|
|
|
|
};
|
2023-10-17 05:56:16 +03:00
|
|
|
in
|
|
|
|
{
|
|
|
|
packages = {
|
|
|
|
inherit my-crate;
|
|
|
|
default = my-crate;
|
|
|
|
};
|
|
|
|
|
|
|
|
checks = {
|
|
|
|
inherit my-crate;
|
|
|
|
};
|
2023-01-07 04:11:42 +03:00
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|