Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cygwin: add as a cross-compilation target, and get bash.exe to compile #354137

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
107 changes: 64 additions & 43 deletions pkgs/os-specific/windows/cygwin/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,56 +10,77 @@
flex,
perl,
mingw_w64,
symlinkJoin,
}:

stdenv.mkDerivation {
pname = "cygwin";
let
newlib-cygwin = stdenv.mkDerivation {
pname = "cygwin";

inherit (cygwin_headers)
version
src
meta
patches
;
inherit (cygwin_headers)
version
src
meta
patches
;

preConfigure = ''
pushd winsup
aclocal --force
autoconf -f
automake -ac
rm -rf autom4te.cache
popd
patch -p0 -i ${./after-autogen.patch}
'';
preConfigure = ''
pushd winsup
aclocal --force
autoconf -f
automake -ac
rm -rf autom4te.cache
popd
patch -p0 -i ${./after-autogen.patch}
'';

postPatch = ''
patchShebangs --build winsup/cygwin/scripts
'';
postPatch = ''
patchShebangs --build winsup/cygwin/scripts
'';

env.CXXFLAGS_FOR_TARGET = "-Wno-error";
env.CXXFLAGS_FOR_TARGET = "-Wno-error";

depsBuildBuild = [ buildPackages.stdenv.cc ];
nativeBuildInputs = [
autoconf
automake
bison
cocom-tool-set
flex
perl
];
buildInputs = [ mingw_w64 ];
depsBuildBuild = [ buildPackages.stdenv.cc ];
nativeBuildInputs = [
autoconf
automake
bison
cocom-tool-set
flex
perl
];
buildInputs = [ mingw_w64 ];

hardeningDisable = [ "fortify" ];
configurePlatforms = [
"build"
"target"
];
configureFlags = [
"--disable-shared"
"--disable-doc"
"--enable-static"
"--disable-dumper"
"--with-cross-bootstrap"
"ac_cv_prog_CC=gcc"
postInstall = ''
mv $out/x86_64-pc-cygwin/* $out/
rmdir $out/x86_64-pc-cygwin
'';

hardeningDisable = [
"fortify"
"stackprotector"
];
configurePlatforms = [
"build"
"target"
];
configureFlags = [
"--disable-shared"
"--disable-doc"
"--enable-static"
"--disable-dumper"
"--with-cross-bootstrap"
"ac_cv_prog_CC=gcc"
];
};
in
# TODO: Is there something like nix-support which would achieve this better?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you just link the appropriate paths in postInstall in the main derivation?

symlinkJoin {
pname = "cygwin-and-mingw_w64";
inherit (newlib-cygwin) version;
paths = [
newlib-cygwin
mingw_w64
mingw_w64.dev
];
}