diff --git a/pkgs/development/compilers/mono/4.0.nix b/pkgs/development/compilers/mono/4.0.nix deleted file mode 100644 index 8621751e5a14dc..00000000000000 --- a/pkgs/development/compilers/mono/4.0.nix +++ /dev/null @@ -1,6 +0,0 @@ -{ stdenv, callPackage, Foundation, libobjc }: -callPackage ./generic.nix (rec { - inherit Foundation libobjc; - version = "4.0.4.1"; - sha256 = "1ydw9l89apc9p7xr5mdzy0h97g2q6v243g82mxswfc2rrqhfs4gd"; -}) diff --git a/pkgs/development/compilers/mono/4.4.nix b/pkgs/development/compilers/mono/4.4.nix deleted file mode 100644 index 1ec679e6e41bdb..00000000000000 --- a/pkgs/development/compilers/mono/4.4.nix +++ /dev/null @@ -1,7 +0,0 @@ -{ stdenv, callPackage, Foundation, libobjc }: - -callPackage ./generic.nix (rec { - inherit Foundation libobjc; - version = "4.4.2.11"; - sha256 = "0cxnypw1j7s253wr5hy05k42ghgg2s9qibp10kndwnp5bv12q34h"; -}) diff --git a/pkgs/development/compilers/mono/4.6.nix b/pkgs/development/compilers/mono/4.6.nix deleted file mode 100644 index 03ccd776c600df..00000000000000 --- a/pkgs/development/compilers/mono/4.6.nix +++ /dev/null @@ -1,7 +0,0 @@ -{ stdenv, callPackage, Foundation, libobjc }: - -callPackage ./generic.nix (rec { - inherit Foundation libobjc; - version = "4.6.0.182"; - sha256 = "1sajwl7fqhkcmh697qqjj4z6amzkay7xf7npsvpm10gm071s5qi6"; -}) diff --git a/pkgs/development/compilers/mono/build-fix-llvm.patch b/pkgs/development/compilers/mono/build-fix-llvm.patch deleted file mode 100644 index 526986ad12c74f..00000000000000 --- a/pkgs/development/compilers/mono/build-fix-llvm.patch +++ /dev/null @@ -1,12 +0,0 @@ -diff --git a/lib/CodeGen/AsmPrinter/CMakeLists.txt.old b/lib/CodeGen/AsmPrinter/CMakeLists.txt -index be484a6..c92ff46 100644 ---- a/lib/CodeGen/AsmPrinter/CMakeLists.txt.old -+++ b/lib/CodeGen/AsmPrinter/CMakeLists.txt -@@ -10,6 +10,7 @@ add_llvm_library(LLVMAsmPrinter - DwarfCompileUnit.cpp - DwarfDebug.cpp - DwarfException.cpp -+ DwarfMonoException.cpp - ErlangGCPrinter.cpp - OcamlGCPrinter.cpp - Win64Exception.cpp diff --git a/pkgs/development/compilers/mono/default.nix b/pkgs/development/compilers/mono/default.nix new file mode 100644 index 00000000000000..289b032da24163 --- /dev/null +++ b/pkgs/development/compilers/mono/default.nix @@ -0,0 +1,125 @@ +{ stdenv, lib, fetchurl, fetchpatch, callPackage, cmake, bison, pkgconfig, perl, python2 +, gettext, ncurses, zlib, cacert +, Foundation, libobjc +, withX11 ? true, libgdiplus, libX11, libXinerama, cairo, glib, gtk2, gdk_pixbuf, librsvg +, withCUPS ? stdenv.isLinux, cups +, withALSA ? stdenv.isLinux, alsaLib +, withLLVM ? !stdenv.isDarwin +}: + +let + llvm = callPackage ./llvm.nix { }; + reference-assemblies = callPackage ./reference-assemblies.nix { + inherit libobjc Foundation; + }; +in +stdenv.mkDerivation rec { + name = "mono-${version}"; + version = "4.8.0.495"; + + src = fetchurl { + url = "http://download.mono-project.com/sources/mono/${name}.tar.bz2"; + sha256 = "1jr0l7g1ffgp6piy28bfdiyrgix9n8fgq6bs8kf5i7am89pjx9kv"; + }; + + #nativeBuildInputs = [ bison pkgconfig perl python2 ]; + nativeBuildInputs = [ cmake pkgconfig perl ]; + + buildInputs = [ zlib ncurses gettext ] + ++ lib.optionals withX11 [ libgdiplus libX11 ] + ++ lib.optionals stdenv.isDarwin [ Foundation libobjc ]; + + # Fix mono DLLMap so it can find libraries for winforms apps. + # Other items in the DLLMap may need to be pointed to their store locations, I don't think this is exhaustive + # http://www.mono-project.com/docs/advanced/pinvoke/dllmap/ + sedExpressions = lib.concatMapStringsSep " " (x: "-e ${x}") ( + lib.optionals withX11 ( + [ "s,@X11@,${libX11.out}/lib/libX11.so.6,g" + "s,@XINERAMA@,${libXinerama.out}/lib/libXinerama.so.1,g" + "s,@libgdiplus_install_loc@,${libgdiplus}/lib/libgdiplus.so.0,g" + ] ++ lib.optionals stdenv.isLinux [ + "s,@GTKX11@,${gtk2}/lib/libgtk-x11-2.0.so.0,g" + "s,@GDKX11@,${gtk2}/lib/libgdk-x11-2.0.so.0,g" + "s,libgdk_pixbuf-2.0.so.0,${gdk_pixbuf}/lib/libgdk_pixbuf-2.0.so.0,g" + "s,libglib-2.0.so.0,${glib}/lib/libglib-2.0.so.0,g" + "s,librsvg-2.so.2,${librsvg}/lib/librsvg-2.so.2,g" + "s,libgobject-2.0.so.0,${glib}/lib/libgobject-2.0.so.0,g" + "s,libcairo.so.2,${cairo}/lib/libcairo.so.2,g" + ] + ) ++ lib.optional withALSA "s,libasound.so.2,${alsaLib}/lib/libasound.so.2,g" + ++ lib.optional withCUPS "s,libcups.so.2,${cups}/lib/libcups.so.2,g" + ); + + postPatch = lib.optionalString (sedExpressions != "") '' + sed -i $sedExpressions data/config.in + ''; + + dontUseCmakeConfigure = true; + + # To overcome the bug https://bugzilla.novell.com/show_bug.cgi?id=644723 + dontDisableStatic = true; + + configureFlags = lib.optionals withLLVM [ + "--enable-llvm" + "--with-llvm=${llvm}" + ]; + + # Attempt to fix this error when running "mcs --version": + # The file /nix/store/xxx-mono-2.4.2.1/lib/mscorlib.dll is an invalid CIL image + dontStrip = true; + + enableParallelBuilding = true; + + patches = [ + # We want pkg-config to take priority over the dlls in the Mono framework and the GAC + # because we control pkg-config + ./pkgconfig-before-gac.patch + # Route as much hardcoded libraries through global dllmap as possible. + (fetchpatch { + url = "https://github.com/mono/mono/commit/c6de69eb21a14b647fa2d1aab33b9d26d1a1b6a7.patch"; + sha256 = "1y0jvrdn3kh0vvj6w6r4p4apiy251sxrwrzsn04hl3jkpl8cvg17"; + }) + # Use built frameworks instead of pre-built reference assemblies. + (fetchpatch { + url = "https://anonscm.debian.org/cgit/pkg-mono/packages/mono.git/patch/?id=3cfd6a21f889eebe24e124c1e96d6d05ed722142"; + sha256 = "1y4y6sks7magxqm34m8ywi6yrgan037nzgkwhrq620sfkddialr4"; + }) + ]; + + # Patch all the necessary scripts. Also, if we're using LLVM, we fix the default + # LLVM path to point into the Mono LLVM build, since it's private anyway. + preBuild = '' + makeFlagsArray=(INSTALL=`type -tp install`) + patchShebangs ./ + substituteInPlace mcs/class/corlib/System/Environment.cs --replace /usr/share "$out/share" + '' + lib.optionalString withLLVM '' + substituteInPlace mono/mini/aot-compiler.c --replace "llvm_path = g_strdup (\"\")" "llvm_path = g_strdup (\"${llvm}/bin/\")" + ''; + + postInstall = '' + # Without this, any Mono application attempting to open an SSL connection will throw with + # The authentication or decryption has failed. + # ---> Mono.Security.Protocol.Tls.TlsException: Invalid certificate received from server. + echo "Updating Mono key store" + $out/bin/cert-sync ${cacert}/etc/ssl/certs/ca-bundle.crt + + # According to [1], gmcs is just mcs + # [1] https://github.com/mono/mono/blob/master/scripts/gmcs.in + ln -s $out/bin/mcs $out/bin/gmcs + + # Use our reference assemblies instead of pre-compiled onces. + for i in ${reference-assemblies}/lib/mono/*; do + rm -rf "$out/lib/mono/$(basename "$i")" + cp -r "$i" $out/lib/mono + done + rm -rf $out/lib/mono/4.5-api + ''; + + meta = with stdenv.lib; { + homepage = "http://mono-project.com/"; + description = "Cross platform, open source .NET development framework"; + platforms = with platforms; darwin ++ linux; + maintainers = with maintainers; [ viric thoughtpolice obadz vrthra ]; + license = licenses.free; # Combination of LGPL/X11/GPL ? + }; +} diff --git a/pkgs/development/compilers/mono/generic.nix b/pkgs/development/compilers/mono/generic.nix deleted file mode 100644 index 3bc962859e28da..00000000000000 --- a/pkgs/development/compilers/mono/generic.nix +++ /dev/null @@ -1,89 +0,0 @@ -{ stdenv, fetchurl, bison, pkgconfig, glib, gettext, perl, libgdiplus, libX11, callPackage, ncurses, zlib, withLLVM ? false, cacert, Foundation, libobjc, python, version, sha256 }: - -let - llvm = callPackage ./llvm.nix { }; -in -stdenv.mkDerivation rec { - name = "mono-${version}"; - - src = fetchurl { - inherit sha256; - url = "http://download.mono-project.com/sources/mono/${name}.tar.bz2"; - }; - - buildInputs = - [ bison pkgconfig glib gettext perl libgdiplus libX11 ncurses zlib python - ] - ++ (stdenv.lib.optionals stdenv.isDarwin [ Foundation libobjc ]); - - propagatedBuildInputs = [glib]; - - NIX_LDFLAGS = if stdenv.isDarwin then "" else "-lgcc_s" ; - - # To overcome the bug https://bugzilla.novell.com/show_bug.cgi?id=644723 - dontDisableStatic = true; - - # In fact I think this line does not help at all to what I - # wanted to achieve: have mono to find libgdiplus automatically - configureFlags = [ - "--x-includes=${libX11.dev}/include" - "--x-libraries=${libX11.out}/lib" - "--with-libgdiplus=${libgdiplus}/lib/libgdiplus.so" - ] - ++ stdenv.lib.optionals withLLVM [ - "--enable-llvm" - "--enable-llvmloaded" - "--with-llvm=${llvm}" - ]; - - # Attempt to fix this error when running "mcs --version": - # The file /nix/store/xxx-mono-2.4.2.1/lib/mscorlib.dll is an invalid CIL image - dontStrip = true; - - # Parallel building doesn't work, as shows http://hydra.nixos.org/build/2983601 - enableParallelBuilding = false; - - # We want pkg-config to take priority over the dlls in the Mono framework and the GAC - # because we control pkg-config - patches = [ ./pkgconfig-before-gac.patch ]; - - # Patch all the necessary scripts. Also, if we're using LLVM, we fix the default - # LLVM path to point into the Mono LLVM build, since it's private anyway. - preBuild = '' - makeFlagsArray=(INSTALL=`type -tp install`) - patchShebangs ./ - substituteInPlace mcs/class/corlib/System/Environment.cs --replace /usr/share "$out/share" - '' + stdenv.lib.optionalString withLLVM '' - substituteInPlace mono/mini/aot-compiler.c --replace "llvm_path = g_strdup (\"\")" "llvm_path = g_strdup (\"${llvm}/bin/\")" - ''; - - # Fix mono DLLMap so it can find libX11 and gdiplus to run winforms apps - # Other items in the DLLMap may need to be pointed to their store locations, I don't think this is exhaustive - # http://www.mono-project.com/Config_DllMap - postBuild = '' - find . -name 'config' -type f | xargs \ - sed -i -e "s@libX11.so.6@${libX11.out}/lib/libX11.so.6@g" \ - -e "s@/.*libgdiplus.so@${libgdiplus}/lib/libgdiplus.so@g" \ - ''; - - # Without this, any Mono application attempting to open an SSL connection will throw with - # The authentication or decryption has failed. - # ---> Mono.Security.Protocol.Tls.TlsException: Invalid certificate received from server. - postInstall = '' - echo "Updating Mono key store" - $out/bin/cert-sync ${cacert}/etc/ssl/certs/ca-bundle.crt - '' - # According to [1], gmcs is just mcs - # [1] https://github.com/mono/mono/blob/master/scripts/gmcs.in - + '' - ln -s $out/bin/mcs $out/bin/gmcs - ''; - - meta = { - homepage = http://mono-project.com/; - description = "Cross platform, open source .NET development framework"; - platforms = with stdenv.lib.platforms; darwin ++ linux; - maintainers = with stdenv.lib.maintainers; [ viric thoughtpolice obadz vrthra ]; - license = stdenv.lib.licenses.free; # Combination of LGPL/X11/GPL ? - }; -} diff --git a/pkgs/development/compilers/mono/llvm.nix b/pkgs/development/compilers/mono/llvm.nix index 1036e43ea941bf..37596d180b07f6 100644 --- a/pkgs/development/compilers/mono/llvm.nix +++ b/pkgs/development/compilers/mono/llvm.nix @@ -1,35 +1,21 @@ -{ stdenv -, fetchurl -, perl -, groff -, cmake -, python -, libffi -, binutils -, libxml2 -, valgrind -, ncurses -, zlib +{ stdenv, lib, fetchFromGitHub, groff, cmake, python2, perl +, libffi, binutils, libxml2, valgrind, ncurses, zlib }: stdenv.mkDerivation rec { name = "llvm-${version}"; - version = "3.4svn-mono-f9b1a74368"; - src = fetchurl { - # from the HEAD of the 'mono3' branch - url = "https://github.com/mono/llvm/archive/f9b1a74368ec299fc04c4cfef4b5aa0992b7b806.tar.gz"; - name = "${name}.tar.gz"; - sha256 = "1bbkx4p5zdnk3nbdd5jxvbwqx8cdq8z1n1nhf639i98mggs0zhdg"; + version = "3.6-mono-2017-02-15"; + + src = fetchFromGitHub { + owner = "mono"; + repo = "llvm"; + rev = "dbb6fdffdeb780d11851a6be77c209bd7ada4bd3"; + sha256 = "07wd1cs3fdvzb1lv41b655z5zk34f47j8fgd9ljjimi5j9pj71f7"; }; - patches = [ ./build-fix-llvm.patch ]; - unpackPhase = '' - unpackFile ${src} - mv llvm-* llvm - sourceRoot=$PWD/llvm - ''; + #patches = [ ./build-fix-llvm.patch ]; - buildInputs = [ perl groff cmake libxml2 python libffi ] ++ stdenv.lib.optional stdenv.isLinux valgrind; + buildInputs = [ perl groff cmake libxml2 python2 libffi ] ++ lib.optional stdenv.isLinux valgrind; propagatedBuildInputs = [ ncurses zlib ]; @@ -43,7 +29,6 @@ stdenv.mkDerivation rec { cmakeFlags = with stdenv; [ "-DLLVM_ENABLE_FFI=ON" "-DLLVM_BINUTILS_INCDIR=${binutils.dev}/include" - "-DCMAKE_CXX_FLAGS=-std=c++11" ] ++ stdenv.lib.optional (!isDarwin) "-DBUILD_SHARED_LIBS=ON"; enableParallelBuilding = true; diff --git a/pkgs/development/compilers/mono/reference-assemblies.nix b/pkgs/development/compilers/mono/reference-assemblies.nix new file mode 100644 index 00000000000000..8ae6da4afccdeb --- /dev/null +++ b/pkgs/development/compilers/mono/reference-assemblies.nix @@ -0,0 +1,58 @@ +{ stdenv, lib, fetchurl, callPackage, pkgconfig, perl +, gettext, ncurses, zlib +, Foundation, libobjc }: + +stdenv.mkDerivation rec { + name = "mono-reference-assemblies-${version}"; + version = "3.12.1"; + + src = fetchurl { + url = "http://download.mono-project.com/sources/mono/mono-${version}.tar.bz2"; + sha256 = "03dn68vignknzxy1rx75p16qx1ild27hixgvr5mw0j19mx9z332x"; + }; + + nativeBuildInputs = [ pkgconfig perl ]; + + buildInputs = [ zlib ncurses gettext ] + ++ lib.optionals stdenv.isDarwin [ Foundation libobjc ]; + + # Attempt to fix this error when running "mcs --version": + # The file /nix/store/xxx-mono-2.4.2.1/lib/mscorlib.dll is an invalid CIL image + dontStrip = true; + + # Parallel building doesn't work, as shows http://hydra.nixos.org/build/2983601 + enableParallelBuilding = false; + + dontAddPrefix = true; + configureFlags = [ + # Fix build; doesn't matter for API. + "--disable-boehm" "--without-sigaltstack" "--disable-system-aot" + ]; + + preConfigure = '' + configureFlags="--prefix=$PWD/builddir $configureFlags" + ''; + + # Patch all the necessary scripts. + preBuild = '' + makeFlagsArray=(INSTALL=`type -tp install`) + patchShebangs ./ + ''; + + postInstall = '' + for ver in 2.0 3.5 4.0; do + mkdir -p "$out/lib/mono/''${ver}-api" + for lib in "builddir/lib/mono/$ver/"*.dll; do + builddir/bin/mono builddir/lib/mono/4.5/mono-cil-strip.exe "$lib" "$out/lib/mono/''${ver}-api/$(basename "$lib")" + done + done + ''; + + meta = with stdenv.lib; { + homepage = "http://mono-project.com/"; + description = "Cross platform, open source .NET development framework"; + platforms = with platforms; darwin ++ linux; + maintainers = with maintainers; [ viric thoughtpolice obadz vrthra ]; + license = licenses.free; # Combination of LGPL/X11/GPL ? + }; +} diff --git a/pkgs/servers/emby/default.nix b/pkgs/servers/emby/default.nix index 340e376e9ed6fe..2d3d309cb70b6b 100644 --- a/pkgs/servers/emby/default.nix +++ b/pkgs/servers/emby/default.nix @@ -1,4 +1,4 @@ -{ stdenv, fetchurl, pkgs, unzip, sqlite, makeWrapper, mono46, ffmpeg, ... }: +{ stdenv, fetchurl, pkgs, unzip, sqlite, makeWrapper, mono, ffmpeg, ... }: stdenv.mkDerivation rec { name = "emby-${version}"; @@ -14,7 +14,7 @@ stdenv.mkDerivation rec { makeWrapper ]; propagatedBuildInputs = with pkgs; [ - mono46 + mono sqlite ]; @@ -30,7 +30,7 @@ stdenv.mkDerivation rec { mkdir -p $out/bin cp -r * $out/bin - makeWrapper "${mono46}/bin/mono" $out/bin/MediaBrowser.Server.Mono \ + makeWrapper "${mono}/bin/mono" $out/bin/MediaBrowser.Server.Mono \ --add-flags "$out/bin/MediaBrowser.Server.Mono.exe -ffmpeg ${ffmpeg}/bin/ffmpeg -ffprobe ${ffmpeg}/bin/ffprobe" ''; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 90037d3026971d..74c4646d404c98 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -5376,22 +5376,16 @@ with pkgs; mlton = callPackage ../development/compilers/mlton { }; - mono = mono40; - - mono40 = callPackage ../development/compilers/mono/4.0.nix { + mono = callPackage ../development/compilers/mono/default.nix { inherit (darwin) libobjc; inherit (darwin.apple_sdk.frameworks) Foundation; }; - mono44 = lowPrio (callPackage ../development/compilers/mono/4.4.nix { - inherit (darwin) libobjc; - inherit (darwin.apple_sdk.frameworks) Foundation; - }); - - mono46 = lowPrio (callPackage ../development/compilers/mono/4.6.nix { - inherit (darwin) libobjc; - inherit (darwin.apple_sdk.frameworks) Foundation; - }); + mono_headless = mono.override { + withX11 = false; + withCUPS = false; + withALSA = false; + }; monoDLLFixer = callPackage ../build-support/mono-dll-fixer { };