acr-cli: init at 0.14 (#359508)
[NixPkgs.git] / pkgs / by-name / om / omnisharp-roslyn / package.nix
blob5ca7c3290eab0fd9bb2c7076213cd542c9632b2f
2   buildDotnetModule,
3   dotnetCorePackages,
4   fetchFromGitHub,
5   lib,
6   stdenv,
7   runCommand,
8   expect,
9 }:
11 let
12   inherit (dotnetCorePackages) sdk_8_0 runtime_6_0;
14 let
15   finalPackage = buildDotnetModule rec {
16     pname = "omnisharp-roslyn";
17     version = "1.39.12";
19     src = fetchFromGitHub {
20       owner = "OmniSharp";
21       repo = "omnisharp-roslyn";
22       rev = "refs/tags/v${version}";
23       hash = "sha256-WQIBNqUqvVA0UhSoPdf179X+GYKp4LhPvYeEAet6TnY=";
24     };
26     projectFile = "src/OmniSharp.Stdio.Driver/OmniSharp.Stdio.Driver.csproj";
27     nugetDeps = ./deps.nix;
29     dotnet-sdk =
30       with dotnetCorePackages;
31       combinePackages [
32         sdk_6_0
33         sdk_8_0
34       ];
35     dotnet-runtime = sdk_8_0;
37     dotnetInstallFlags = [ "--framework net6.0" ];
38     dotnetBuildFlags = [
39       "--framework net6.0"
40       "--no-self-contained"
41     ];
42     dotnetFlags = [
43       # These flags are set by the cake build.
44       "-property:PackageVersion=${version}"
45       "-property:AssemblyVersion=${version}.0"
46       "-property:FileVersion=${version}.0"
47       "-property:InformationalVersion=${version}"
48       "-property:RuntimeFrameworkVersion=${runtime_6_0.version}"
49       "-property:RollForward=LatestMajor"
50     ];
52     postPatch = ''
53       # Relax the version requirement
54       rm global.json
56       # Patch the project files so we can compile them properly
57       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
58         substituteInPlace $project \
59           --replace '<RuntimeIdentifiers>win7-x64;win7-x86;win10-arm64</RuntimeIdentifiers>' '<RuntimeIdentifiers>linux-x64;linux-arm64;osx-x64;osx-arm64</RuntimeIdentifiers>'
60       done
61     '';
63     useDotnetFromEnv = true;
64     executables = [ "OmniSharp" ];
66     passthru.tests =
67       let
68         with-sdk =
69           sdk:
70           runCommand "with-${if sdk ? version then sdk.version else "no"}-sdk"
71             {
72               nativeBuildInputs = [
73                 finalPackage
74                 sdk
75                 expect
76               ];
77               meta.timeout = 60;
78             }
79             ''
80               HOME=$TMPDIR
81               expect <<"EOF"
82                 spawn OmniSharp
83                 expect_before timeout {
84                   send_error "timeout!\n"
85                   exit 1
86                 }
87                 expect ".NET Core SDK ${if sdk ? version then sdk.version else sdk_8_0.version}"
88                 expect "{\"Event\":\"started\","
89                 send \x03
90                 expect eof
91                 catch wait result
92                 exit [lindex $result 3]
93               EOF
94               touch $out
95             '';
96       in
97       {
98         # Make sure we can run OmniSharp with any supported SDK version, as well as without
99         with-net6-sdk = with-sdk dotnetCorePackages.sdk_6_0;
100         with-net8-sdk = with-sdk dotnetCorePackages.sdk_8_0;
101         no-sdk = with-sdk null;
102       };
104     passthru.updateScript = ./update.sh;
106     meta = {
107       description = "OmniSharp based on roslyn workspaces";
108       homepage = "https://github.com/OmniSharp/omnisharp-roslyn";
109       sourceProvenance = with lib.sourceTypes; [
110         fromSource
111         binaryNativeCode # dependencies
112       ];
113       license = lib.licenses.mit;
114       maintainers = with lib.maintainers; [
115         corngood
116         ericdallo
117         gepbird
118         mdarocha
119         tesq0
120       ];
121       mainProgram = "OmniSharp";
122     };
123   };
125 finalPackage