Statically compiling a Windows binary with mingw that needs pthreads?

I’m having a lot of trouble with this. I’m trying to package this script, that depends on a statically compiled Windows binary.

This is what I have so far:

{
    fetchFromGitHub,
    lib,
    pkgs,
    stdenv,
    ...
}:

stdenv.mkDerivation rec {
    pname = "mo2installer";
    version = "5.0.3";

    src = fetchFromGitHub {
        owner = "rockerbacon";
        repo = "modorganizer2-linux-installer";
        rev = "90d33013aca0deceaadc099be4d682e08f237ef5";
        sha256 = "sha256-RYN5/t5Hmzu+Tol9iJ+xDmLGY9sAkLTU0zY6UduJ4i0=";
    };

    buildInputs = with pkgs; [
        bash
        curl
        p7zip
        protontricks
        zenity
    ] ++ (with pkgsCross.mingwW64.buildPackages; [
        gcc
    ]);

    nativeBuildInputs = [ pkgs.makeWrapper ];

    buildPhase = ''
        cd steam-redirector/
        make "main.exe"
    '';

    installPhase = ''
        mkdir -p "$out/bin"

        mv "install.sh" "${pname}"
        cp -r ./* "$out/bin"

        wrapProgram $out/bin/${pname} --prefix PATH : ${lib.makeBinPath (with pkgs; [
            bash
            curl
            p7zip
            protontricks
            zenity
        ])}
    '';
}

I’m running into this error when trying to compile though:

error: builder for '/nix/store/a027m0d316afn1lpgay3h6jfmwycaarl-mo2installer-5.0.3.drv' failed with exit code 2;
       last 25 log lines:
       > calling 'envTargetTargetHook' function hook 'bintoolsWrapper_addLDVars' /nix/store/vadr5l3lhhkvijsm7ba9rnhkh7i4f6kq-x86_64-w64-mingw32-gcc-wrapper-13.3.0
       > calling 'envTargetTargetHook' function hook 'ccWrapper_addCVars' /nix/store/csqys140jagfjp8k04mqv4lhas2ivcmn-x86_64-w64-mingw32-binutils-wrapper-2.42
       > calling 'envTargetTargetHook' function hook 'bintoolsWrapper_addLDVars' /nix/store/csqys140jagfjp8k04mqv4lhas2ivcmn-x86_64-w64-mingw32-binutils-wrapper-2.42
       > calling 'envTargetTargetHook' function hook 'ccWrapper_addCVars' /nix/store/6bizi2bgnrfq8q1wdl4vw4bhddipwhk1-mcfgthread-x86_64-w64-mingw32-1.6.1-dev
       > calling 'envTargetTargetHook' function hook 'bintoolsWrapper_addLDVars' /nix/store/6bizi2bgnrfq8q1wdl4vw4bhddipwhk1-mcfgthread-x86_64-w64-mingw32-1.6.1-dev
       > calling 'envTargetTargetHook' function hook 'ccWrapper_addCVars' /nix/store/68dsqrvjzfg16lvbfxcb850yca82820m-mcfgthread-x86_64-w64-mingw32-1.6.1
       > calling 'envTargetTargetHook' function hook 'bintoolsWrapper_addLDVars' /nix/store/68dsqrvjzfg16lvbfxcb850yca82820m-mcfgthread-x86_64-w64-mingw32-1.6.1
       > Running phase: unpackPhase
       > unpacking source archive /nix/store/1nyg4l4rnyf7g9cm73crrwawxaaqb7dm-source
       > calling 'unpackCmd' function hook '_try7zip' /nix/store/1nyg4l4rnyf7g9cm73crrwawxaaqb7dm-source
       > calling 'unpackCmd' function hook '_defaultUnpack' /nix/store/1nyg4l4rnyf7g9cm73crrwawxaaqb7dm-source
       > source root is source
       > calling 'postUnpack' function hook '_updateSourceDateEpochFromSourceRoot'
       > Running phase: patchPhase
       > Running phase: updateAutotoolsGnuConfigScriptsPhase
       > Running phase: configurePhase
       > calling 'preConfigure' function hook '_multioutConfig'
       > no configure script, doing nothing
       > Running phase: buildPhase
       > x86_64-w64-mingw32-gcc -municode -static -static-libgcc -Bstatic -lpthread -mwindows -o main.exe main.c win32_utils.c
       > /nix/store/m97kjxkw00czjfq5dsl7rp1xikrbz6in-x86_64-w64-mingw32-binutils-2.42/bin/x86_64-w64-mingw32-ld: cannot find -lpthread: No such file or directory
       > /nix/store/m97kjxkw00czjfq5dsl7rp1xikrbz6in-x86_64-w64-mingw32-binutils-2.42/bin/x86_64-w64-mingw32-ld: cannot find -lmcfgthread: No such file or directory
       > /nix/store/m97kjxkw00czjfq5dsl7rp1xikrbz6in-x86_64-w64-mingw32-binutils-2.42/bin/x86_64-w64-mingw32-ld: cannot find -lmcfgthread: No such file or directory
       > collect2: error: ld returned 1 exit status
       > make: *** [Makefile:15: main.exe] Error 1
       For full logs, run 'nix log /nix/store/a027m0d316afn1lpgay3h6jfmwycaarl-mo2installer-5.0.3.drv'.

I’ve been doing some research into how to fix this, but I don’t really understand how I can apply it to my situation. This is what I’ve looked at so far: