1# Temporaririly avoid dependency on dotnetbuildhelpers to avoid rebuilding many times while working on it
2
3{ stdenv, fetchurl, pkgconfig, autoconf, automake, which, mono, dotnetbuildhelpers, dotnetPackages }:
4
5stdenv.mkDerivation rec {
6 name = "fsharp-${version}";
7 version = "4.1.7";
8
9 src = fetchurl {
10 url = "https://github.com/fsharp/fsharp/archive/${version}.tar.gz";
11 sha256 = "0rfkrk4mzi4w54mfqilvng9ar5swhmnwhsyjc54rx3fd0np3jiyl";
12 };
13
14 buildInputs = [
15 pkgconfig
16 autoconf
17 automake
18 which
19 mono
20 dotnetbuildhelpers
21 dotnetPackages.FsCheck262
22 dotnetPackages.FSharpCompilerTools
23 dotnetPackages.FSharpCore
24 dotnetPackages.FSharpData225
25 dotnetPackages.FsLexYacc704
26 dotnetPackages.MicrosoftDiaSymReader
27 dotnetPackages.MicrosoftDiaSymReaderPortablePdb
28 dotnetPackages.NUnit350
29 dotnetPackages.SystemCollectionsImmutable131
30 dotnetPackages.SystemReflectionMetadata
31 dotnetPackages.SystemValueTuple
32 ];
33
34 configurePhase = ''
35 substituteInPlace ./autogen.sh --replace "/usr/bin/env sh" "/bin/sh"
36 ./autogen.sh --prefix $out
37 '';
38
39 preBuild = ''
40 substituteInPlace Makefile --replace "MONO_ENV_OPTIONS=\$(monoopts) mono .nuget/NuGet.exe restore packages.config -PackagesDirectory packages -ConfigFile .nuget/NuGet.Config" "true"
41 substituteInPlace src/fsharp/Fsc-proto/Fsc-proto.fsproj --replace "<FSharpCoreOptSigFiles Include=\"\$(FSharpCoreLkgPath)\\FSharp.Core.dll\" />" ""
42 substituteInPlace src/fsharp/Fsc-proto/Fsc-proto.fsproj --replace "<FSharpCoreOptSigFiles Include=\"\$(FSharpCoreLkgPath)\\FSharp.Core.optdata\" />" ""
43 substituteInPlace src/fsharp/Fsc-proto/Fsc-proto.fsproj --replace "<FSharpCoreOptSigFiles Include=\"\$(FSharpCoreLkgPath)\\FSharp.Core.sigdata\" />" ""
44 substituteInPlace src/fsharp/Fsc-proto/Fsc-proto.fsproj --replace "<FSharpCoreOptSigFiles Include=\"\$(FSharpCoreLkgPath)\\FSharp.Core.xml\" />" ""
45
46 rm -rf packages
47 mkdir packages
48
49 ln -s ${dotnetPackages.FsCheck262}/lib/dotnet/FsCheck packages/FsCheck.2.6.2
50 ln -s ${dotnetPackages.FSharpCompilerTools}/lib/dotnet/FSharp.Compiler.Tools packages/FSharp.Compiler.Tools.4.1.4
51 ln -s ${dotnetPackages.FSharpCore}/lib/dotnet/FSharp.Core/ packages/FSharp.Core.4.0.0.1
52 ln -s ${dotnetPackages.FSharpData225}/lib/dotnet/FSharp.Data/ packages/FSharp.Data.2.2.5
53 ln -s ${dotnetPackages.FsLexYacc704}/lib/dotnet/FsLexYacc/ packages/FsLexYacc.7.0.4
54 ln -s ${dotnetPackages.MicrosoftDiaSymReader}/lib/dotnet/Microsoft.DiaSymReader/ packages/Microsoft.DiaSymReader.1.1.0
55 ln -s ${dotnetPackages.MicrosoftDiaSymReaderPortablePdb}/lib/dotnet/Microsoft.DiaSymReader.PortablePdb/ packages/Microsoft.DiaSymReader.PortablePdb.1.2.0
56 ln -s ${dotnetPackages.NUnit350}/lib/dotnet/NUnit/ packages/NUnit.3.5.0
57 ln -s ${dotnetPackages.SystemCollectionsImmutable131}/lib/dotnet/System.Collections.Immutable/ packages/System.Collections.Immutable.1.3.1
58 ln -s ${dotnetPackages.SystemReflectionMetadata}/lib/dotnet/System.Reflection.Metadata/ packages/System.Reflection.Metadata.1.4.2
59 ln -s ${dotnetPackages.SystemValueTuple}/lib/dotnet/System.ValueTuple/ packages/System.ValueTuple.4.3.0
60 '';
61
62 # Make sure the executables use the right mono binary,
63 # and set up some symlinks for backwards compatibility.
64 postInstall = ''
65 substituteInPlace $out/bin/fsharpc --replace " mono " " ${mono}/bin/mono "
66 substituteInPlace $out/bin/fsharpi --replace " mono " " ${mono}/bin/mono "
67 substituteInPlace $out/bin/fsharpiAnyCpu --replace " mono " " ${mono}/bin/mono "
68 ln -s $out/bin/fsharpc $out/bin/fsc
69 ln -s $out/bin/fsharpi $out/bin/fsi
70 for dll in "$out/lib/mono/fsharp"/FSharp*.dll
71 do
72 create-pkg-config-for-dll.sh "$out/lib/pkgconfig" "$dll"
73 done
74 '';
75
76 # To fix this error when running:
77 # The file "/nix/store/path/whatever.exe" is an not a valid CIL image
78 dontStrip = true;
79
80 meta = {
81 description = "A functional CLI language";
82 homepage = http://fsharp.org/;
83 license = stdenv.lib.licenses.asl20;
84 maintainers = with stdenv.lib.maintainers; [ thoughtpolice raskin ];
85 platforms = with stdenv.lib.platforms; unix;
86 };
87}