12 inherit (dotnetCorePackages) sdk_6_0 runtime_6_0;
14 let finalPackage = buildDotnetModule rec {
15 pname = "omnisharp-roslyn";
18 src = fetchFromGitHub {
22 sha256 = "Fd9fS5iSEynZfRwZexDlVndE/zSZdUdugR0VgXXAdmI=";
25 projectFile = "src/OmniSharp.Stdio.Driver/OmniSharp.Stdio.Driver.csproj";
26 nugetDeps = ./deps.nix;
32 dotnetInstallFlags = [ "--framework net6.0" ];
33 dotnetBuildFlags = [ "--framework net6.0" ];
35 # These flags are set by the cake build.
36 "-property:PackageVersion=${version}"
37 "-property:AssemblyVersion=${version}.0"
38 "-property:FileVersion=${version}.0"
39 "-property:InformationalVersion=${version}"
40 "-property:RuntimeFrameworkVersion=${runtime_6_0.version}"
41 "-property:RollForward=LatestMajor"
45 # Relax the version requirement
46 substituteInPlace global.json \
47 --replace '7.0.100-preview.4.22252.9' '${sdk_6_0.version}'
48 # Patch the project files so we can compile them properly
49 for project in src/OmniSharp.Http.Driver/OmniSharp.Http.Driver.csproj src/OmniSharp.LanguageServerProtocol/OmniSharp.LanguageServerProtocol.csproj src/OmniSharp.Stdio.Driver/OmniSharp.Stdio.Driver.csproj; do
50 substituteInPlace $project \
51 --replace '<RuntimeIdentifiers>win7-x64;win7-x86;win10-arm64</RuntimeIdentifiers>' '<RuntimeIdentifiers>linux-x64;linux-arm64;osx-x64;osx-arm64</RuntimeIdentifiers>'
55 dontDotnetFixup = true; # we'll fix it ourselves
56 postFixup = lib.optionalString stdenv.isLinux ''
57 # Emulate what .NET 7 does to its binaries while a fix doesn't land in buildDotnetModule
58 patchelf --set-interpreter $(patchelf --print-interpreter ${sdk_6_0}/dotnet) \
59 --set-rpath $(patchelf --print-rpath ${sdk_6_0}/dotnet) \
60 $out/lib/omnisharp-roslyn/OmniSharp
63 # Now create a wrapper without DOTNET_ROOT
64 # we explicitly don't set DOTNET_ROOT as it should get the one from PATH
65 # as you can use any .NET SDK higher than 6 to run OmniSharp and you most
66 # likely will NOT want the .NET 6 runtime running it (as it'll use that to
67 # detect the SDKs for its own use, so it's better to let it find it in PATH).
68 makeWrapper $out/lib/omnisharp-roslyn/OmniSharp $out/bin/OmniSharp \
69 --prefix LD_LIBRARY_PATH : ${sdk_6_0.icu}/lib \
70 --set-default DOTNET_ROOT ${sdk_6_0}
72 # Delete files to mimick hacks in https://github.com/OmniSharp/omnisharp-roslyn/blob/bdc14ca/build.cake#L594
73 rm $out/lib/omnisharp-roslyn/NuGet.*.dll
74 rm $out/lib/omnisharp-roslyn/System.Configuration.ConfigurationManager.dll
78 no-sdk = runCommand "no-sdk" { nativeBuildInputs = [ finalPackage expect ]; meta.timeout = 60; } ''
82 expect_before timeout {
83 send_error "timeout!\n"
86 expect "\"ERROR\",\"Name\":\"OmniSharp.MSBuild.Discovery.Providers.SdkInstanceProvider\""
89 if { [lindex $result 3] == 0 } {
96 with-sdk = runCommand "with-sdk" { nativeBuildInputs = [ finalPackage sdk_6_0 expect ]; meta.timeout = 60; } ''
100 expect_before timeout {
101 send_error "timeout!\n"
104 expect "{\"Event\":\"started\","
108 exit [lindex $result 3]
115 description = "OmniSharp based on roslyn workspaces";
116 homepage = "https://github.com/OmniSharp/omnisharp-roslyn";
117 sourceProvenance = with sourceTypes; [
119 binaryNativeCode # dependencies
121 license = licenses.mit;
122 maintainers = with maintainers; [ tesq0 ericdallo corngood mdarocha ];
123 mainProgram = "OmniSharp";