29 enableParallelBuilding ? true,
30 srcArchiveSuffix ? "tar.bz2",
35 llvm = callPackage ./llvm.nix { };
37 stdenv.mkDerivation rec {
43 url = "https://download.mono-project.com/sources/mono/${pname}-${version}.${srcArchiveSuffix}";
69 ++ lib.optionals stdenv.hostPlatform.isDarwin [
76 "--x-includes=${libX11.dev}/include"
77 "--x-libraries=${libX11.out}/lib"
78 "--with-libgdiplus=${libgdiplus}/lib/libgdiplus.so"
80 ++ lib.optionals withLLVM [
86 patchShebangs autogen.sh mcs/build/start-compiler-server.sh
87 ./autogen.sh --prefix $out $configureFlags
90 # We want pkg-config to take priority over the dlls in the Mono framework and the GAC
91 # because we control pkg-config
92 patches = [ ./pkgconfig-before-gac.patch ] ++ extraPatches;
94 # Patch all the necessary scripts. Also, if we're using LLVM, we fix the default
95 # LLVM path to point into the Mono LLVM build, since it's private anyway.
98 makeFlagsArray=(INSTALL=`type -tp install`)
99 substituteInPlace mcs/class/corlib/System/Environment.cs --replace /usr/share "$out/share"
101 + lib.optionalString withLLVM ''
102 substituteInPlace mono/mini/aot-compiler.c --replace "llvm_path = g_strdup (\"\")" "llvm_path = g_strdup (\"${llvm}/bin/\")"
105 # Fix mono DLLMap so it can find libX11 to run winforms apps
106 # libgdiplus is correctly handled by the --with-libgdiplus configure flag
107 # Other items in the DLLMap may need to be pointed to their store locations, I don't think this is exhaustive
108 # https://www.mono-project.com/Config_DllMap
110 find . -name 'config' -type f | xargs \
111 sed -i -e "s@libX11.so.6@${libX11.out}/lib/libX11.so.6@g"
114 # Without this, any Mono application attempting to open an SSL connection will throw with
115 # The authentication or decryption has failed.
116 # ---> Mono.Security.Protocol.Tls.TlsException: Invalid certificate received from server.
119 echo "Updating Mono key store"
120 $out/bin/cert-sync ${cacert}/etc/ssl/certs/ca-bundle.crt
122 # According to [1], gmcs is just mcs
123 # [1] https://github.com/mono/mono/blob/master/scripts/gmcs.in
125 ln -s $out/bin/mcs $out/bin/gmcs
128 inherit enableParallelBuilding;
131 # Per nixpkgs#151720 the build failures for aarch64-darwin are fixed since 6.12.0.129
133 stdenv.hostPlatform.isDarwin
134 && stdenv.hostPlatform.isAarch64
135 && lib.versionOlder version "6.12.0.129";
136 homepage = "https://mono-project.com/";
137 description = "Cross platform, open source .NET development framework";
138 platforms = with platforms; darwin ++ linux;
139 maintainers = with maintainers; [
143 license = with licenses; [
144 # runtime, compilers, tools and most class libraries licensed
146 # runtime includes some code licensed
148 # mcs/class/I18N/mklist.sh marked GPLv2 and others just GPL
150 # RabbitMQ.Client class libraries dual licensed
153 # mcs/class/System.Core/System/TimeZoneInfo.Android.cs
157 # https://www.mono-project.com/docs/faq/licensing/
158 # https://github.com/mono/mono/blob/main/LICENSE
160 mainProgram = "mono";