···1+# On cygwin, automatic runtime dependency detection does not work
2+# because the binaries do not contain absolute references to store
3+# locations (yet)
4+postFixupHooks+=(_cygwinAllBuildInputsAsRuntimeDep)
5+6+_cygwinAllBuildInputsAsRuntimeDep() {
7+ if [ -n "$buildInputs" ]; then
8+ mkdir -p "$out/nix-support"
9+ echo "$buildInputs" >> "$out/nix-support/cygwin-buildinputs-as-runtime-deps"
10+ fi
11+12+ if [ -n "$nativeBuildInputs" ]; then
13+ mkdir -p "$out/nix-support"
14+ echo "$nativeBuildInputs" >> "$out/nix-support/cygwin-buildinputs-as-runtime-deps"
15+ fi
16+}
···1+postFixupHooks+=(_cygwinWrapExesToFindDlls)
2+3+_cygwinWrapExesToFindDlls() {
4+ find $out -type l | while read LINK; do
5+ TARGET="$(readlink "${LINK}")"
6+7+ # fix all non .exe links that link explicitly to a .exe
8+ if [[ ${TARGET} == *.exe ]] && [[ ${LINK} != *.exe ]]; then
9+ mv "${LINK}" "${LINK}.exe"
10+ LINK="${LINK}.exe"
11+ fi
12+13+ # generate complementary filenames
14+ if [[ ${LINK} == *.exe ]]; then
15+ _LINK="${LINK%.exe}"
16+ _TARGET="${TARGET%.exe}"
17+ else
18+ _LINK="${LINK}.exe"
19+ _TARGET="${TARGET}.exe"
20+ fi
21+22+ # check if sould create complementary link
23+ DOLINK=1
24+ if [[ ${_TARGET} == *.exe ]]; then
25+ # the canonical target has to be a .exe
26+ CTARGET="$(readlink -f "${LINK}")"
27+ if [[ ${CTARGET} != *.exe ]]; then
28+ CTARGET="${CTARGET}.exe"
29+ fi
30+31+ if [ ! -e "${CTARGET}" ]; then
32+ unset DOLINK
33+ fi
34+ fi
35+36+ if [ -e "${_LINK}" ]; then
37+ # complementary link seems to exist
38+ # but could be cygwin smoke and mirrors
39+ INO=$(stat -c%i "${LINK}")
40+ _INO=$(stat -c%i "${_LINK}")
41+ if [ "${INO}" -ne "${_INO}" ]; then
42+ unset DOLINK
43+ fi
44+ fi
45+46+ # create complementary link
47+ if [ -n "${DOLINK}" ]; then
48+ ln -s "${_TARGET}" "${_LINK}.tmp"
49+ mv "${_LINK}.tmp" "${_LINK}"
50+ fi
51+ done
52+53+ find $out -type f -name "*.exe" | while read EXE; do
54+ WRAPPER="${EXE%.exe}"
55+ if [ -e "${WRAPPER}" ]; then
56+ # check if really exists or cygwin smoke and mirrors
57+ INO=$(stat -c%i "${EXE}")
58+ _INO=$(stat -c%i "${WRAPPER}")
59+ if [ "${INO}" -ne "${_INO}" ]; then
60+ continue
61+ fi
62+ fi
63+64+ mv "${EXE}" "${EXE}.tmp"
65+66+ cat >"${WRAPPER}" <<EOF
67+#!/bin/sh
68+export PATH=$_PATH${_PATH:+:}\${PATH}
69+exec "\$0.exe" "\$@"
70+EOF
71+ chmod +x "${WRAPPER}"
72+ mv "${EXE}.tmp" "${EXE}"
73+ done
74+}
+2
pkgs/stdenv/default.nix
···50 if system == "powerpc-linux" then /* stdenvLinux */ stdenvNative else
51 if system == "x86_64-darwin" then stdenvDarwin else
52 if system == "x86_64-solaris" then stdenvNix else
0053 stdenvNative;
54}
···50 if system == "powerpc-linux" then /* stdenvLinux */ stdenvNative else
51 if system == "x86_64-darwin" then stdenvDarwin else
52 if system == "x86_64-solaris" then stdenvNix else
53+ if system == "i686-cygwin" then stdenvNative else
54+ if system == "x86_64-cygwin" then stdenvNative else
55 stdenvNative;
56}
+3
pkgs/stdenv/generic/default.nix
···210 || system == "i686-gnu"
211 || system == "i686-freebsd"
212 || system == "i686-openbsd"
0213 || system == "i386-sunos";
214 isx86_64 = system == "x86_64-linux"
215 || system == "x86_64-darwin"
216 || system == "x86_64-freebsd"
217 || system == "x86_64-openbsd"
0218 || system == "x86_64-solaris";
219 is64bit = system == "x86_64-linux"
220 || system == "x86_64-darwin"
221 || system == "x86_64-freebsd"
222 || system == "x86_64-openbsd"
0223 || system == "x86_64-solaris"
224 || system == "mips64el-linux";
225 isMips = system == "mips-linux"
···210 || system == "i686-gnu"
211 || system == "i686-freebsd"
212 || system == "i686-openbsd"
213+ || system == "i686-cygwin"
214 || system == "i386-sunos";
215 isx86_64 = system == "x86_64-linux"
216 || system == "x86_64-darwin"
217 || system == "x86_64-freebsd"
218 || system == "x86_64-openbsd"
219+ || system == "x86_64-cygwin"
220 || system == "x86_64-solaris";
221 is64bit = system == "x86_64-linux"
222 || system == "x86_64-darwin"
223 || system == "x86_64-freebsd"
224 || system == "x86_64-openbsd"
225+ || system == "x86_64-cygwin"
226 || system == "x86_64-solaris"
227 || system == "mips64el-linux";
228 isMips = system == "mips-linux"
+18-5
pkgs/stdenv/native/default.nix
···52 shopt -s expand_aliases
53 '';
54055 prehookCygwin = ''
56 ${prehookBase}
5758- if test -z "$cygwinConfigureEnableShared"; then
59- export configureFlags="$configureFlags --disable-shared"
60- fi
61-62- PATH_DELIMITER=';'
63 '';
64000000006566 # A function that builds a "native" stdenv (one that uses tools in
67 # /usr etc.).
···74 if system == "x86_64-freebsd" then prehookFreeBSD else
75 if system == "i686-openbsd" then prehookOpenBSD else
76 if system == "i686-netbsd" then prehookNetBSD else
0077 prehookBase;
000007879 initialPath = extraPath ++ path;
80
···52 shopt -s expand_aliases
53 '';
5455+ # prevent libtool from failing to find dynamic libraries
56 prehookCygwin = ''
57 ${prehookBase}
5859+ shopt -s expand_aliases
60+ export lt_cv_deplibs_check_method=pass_all
00061 '';
6263+ extraBuildInputsCygwin = [
64+ ../cygwin/all-buildinputs-as-runtimedep.sh
65+ ../cygwin/wrap-exes-to-find-dlls.sh
66+ ] ++ (if system == "i686-cygwin" then [
67+ ../cygwin/rebase-i686.sh
68+ ] else if system == "x86_64-cygwin" then [
69+ ../cygwin/rebase-x86_64.sh
70+ ] else []);
7172 # A function that builds a "native" stdenv (one that uses tools in
73 # /usr etc.).
···80 if system == "x86_64-freebsd" then prehookFreeBSD else
81 if system == "i686-openbsd" then prehookOpenBSD else
82 if system == "i686-netbsd" then prehookNetBSD else
83+ if system == "i686-cygwin" then prehookCygwin else
84+ if system == "x86_64-cygwin" then prehookCygwin else
85 prehookBase;
86+87+ extraBuildInputs =
88+ if system == "i686-cygwin" then extraBuildInputsCygwin else
89+ if system == "x86_64-cygwin" then extraBuildInputsCygwin else
90+ [];
9192 initialPath = extraPath ++ path;
93
+2
pkgs/top-level/release-lib.nix
···22 else if system == "x86_64-freebsd" then pkgs_x86_64_freebsd
23 else if system == "i686-freebsd" then pkgs_i686_freebsd
24 else if system == "i686-cygwin" then pkgs_i686_cygwin
025 else abort "unsupported system type: ${system}";
2627 pkgs_x86_64_linux = allPackages { system = "x86_64-linux"; };
···30 pkgs_x86_64_freebsd = allPackages { system = "x86_64-freebsd"; };
31 pkgs_i686_freebsd = allPackages { system = "i686-freebsd"; };
32 pkgs_i686_cygwin = allPackages { system = "i686-cygwin"; };
0333435 /* The working or failing mails for cross builds will be sent only to
···22 else if system == "x86_64-freebsd" then pkgs_x86_64_freebsd
23 else if system == "i686-freebsd" then pkgs_i686_freebsd
24 else if system == "i686-cygwin" then pkgs_i686_cygwin
25+ else if system == "x86_64-cygwin" then pkgs_x86_64_cygwin
26 else abort "unsupported system type: ${system}";
2728 pkgs_x86_64_linux = allPackages { system = "x86_64-linux"; };
···31 pkgs_x86_64_freebsd = allPackages { system = "x86_64-freebsd"; };
32 pkgs_i686_freebsd = allPackages { system = "i686-freebsd"; };
33 pkgs_i686_cygwin = allPackages { system = "i686-cygwin"; };
34+ pkgs_x86_64_cygwin = allPackages { system = "x86_64-cygwin"; };
353637 /* The working or failing mails for cross builds will be sent only to