Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1# Temporaririly avoid dependency on dotnetbuildhelpers to avoid rebuilding many times while working on it
2
3{ stdenv, fetchurl, pkgconfig, autoconf, automake, which, mono, msbuild, dotnetbuildhelpers, dotnetPackages }:
4
5stdenv.mkDerivation rec {
6 pname = "fsharp";
7 version = "4.1.34";
8
9 src = fetchurl {
10 url = "https://github.com/fsharp/fsharp/archive/${version}.tar.gz";
11 sha256 = "0cv6p5pin962vhbpsji40nkckkag5c96kq5qihvg60pc1z821p0i";
12 };
13
14 nativeBuildInputs = [ pkgconfig ];
15 buildInputs = [
16 autoconf
17 automake
18 which
19 mono
20 msbuild
21 dotnetbuildhelpers
22 dotnetPackages.FsCheck262
23 dotnetPackages.FSharpCompilerTools
24 dotnetPackages.FSharpCore302
25 dotnetPackages.FSharpCore3125
26 dotnetPackages.FSharpCore4001
27 dotnetPackages.FSharpCore4117
28 dotnetPackages.FSharpData225
29 dotnetPackages.FsLexYacc706
30 dotnetPackages.MicrosoftDiaSymReader
31 dotnetPackages.MicrosoftDiaSymReaderPortablePdb
32 dotnetPackages.NUnit350
33 dotnetPackages.SystemCollectionsImmutable131
34 dotnetPackages.SystemReflectionMetadata
35 dotnetPackages.SystemValueTuple
36 ];
37
38 # https://github.com/mono/mono/tree/fe0f311a848068ab2d17a9b9dd15326e5712d520/packaging/MacSDK/patches
39 # https://github.com/mono/mono/issues/7805
40 patches = [
41 ./fsharp-IsPathRooted-type-inference.patch
42 ./fsharp-string-switchName.patch
43 ./fsharp-path-overloads.patch
44 ];
45
46 configurePhase = ''
47 substituteInPlace ./autogen.sh --replace "/usr/bin/env sh" "${stdenv.shell}"
48 ./autogen.sh --prefix $out
49 '';
50
51 preBuild = ''
52 substituteInPlace Makefile --replace "MONO_ENV_OPTIONS=\$(monoopts) mono .nuget/NuGet.exe restore packages.config -PackagesDirectory packages -ConfigFile .nuget/NuGet.Config" "true"
53 substituteInPlace src/fsharp/Fsc-proto/Fsc-proto.fsproj --replace "<FSharpCoreOptSigFiles Include=\"\$(FSharpCoreLkgPath)\\FSharp.Core.dll\" />" ""
54 substituteInPlace src/fsharp/Fsc-proto/Fsc-proto.fsproj --replace "<FSharpCoreOptSigFiles Include=\"\$(FSharpCoreLkgPath)\\FSharp.Core.optdata\" />" ""
55 substituteInPlace src/fsharp/Fsc-proto/Fsc-proto.fsproj --replace "<FSharpCoreOptSigFiles Include=\"\$(FSharpCoreLkgPath)\\FSharp.Core.sigdata\" />" ""
56 substituteInPlace src/fsharp/Fsc-proto/Fsc-proto.fsproj --replace "<FSharpCoreOptSigFiles Include=\"\$(FSharpCoreLkgPath)\\FSharp.Core.xml\" />" ""
57
58 rm -rf packages
59 mkdir packages
60
61 ln -s ${dotnetPackages.FsCheck262}/lib/dotnet/FsCheck packages/FsCheck.2.6.2
62 ln -s ${dotnetPackages.FSharpCompilerTools}/lib/dotnet/FSharp.Compiler.Tools packages/FSharp.Compiler.Tools.4.1.27
63 ln -s ${dotnetPackages.FSharpCore302}/lib/dotnet/FSharp.Core/ packages/FSharp.Core.3.0.2
64 ln -s ${dotnetPackages.FSharpCore3125}/lib/dotnet/FSharp.Core/ packages/FSharp.Core.3.1.2.5
65 ln -s ${dotnetPackages.FSharpCore4001}/lib/dotnet/FSharp.Core/ packages/FSharp.Core.4.0.0.1
66 ln -s ${dotnetPackages.FSharpCore4117}/lib/dotnet/FSharp.Core/ packages/FSharp.Core.4.1.17
67 ln -s ${dotnetPackages.FSharpData225}/lib/dotnet/FSharp.Data/ packages/FSharp.Data.2.2.5
68 ln -s ${dotnetPackages.FsLexYacc706}/lib/dotnet/FsLexYacc/ packages/FsLexYacc.7.0.6
69 ln -s ${dotnetPackages.MicrosoftDiaSymReader}/lib/dotnet/Microsoft.DiaSymReader/ packages/Microsoft.DiaSymReader.1.1.0
70 ln -s ${dotnetPackages.MicrosoftDiaSymReaderPortablePdb}/lib/dotnet/Microsoft.DiaSymReader.PortablePdb/ packages/Microsoft.DiaSymReader.PortablePdb.1.2.0
71 ln -s ${dotnetPackages.NUnit350}/lib/dotnet/NUnit/ packages/NUnit.3.5.0
72 ln -s ${dotnetPackages.SystemCollectionsImmutable131}/lib/dotnet/System.Collections.Immutable/ packages/System.Collections.Immutable.1.3.1
73 ln -s ${dotnetPackages.SystemReflectionMetadata}/lib/dotnet/System.Reflection.Metadata/ packages/System.Reflection.Metadata.1.4.2
74 ln -s ${dotnetPackages.SystemValueTuple}/lib/dotnet/System.ValueTuple/ packages/System.ValueTuple.4.3.1
75 '';
76
77 # Signing /home/jdanek/nix/nixpkgs/build/fss/fsharp-4.1.34/again/fsharp-4.1.34/Release/fsharp30/net40/bin/FSharp.Core.dll with Mono key
78 # ERROR: Unknown error during processing: System.UnauthorizedAccessException: Access to the path
79 # "Release/fsharp30/net40/bin/FSharp.Core.dll" is denied.
80 preInstall = ''
81 find Release/ -name FSharp.Core.dll -exec chmod u+w {} \;
82 '';
83
84 # Set up some symlinks for backwards compatibility.
85 postInstall = ''
86 ln -s $out/bin/fsharpc $out/bin/fsc
87 ln -s $out/bin/fsharpi $out/bin/fsi
88 for dll in "$out/lib/mono/fsharp"/FSharp*.dll
89 do
90 create-pkg-config-for-dll.sh "$out/lib/pkgconfig" "$dll"
91 done
92 '';
93
94 doInstallCheck = true;
95 installCheckPhase = ''
96 echo 'printf "int = %i" (6 * 7);;' > script.fsx
97 $out/bin/fsi --exec script.fsx | grep "int = 42"
98 $out/bin/fsharpi --exec script.fsx | grep "int = 42"
99 $out/bin/fsharpiAnyCpu --exec script.fsx | grep "int = 42"
100
101 cat > answer.fs <<EOF
102open System
103
104[<EntryPoint>]
105let main argv =
106 printfn "int = %i" (6 * 7)
107 0
108EOF
109
110 $out/bin/fsc answer.fs
111 ${mono}/bin/mono answer.exe | grep "int = 42"
112 '';
113
114 # To fix this error when running:
115 # The file "/nix/store/path/whatever.exe" is an not a valid CIL image
116 dontStrip = true;
117
118 meta = {
119 description = "A functional CLI language";
120 homepage = https://fsharp.org/;
121 license = stdenv.lib.licenses.asl20;
122 maintainers = with stdenv.lib.maintainers; [ thoughtpolice raskin ];
123 platforms = with stdenv.lib.platforms; unix;
124 };
125}