at master 4.0 kB view raw
1{ 2 lib, 3 stdenv, 4 bison, 5 pkg-config, 6 glib, 7 gettext, 8 perl, 9 libgdiplus, 10 libX11, 11 ncurses, 12 zlib, 13 bash, 14 cacert, 15 python3, 16 version, 17 src, 18 autoconf, 19 libtool, 20 automake, 21 cmake, 22 which, 23 gnumake42, 24 enableParallelBuilding ? true, 25 extraPatches ? [ ], 26 env ? { }, 27}: 28 29stdenv.mkDerivation (finalAttrs: { 30 pname = "mono"; 31 inherit version src env; 32 33 strictDeps = true; 34 nativeBuildInputs = [ 35 autoconf 36 automake 37 bison 38 cmake 39 libtool 40 perl 41 pkg-config 42 python3 43 which 44 gnumake42 45 gettext 46 ]; 47 buildInputs = [ 48 glib 49 gettext 50 libgdiplus 51 libX11 52 ncurses 53 zlib 54 bash 55 ]; 56 57 configureFlags = [ 58 "--x-includes=${libX11.dev}/include" 59 "--x-libraries=${libX11.out}/lib" 60 "--with-libgdiplus=${libgdiplus}/lib/libgdiplus.so" 61 ]; 62 63 configurePhase = '' 64 patchShebangs autogen.sh mcs/build/start-compiler-server.sh 65 ./autogen.sh --prefix $out $configureFlags 66 ''; 67 68 # We want pkg-config to take priority over the dlls in the Mono framework and the GAC 69 # because we control pkg-config 70 patches = [ ./pkgconfig-before-gac.patch ] ++ extraPatches; 71 72 # Patch all the necessary scripts 73 preBuild = '' 74 makeFlagsArray=(INSTALL=`type -tp install`) 75 substituteInPlace mcs/class/corlib/System/Environment.cs --replace-fail /usr/share "$out/share" 76 ''; 77 78 # Fix mono DLLMap so it can find libX11 to run winforms apps 79 # libgdiplus is correctly handled by the --with-libgdiplus configure flag 80 # Other items in the DLLMap may need to be pointed to their store locations, I don't think this is exhaustive 81 # https://www.mono-project.com/Config_DllMap 82 postBuild = '' 83 find . -name 'config' -type f | xargs \ 84 sed -i -e "s@libX11.so.6@${libX11.out}/lib/libX11.so.6@g" 85 ''; 86 87 # Without this, any Mono application attempting to open an SSL connection will throw with 88 # The authentication or decryption has failed. 89 # ---> Mono.Security.Protocol.Tls.TlsException: Invalid certificate received from server. 90 postInstall = '' 91 echo "Updating Mono key store" 92 $out/bin/cert-sync ${cacert}/etc/ssl/certs/ca-bundle.crt 93 '' 94 # According to [1], gmcs is just mcs 95 # [1] https://github.com/mono/mono/blob/master/scripts/gmcs.in 96 + '' 97 ln -s $out/bin/mcs $out/bin/gmcs 98 ''; 99 100 inherit enableParallelBuilding; 101 102 meta = with lib; { 103 # Per nixpkgs#151720 the build failures for aarch64-darwin are fixed since 6.12.0.129. 104 # Cross build is broken due to attempt to execute cert-sync built for the host. 105 broken = 106 ( 107 stdenv.hostPlatform.isDarwin 108 && stdenv.hostPlatform.isAarch64 109 && lib.versionOlder finalAttrs.version "6.12.0.129" 110 ) 111 || !stdenv.buildPlatform.canExecute stdenv.hostPlatform; 112 homepage = 113 if lib.versionOlder finalAttrs.version "6.14.0" then 114 "https://mono-project.com/" 115 else 116 "https://gitlab.winehq.org/mono/mono"; 117 description = "Cross platform, open source .NET development framework"; 118 platforms = with platforms; darwin ++ linux; 119 knownVulnerabilities = lib.optionals (lib.versionOlder finalAttrs.version "6.14.0") [ 120 '' 121 mono was archived upstream, see https://www.mono-project.com/ 122 While WineHQ has taken over development, consider using 6.14.0 or newer. 123 '' 124 ]; 125 maintainers = with maintainers; [ 126 thoughtpolice 127 obadz 128 ]; 129 license = with licenses; [ 130 # runtime, compilers, tools and most class libraries licensed 131 mit 132 # runtime includes some code licensed 133 bsd3 134 # mcs/class/I18N/mklist.sh marked GPLv2 and others just GPL 135 gpl2Only 136 # RabbitMQ.Client class libraries dual licensed 137 mpl20 138 asl20 139 # mcs/class/System.Core/System/TimeZoneInfo.Android.cs 140 asl20 141 # some documentation 142 mspl 143 # https://www.mono-project.com/docs/faq/licensing/ 144 # https://github.com/mono/mono/blob/main/LICENSE 145 ]; 146 mainProgram = "mono"; 147 }; 148})