diff --git a/pkgs/stdenv/mingw/default.nix b/pkgs/stdenv/mingw/default.nix index 515e56eb12a..77f3cbc11b4 100644 --- a/pkgs/stdenv/mingw/default.nix +++ b/pkgs/stdenv/mingw/default.nix @@ -8,29 +8,98 @@ {system} : let { + body = + stdenvFinal; + /** - * Initial standard environment based on native cygwin tools. + * Initial standard environment based on native Cygwin tools. */ stdenvInit1 = import ./simple-stdenv { inherit system; - name = "stdenv-initial-cygwin"; + name = "stdenv-init1-mingw"; shell = "/bin/bash.exe"; path = ["/usr/bin" "/bin"]; }; /** * Initial standard environment based on MSYS tools. - * From this point, Cygwin should no longer by involved. */ stdenvInit2 = import ./simple-stdenv { inherit system; - name = "stdenv-initial-msys"; - shell = msys + /bin/sh.exe; + name = "stdenv-init2-mingw"; + shell = msysShell; path = [(msys + /bin)]; }; + /** + * Initial standard environment with the most basic MinGW packages. + */ + stdenvInit3 = + (import ./simple-stdenv) { + inherit system; + name = "stdenv-init3-mingw"; + shell = msysShell; + path = [ (make + /bin) (msys + /bin) (binutils /bin) (gccCore + /bin) ]; + }; + + /** + * Final standard environment, based on generic stdenv. + * It would be better to make the generic stdenv usable on + * MINGW (i.e. make all environment variables CAPS). + */ + stdenvFinal = + let { + body = + stdenv // mkDerivationFun; + + shell = + msys + /bin/sh + ".exe"; + + gccWrapper = (import ../../build-support/gcc-wrapper) { + name = "mingw-gcc-wrapper"; + nativeTools = false; + nativeGlibc = true; + shell = msysShell; + binutils = binutils; + gcc = gccCore // { langC = true; langCC = false; langF77 = false; }; + + /** + * Tricky: gcc-wrapper cannot be constructed using the MSYS shell + * so we use the Cygwin shell. + */ + stdenv = stdenvInit1; + }; + + stdenv = + stdenvInit2.mkDerivation { + name = "stdenv-mingw"; + builder = ./builder.sh; + substitute = ../../build-support/substitute/substitute.sh; + setup = ./setup.sh; + initialPath = [make msys]; + gcc = gccWrapper; + shell = msysShell; + }; + + mkDerivationFun = { + mkDerivation = attrs: + (derivation ( + (removeAttrs attrs ["meta"]) + // + { + builder = if attrs ? realBuilder then attrs.realBuilder else shell; + args = if attrs ? args then attrs.args else + ["-e" (if attrs ? builder then attrs.builder else ../generic/default-builder.sh)]; + inherit stdenv system; + }) + ) + // { meta = if attrs ? meta then attrs.meta else {}; }; + }; + }; + + /** * Fetchurl, based on Cygwin curl in stdenvInit1 */ @@ -61,64 +130,26 @@ let { }; }; - /** - * Complete standard environment, based on generic stdenv. - * It would be better to make the generic stdenv usable on - * MINGW (i.e. make all environment variables CAPS). - */ - body = - let { - body = - stdenv // mkDerivationFun; + msysShell = + msys + /bin/sh + ".exe"; - shell = msys + /bin/sh + ".exe"; + gccCore = + (import ./pkgs).gccCore { + stdenv = stdenvInit2; + inherit fetchurl; + }; - binpkgs = - (import ./pkgs) { - stdenv = stdenvInit2; - inherit fetchurl; - }; + make = + (import ./pkgs).make { + stdenv = stdenvInit2; + inherit fetchurl; + }; - gcc = (import ../../build-support/gcc-wrapper) { - name = "mingw-gcc-wrapper"; - nativeTools = false; - nativeGlibc = true; - inherit shell; # Note: this is the MSYS shell. - binutils = binpkgs.binutils; - gcc = binpkgs.gccCore // { langC = true; langCC = false; langF77 = false; }; - - /** - * Tricky: gcc-wrapper cannot be constructed using the MSYS shell - * so we use the Cygwin shell. - */ - stdenv = stdenvInit1; - }; - - stdenv = - stdenvInit2.mkDerivation { - name = "stdenv-mingw"; - builder = ./builder.sh; - substitute = ../../build-support/substitute/substitute.sh; - setup = ./setup.sh; - initialPath = [binpkgs.make msys]; - inherit shell gcc; - }; - - mkDerivationFun = { - mkDerivation = attrs: - (derivation ( - (removeAttrs attrs ["meta"]) - // - { - builder = if attrs ? realBuilder then attrs.realBuilder else shell; - args = if attrs ? args then attrs.args else - ["-e" (if attrs ? builder then attrs.builder else ../generic/default-builder.sh)]; - inherit stdenv system; - }) - ) - // { meta = if attrs ? meta then attrs.meta else {}; }; - }; - }; + binutils = + (import ./pkgs).binutils { + stdenv = stdenvInit2; + inherit fetchurl; + }; } /* diff --git a/pkgs/stdenv/mingw/pkgs/default.nix b/pkgs/stdenv/mingw/pkgs/default.nix index 45c1ca40955..59794fc3224 100755 --- a/pkgs/stdenv/mingw/pkgs/default.nix +++ b/pkgs/stdenv/mingw/pkgs/default.nix @@ -1,17 +1,7 @@ /** * MinGW packages. */ -let { - - /** - * stdenv and fetchurl are parameters of every function to make this more flexible: - * after some packages, we might be able to use a better stdenv/fetchurl. - */ - body = {stdenv, fetchurl} : { - make = make { inherit stdenv fetchurl; }; - gccCore = gccCore { inherit stdenv fetchurl; }; - binutils = binutils { inherit stdenv fetchurl; }; - }; +rec { /** * Make. Binary. @@ -55,6 +45,19 @@ let { }; }; + /** + * MinGW Runtime. Source. + */ + mingwRuntime = {stdenv, fetchurl} : + stdenv.mkDerivation { + name = "mingw-runtime-3.10"; + src = + fetchurl { + url = http://surfnet.dl.sourceforge.net/sourceforge/mingw/mingw-runtime-3.10-src.tar.gz; + md5 = "9225684e663eafa900b4075731c25f4c"; + }; + }; + /* pkgs.coreutils pkgs.findutils diff --git a/pkgs/stdenv/mingw/setup.sh b/pkgs/stdenv/mingw/setup.sh index c8882212cda..dd8b4605de0 100755 --- a/pkgs/stdenv/mingw/setup.sh +++ b/pkgs/stdenv/mingw/setup.sh @@ -2,6 +2,16 @@ set -e test -z $NIX_GCC && NIX_GCC=@GCC@ +# Workaround MSYS shell problem +if test -z "$out"; then + out="$OUT" + src="$SRC" + srcs="$SRCS" + buildInputs="$BUILDINPUTS" + propagatedBuildInputs="$PROPAGATEDBUILDINPUTS" + succeedOnFailure="$SUCCEEDONFAILURE" +fi + # Set up the initial path. PATH= for i in $NIX_GCC @INITIALPATH@; do