Open yshui opened 9 months ago
pkgsCross.mingwW64.pkgsStatic.stdenv.targetPlatform.config
is "x86_64-w64-windows-gnu"
for some reason, unlike pkgsCross.mingwW64.stdenv.targetPlatform.config
which is "x86_64-w64-mingw32"
as expected.
The Windows case doesn't seem to be covered here, since for MinGW-w64, config
doesn't use the result from lib.systems.parse.tripleFromSystem pkgsCross.mingwW64.stdenv.hostPlatform.parsed
, which is "x86_64-w64-windows-gnu"
. Instead, we have
So I guess stdenv.hostPlatform.{config,libc}
should be passed to crossSystem
conditionally.
Bump, this issue is quite unfortunate when attempting to build static apps through nix.
I was able to build a static windows (mingwW64) executable with 34cefd7dea46e02932c2413ae7068574d0352ce9. I think this closes the issue? Thanks @wolfgangwalther! :heart:
edit: It seems #303849 is not merged yet. So I'm just leaving this information here.
Hi, is there any possible work around for this? (just facing this now after upgrading from 22.11 to 24.05)
Hi, is there any possible work around for this? (just facing this now after upgrading from 22.11 to 24.05)
The work-around is to "properly" instantiate cross compilation.
Compare the following on nixos-24.05 at dc2e0028d274394f73653c7c90cc63edbb696be1.
❯ nix-build '<nixpkgs>' -A pkgsCross.mingwW64.pkgsStatic.stdenv
[..]
checking host system type... Invalid configuration 'x86_64-w64-windows-gnu': Kernel 'windows' not known to work with OS 'gnu'.
configure: error: /nix/store/516kai7nl5dxr792c0nzq0jp8m4zvxpi-bash-5.2p32/bin/bash ./build-aux/config.sub x86_64-w64-windows-gnu failed
error: builder for '/nix/store/j8yx9qfk3yyfq2p5w7k0lmg2xkbypfkr-mingw_w64-headers-static-11.0.1.drv' failed with exit code 1;
vs
❯ nix-build --expr '(import <nixpkgs> { crossSystem = { config = "x86_64-w64-mingw32"; isStatic = true; }; }).stdenv'
/nix/store/m77b2dla2w3k8cx4ggjdmm2j8nldy6j6-stdenv-linux
The problem is not that static mingw64 cross-compilation is broken. The problem is that pkgsCross
and pkgsStatic
cannot be arbitrarily combined.
The work-around is to "properly" instantiate cross compilation.
Whether that's "proper" or not... is a question of it's own. For example for linux, pkgsStatic
will use musl
. If you just do isStatic = true
that way, it will not be musl, right? But a lot of nixpkgs is assuming Linux + Static = musl.
So imho, there is too much knowledge / dependency in nixpkgs about pkgsStatic already to say it's not correct to use it.
Also.. is it really the composition that is broken? What about the following?
nix-build --expr '(import <nixpkgs> { crossSystem = { config = "x86_64-w64-mingw32"; }; }).pkgsStatic.stdenv'
Yup, broken as well.
Steps To Reproduce
Steps to reproduce the behavior:
Build log
Metadata
Please run
nix-shell -p nix-info --run "nix-info -m"
and paste the result.Add a :+1: reaction to issues you find important.