about summary refs log tree commit diff
path: root/pkgs/development/compilers/roslyn/default.nix
blob: 6ab2799f46c46c796850146cdaf4ab901f78cfce (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
{ lib
, fetchFromGitHub
, mono
, buildDotnetModule
, dotnetCorePackages
, unzip
}:

buildDotnetModule rec {
  pname = "roslyn";
  version = "4.2.0";

  src = fetchFromGitHub {
    owner = "dotnet";
    repo = "roslyn";
    rev = "v${version}";
    hash = "sha256-4iXabFp0LqJ8TXOrqeD+oTAocg6ZTIfijfX3s3fMJuI=";
  };

  dotnet-sdk = dotnetCorePackages.sdk_6_0;

  projectFile = [ "src/NuGet/Microsoft.Net.Compilers.Toolset/Microsoft.Net.Compilers.Toolset.Package.csproj" ];

  nugetDeps = ./deps.nix;

  dontDotnetFixup = true;

  nativeBuildInputs = [ unzip ];

  postPatch = ''
    sed -i 's/latestPatch/latestFeature/' global.json
  '';

  buildPhase = ''
    runHook preBuild

    dotnet msbuild -v:m -t:pack \
      -p:Configuration=Release \
      -p:RepositoryUrl="${meta.homepage}" \
      -p:RepositoryCommit="v${version}" \
      src/NuGet/Microsoft.Net.Compilers.Toolset/Microsoft.Net.Compilers.Toolset.Package.csproj

    runHook postBuild
  '';

  installPhase = ''
    pkg="$out/lib/dotnet/microsoft.net.compilers.toolset/${version}"
    mkdir -p "$out/bin" "$pkg"

    unzip -q artifacts/packages/Release/Shipping/Microsoft.Net.Compilers.Toolset.${version}-dev.nupkg \
      -d "$pkg"
    # nupkg has 0 permissions for a bunch of things
    chmod -R +rw "$pkg"

    makeWrapper ${mono}/bin/mono $out/bin/csc \
      --add-flags "$pkg/tasks/net472/csc.exe"
    makeWrapper ${mono}/bin/mono $out/bin/vbc \
      --add-flags "$pkg/tasks/net472/vbc.exe"
  '';

  meta = with lib; {
    description = ".NET C# and Visual Basic compiler";
    homepage = "https://github.com/dotnet/roslyn";
    mainProgram = "csc";
    license = licenses.mit;
    maintainers = with maintainers; [ corngood ];
  };
}