Fix cygwin support and add support for x86_64-cygwin

The following patches fix cygwin support and also implement x86_64-cygwin support.

However, these patches are meaningless if the following pull request to Nix is not accepted (which fixes Cygwin support): https://github.com/NixOS/nix/pull/274