blob: 88e7fa690db655f00ff818586f550412637b08cf (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
{ buildDotnetModule
, dotnetCorePackages
, fetchFromGitHub
, icu
, lib
, patchelf
, stdenv
, runCommand
, expect
}:
let
inherit (dotnetCorePackages) sdk_6_0 runtime_6_0;
in
let finalPackage = buildDotnetModule rec {
pname = "omnisharp-roslyn";
version = "1.39.2";
src = fetchFromGitHub {
owner = "OmniSharp";
repo = pname;
rev = "v${version}";
sha256 = "/MxBdMjPpq3Gwhi/93+JCAI+BuiiWu0n9QThQi+s/kE=";
};
projectFile = "src/OmniSharp.Stdio.Driver/OmniSharp.Stdio.Driver.csproj";
nugetDeps = ./deps.nix;
nativeBuildInputs = [
patchelf
];
dotnetInstallFlags = [ "--framework net6.0" ];
dotnetBuildFlags = [ "--framework net6.0" ];
dotnetFlags = [
# These flags are set by the cake build.
"-property:PackageVersion=${version}"
"-property:AssemblyVersion=${version}.0"
"-property:FileVersion=${version}.0"
"-property:InformationalVersion=${version}"
"-property:RuntimeFrameworkVersion=${runtime_6_0.version}"
"-property:RollForward=LatestMajor"
];
postPatch = ''
# Relax the version requirement
substituteInPlace global.json \
--replace '7.0.100-rc.1.22431.12' '${sdk_6_0.version}'
# Patch the project files so we can compile them properly
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
substituteInPlace $project \
--replace '<RuntimeIdentifiers>win7-x64;win7-x86;win10-arm64</RuntimeIdentifiers>' '<RuntimeIdentifiers>linux-x64;linux-arm64;osx-x64;osx-arm64</RuntimeIdentifiers>'
done
'';
dontDotnetFixup = true; # we'll fix it ourselves
postFixup = lib.optionalString stdenv.isLinux ''
# Emulate what .NET 7 does to its binaries while a fix doesn't land in buildDotnetModule
patchelf --set-interpreter $(patchelf --print-interpreter ${sdk_6_0}/dotnet) \
--set-rpath $(patchelf --print-rpath ${sdk_6_0}/dotnet) \
$out/lib/omnisharp-roslyn/OmniSharp
'' + ''
# Now create a wrapper without DOTNET_ROOT
# we explicitly don't set DOTNET_ROOT as it should get the one from PATH
# as you can use any .NET SDK higher than 6 to run OmniSharp and you most
# likely will NOT want the .NET 6 runtime running it (as it'll use that to
# detect the SDKs for its own use, so it's better to let it find it in PATH).
makeWrapper $out/lib/omnisharp-roslyn/OmniSharp $out/bin/OmniSharp \
--prefix LD_LIBRARY_PATH : ${sdk_6_0.icu}/lib \
--set-default DOTNET_ROOT ${sdk_6_0}
'';
passthru.tests = {
no-sdk = runCommand "no-sdk" { nativeBuildInputs = [ finalPackage expect ]; meta.timeout = 60; } ''
HOME=$TMPDIR
expect <<"EOF"
spawn OmniSharp
expect_before timeout {
send_error "timeout!\n"
exit 1
}
expect "\"ERROR\",\"Name\":\"OmniSharp.MSBuild.Discovery.Providers.SdkInstanceProvider\""
expect eof
catch wait result
if { [lindex $result 3] == 0 } {
exit 1
}
EOF
touch $out
'';
with-sdk = runCommand "with-sdk" { nativeBuildInputs = [ finalPackage sdk_6_0 expect ]; meta.timeout = 60; } ''
HOME=$TMPDIR
expect <<"EOF"
spawn OmniSharp
expect_before timeout {
send_error "timeout!\n"
exit 1
}
expect "{\"Event\":\"started\","
send \x03
expect eof
catch wait result
exit [lindex $result 3]
EOF
touch $out
'';
};
meta = with lib; {
description = "OmniSharp based on roslyn workspaces";
homepage = "https://github.com/OmniSharp/omnisharp-roslyn";
sourceProvenance = with sourceTypes; [
fromSource
binaryNativeCode # dependencies
];
license = licenses.mit;
maintainers = with maintainers; [ tesq0 ericdallo corngood mdarocha ];
mainProgram = "OmniSharp";
};
}; in finalPackage
|