Hey guys, I have a project which I want to cross-compile to windows (because I don't want to install windows on my machine, nor do I plan on developing on windows) and eventually MacOS.
All I really need is to know that it will compile for & run on windows.
This is what I tried, but I'm not sure what the best approach is here. Searching online didn't yield any conclusive results either.
{
description = "cross-compile dev env";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
};
outputs = { nixpkgs, ... }:
let
supportedSystems = ["x86_64-linux"];
eachSystem = fn: nixpkgs.lib.genAttrs supportedSystems (system:
fn nixpkgs.legacyPackages.${system}
);
in
{
#1 this is what I tried at first,
# but it created conflicts in the environment (obviously)
devShells = eachSystem (pkgs: {
default = pkgs.mkShell.override { stdenv = pkgs.gcc15.stdenv; } {
packages = with pkgs; [
...
pkgsCross.mingwW64.buildPackages.gcc15
];
};
});
#2 this is probably a better solution?
devShells = eachSystem (pkgs: let packages = with pkgs; [
...
]; in {
default = pkgs.mkShell.override { stdenv = pkgs.gcc15.stdenv; } {
inherit packages;
};
windows = pkgs.pkgsCross.mingwW64.mkShell {
inherit packages;
};
});
};
}
The project is just a C program which compiles using a Makefile. I stripped out dependencies etc. from the flake.
Adwaita