Skip to content

Commit

Permalink
mono: 4.6.0.182 -> 4.8.0.495
Browse files Browse the repository at this point in the history
Bundled LLVM: 3.4svn-mono-f9b1a74368 -> 3.6-mono-2017-02-15

Remove old Mono versions.
Add options to enable GTK, SVG and printing support.
Build reference assemblies from source (essentially Mono 3.12.1 stripped from actual method bodies).
Add headless version.

Should improve support of color schemas in Windows Forms.
  • Loading branch information
abbradar committed Mar 3, 2017
1 parent 91c0815 commit d27768a
Show file tree
Hide file tree
Showing 10 changed files with 203 additions and 162 deletions.
6 changes: 0 additions & 6 deletions pkgs/development/compilers/mono/4.0.nix

This file was deleted.

7 changes: 0 additions & 7 deletions pkgs/development/compilers/mono/4.4.nix

This file was deleted.

7 changes: 0 additions & 7 deletions pkgs/development/compilers/mono/4.6.nix

This file was deleted.

12 changes: 0 additions & 12 deletions pkgs/development/compilers/mono/build-fix-llvm.patch

This file was deleted.

125 changes: 125 additions & 0 deletions 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 ?
};
}
89 changes: 0 additions & 89 deletions pkgs/development/compilers/mono/generic.nix

This file was deleted.

37 changes: 11 additions & 26 deletions 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 ];

Expand All @@ -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;
Expand Down
58 changes: 58 additions & 0 deletions 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 ?
};
}
6 changes: 3 additions & 3 deletions 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}";
Expand All @@ -14,7 +14,7 @@ stdenv.mkDerivation rec {
makeWrapper
];
propagatedBuildInputs = with pkgs; [
mono46
mono
sqlite
];

Expand All @@ -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"
'';

Expand Down

0 comments on commit d27768a

Please sign in to comment.