nixpkgs/pkgs/development/tools/omnisharp-roslyn/default.nix

93 lines
2.8 KiB
Nix
Raw Normal View History

{ buildDotnetModule
, dotnetCorePackages
, fetchFromGitHub
, lib
, stdenv
2022-08-15 20:06:39 +00:00
, runCommand
, expect
}:
let
inherit (dotnetCorePackages) sdk_6_0 runtime_6_0;
in
2022-08-15 20:06:39 +00:00
let finalPackage = buildDotnetModule rec {
pname = "omnisharp-roslyn";
2023-07-18 06:21:25 +00:00
version = "1.39.8";
2020-05-24 13:09:15 +00:00
src = fetchFromGitHub {
owner = "OmniSharp";
repo = pname;
rev = "v${version}";
2023-07-18 06:21:25 +00:00
hash = "sha256-QjkZg3BsI8oDeEe455GqBpM/3H3b89bRBKDjQIc8cO4=";
2019-04-11 21:45:02 +00:00
};
projectFile = "src/OmniSharp.Stdio.Driver/OmniSharp.Stdio.Driver.csproj";
nugetDeps = ./deps.nix;
dotnet-sdk = sdk_6_0;
dotnet-runtime = sdk_6_0;
dotnetInstallFlags = [ "--framework net6.0" ];
dotnetBuildFlags = [ "--framework net6.0" "--no-self-contained" ];
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"
];
2019-04-11 21:45:02 +00:00
postPatch = ''
# Relax the version requirement
2023-06-19 15:04:23 +00:00
rm global.json
# 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-12 11:35:45 +00:00
useDotnetFromEnv = true;
executables = [ "OmniSharp" ];
2022-08-15 20:06:39 +00:00
2023-03-27 20:36:05 +00:00
passthru.tests = let
with-sdk = sdk: runCommand "with-${if sdk ? version then sdk.version else "no"}-sdk"
{ nativeBuildInputs = [ finalPackage sdk expect ]; meta.timeout = 60; } ''
2022-08-15 20:06:39 +00:00
HOME=$TMPDIR
expect <<"EOF"
spawn OmniSharp
expect_before timeout {
send_error "timeout!\n"
exit 1
}
2023-03-27 20:36:05 +00:00
expect ".NET Core SDK ${if sdk ? version then sdk.version else sdk_6_0.version}"
2022-08-15 20:06:39 +00:00
expect "{\"Event\":\"started\","
send \x03
expect eof
catch wait result
exit [lindex $result 3]
EOF
touch $out
'';
2023-03-27 20:36:05 +00:00
in {
# Make sure we can run OmniSharp with any supported SDK version, as well as without
with-net6-sdk = with-sdk sdk_6_0;
with-net7-sdk = with-sdk dotnetCorePackages.sdk_7_0;
no-sdk = with-sdk null;
2022-08-15 20:06:39 +00:00
};
meta = with lib; {
2019-04-11 21:45:02 +00:00
description = "OmniSharp based on roslyn workspaces";
2020-05-24 13:09:15 +00:00
homepage = "https://github.com/OmniSharp/omnisharp-roslyn";
sourceProvenance = with sourceTypes; [
fromSource
binaryNativeCode # dependencies
];
2019-04-11 21:45:02 +00:00
license = licenses.mit;
maintainers = with maintainers; [ tesq0 ericdallo corngood mdarocha ];
mainProgram = "OmniSharp";
2019-04-11 21:45:02 +00:00
};
2022-08-15 20:06:39 +00:00
}; in finalPackage