Merge pull request #268619 from tweag/lib-descriptions
[NixPkgs.git] / pkgs / development / tools / omnisharp-roslyn / default.nix
blob0980a7edf27f5c213629b4c6b11b9e7153b3ba33
1 { buildDotnetModule
2 , dotnetCorePackages
3 , fetchFromGitHub
4 , lib
5 , stdenv
6 , runCommand
7 , expect
8 }:
9 let
10   inherit (dotnetCorePackages) sdk_6_0 runtime_6_0;
12 let finalPackage = buildDotnetModule rec {
13   pname = "omnisharp-roslyn";
14   version = "1.39.10";
16   src = fetchFromGitHub {
17     owner = "OmniSharp";
18     repo = pname;
19     rev = "v${version}";
20     hash = "sha256-3RjRFc+keNLazUS5nLG1ZE7SfVCWoQDti2CCnnSPPQ0=";
21   };
23   projectFile = "src/OmniSharp.Stdio.Driver/OmniSharp.Stdio.Driver.csproj";
24   nugetDeps = ./deps.nix;
26   dotnet-sdk = sdk_6_0;
27   dotnet-runtime = sdk_6_0;
29   dotnetInstallFlags = [ "--framework net6.0" ];
30   dotnetBuildFlags = [ "--framework net6.0" "--no-self-contained" ];
31   dotnetFlags = [
32     # These flags are set by the cake build.
33     "-property:PackageVersion=${version}"
34     "-property:AssemblyVersion=${version}.0"
35     "-property:FileVersion=${version}.0"
36     "-property:InformationalVersion=${version}"
37     "-property:RuntimeFrameworkVersion=${runtime_6_0.version}"
38     "-property:RollForward=LatestMajor"
39   ];
41   postPatch = ''
42     # Relax the version requirement
43     rm global.json
45     # Patch the project files so we can compile them properly
46     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
47       substituteInPlace $project \
48         --replace '<RuntimeIdentifiers>win7-x64;win7-x86;win10-arm64</RuntimeIdentifiers>' '<RuntimeIdentifiers>linux-x64;linux-arm64;osx-x64;osx-arm64</RuntimeIdentifiers>'
49     done
50   '';
52   useDotnetFromEnv = true;
53   executables = [ "OmniSharp" ];
55   passthru.tests = let
56     with-sdk = sdk: runCommand "with-${if sdk ? version then sdk.version else "no"}-sdk"
57       { nativeBuildInputs = [ finalPackage sdk expect ]; meta.timeout = 60; } ''
58       HOME=$TMPDIR
59       expect <<"EOF"
60         spawn OmniSharp
61         expect_before timeout {
62           send_error "timeout!\n"
63           exit 1
64         }
65         expect ".NET Core SDK ${if sdk ? version then sdk.version else sdk_6_0.version}"
66         expect "{\"Event\":\"started\","
67         send \x03
68         expect eof
69         catch wait result
70         exit [lindex $result 3]
71       EOF
72       touch $out
73     '';
74   in {
75     # Make sure we can run OmniSharp with any supported SDK version, as well as without
76     with-net6-sdk = with-sdk sdk_6_0;
77     with-net7-sdk = with-sdk dotnetCorePackages.sdk_7_0;
78     no-sdk = with-sdk null;
79   };
81   meta = with lib; {
82     description = "OmniSharp based on roslyn workspaces";
83     homepage = "https://github.com/OmniSharp/omnisharp-roslyn";
84     sourceProvenance = with sourceTypes; [
85       fromSource
86       binaryNativeCode # dependencies
87     ];
88     license = licenses.mit;
89     maintainers = with maintainers; [ tesq0 ericdallo corngood mdarocha ];
90     mainProgram = "OmniSharp";
91   };
92 }; in finalPackage