2022-08-21 13:32:41 +00:00
|
|
|
{ buildDotnetModule
|
|
|
|
, dotnetCorePackages
|
|
|
|
, fetchFromGitHub
|
|
|
|
, icu
|
|
|
|
, lib
|
|
|
|
, patchelf
|
|
|
|
, stdenv
|
2022-09-22 12:36:57 +00:00
|
|
|
, runCommand
|
|
|
|
, expect
|
2022-08-21 13:32:41 +00:00
|
|
|
}:
|
2021-07-14 22:03:04 +00:00
|
|
|
let
|
2022-10-06 18:32:54 +00:00
|
|
|
inherit (dotnetCorePackages) sdk_6_0 runtime_6_0;
|
2022-06-26 10:26:21 +00:00
|
|
|
in
|
2022-09-22 12:36:57 +00:00
|
|
|
let finalPackage = buildDotnetModule rec {
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "omnisharp-roslyn";
|
2023-02-02 18:25:31 +00:00
|
|
|
version = "1.39.4";
|
2020-05-29 06:06:01 +00:00
|
|
|
|
2021-07-14 22:03:04 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "OmniSharp";
|
|
|
|
repo = pname;
|
|
|
|
rev = "v${version}";
|
2023-02-02 18:25:31 +00:00
|
|
|
sha256 = "rX0FeURw6WMbcJOomqHFcZ9tpKO1td60/HbbVClV324=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2022-06-26 10:26:21 +00:00
|
|
|
projectFile = "src/OmniSharp.Stdio.Driver/OmniSharp.Stdio.Driver.csproj";
|
|
|
|
nugetDeps = ./deps.nix;
|
|
|
|
|
2022-08-21 13:32:41 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
patchelf
|
|
|
|
];
|
|
|
|
|
2022-06-26 10:26:21 +00:00
|
|
|
dotnetInstallFlags = [ "--framework net6.0" ];
|
2022-12-28 21:21:41 +00:00
|
|
|
dotnetBuildFlags = [ "--framework net6.0" "--no-self-contained" ];
|
2022-08-21 13:32:41 +00:00
|
|
|
dotnetFlags = [
|
|
|
|
# These flags are set by the cake build.
|
|
|
|
"-property:PackageVersion=${version}"
|
|
|
|
"-property:AssemblyVersion=${version}.0"
|
|
|
|
"-property:FileVersion=${version}.0"
|
|
|
|
"-property:InformationalVersion=${version}"
|
2022-10-06 18:32:54 +00:00
|
|
|
"-property:RuntimeFrameworkVersion=${runtime_6_0.version}"
|
2022-08-21 13:32:41 +00:00
|
|
|
"-property:RollForward=LatestMajor"
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-03-30 09:31:56 +00:00
|
|
|
postPatch = ''
|
|
|
|
# Relax the version requirement
|
|
|
|
substituteInPlace global.json \
|
2022-11-21 17:40:18 +00:00
|
|
|
--replace '7.0.100-rc.1.22431.12' '${sdk_6_0.version}'
|
2022-08-21 13:32:41 +00:00
|
|
|
# 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
|
2022-03-30 09:31:56 +00:00
|
|
|
'';
|
|
|
|
|
2022-08-21 13:32:41 +00:00
|
|
|
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}
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2022-09-22 12:36:57 +00:00
|
|
|
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
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "OmniSharp based on roslyn workspaces";
|
2020-05-29 06:06:01 +00:00
|
|
|
homepage = "https://github.com/OmniSharp/omnisharp-roslyn";
|
2022-06-26 10:26:21 +00:00
|
|
|
sourceProvenance = with sourceTypes; [
|
|
|
|
fromSource
|
2022-08-21 13:32:41 +00:00
|
|
|
binaryNativeCode # dependencies
|
2022-06-26 10:26:21 +00:00
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
license = licenses.mit;
|
2022-06-26 10:26:21 +00:00
|
|
|
maintainers = with maintainers; [ tesq0 ericdallo corngood mdarocha ];
|
|
|
|
mainProgram = "OmniSharp";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
2022-09-22 12:36:57 +00:00
|
|
|
}; in finalPackage
|