@@ -0,0 +1,59 @@
1+{ stdenv, lib, buildPythonPackage, fetchPypi, python, isPy27
2+, dotnet-sdk
3+, substituteAll
4+, distro
5+, unzip
6+}:
7+
8+buildPythonPackage rec {
9+ pname = "dotnetcore2";
10+ version = "2.1.8.1";
11+ format = "wheel";
12+ disabled = isPy27;
13+
14+ src = fetchPypi {
15+ inherit pname version format;
16+ python = "py3";
17+ platform = "manylinux1_x86_64";
18+ sha256 = "13zrff5j767d3f8drl397sjhl28winsrfa8pa20svf00xfcsy34s";
19+ };
20+
21+ nativeBuildInputs = [ unzip ];
22+
23+ propagatedBuildInputs = [ distro ];
24+
25+ # needed to apply patches
26+ prePatch = ''
27+ unzip dist/dotnet*
28+ '';
29+
30+ patches = [
31+ ( substituteAll {
32+ src = ./runtime.patch;
33+ dotnet = dotnet-sdk;
34+ }
35+ )
36+ ];
37+
38+ # unfortunately the noraml pip install fails because the manylinux1 format check fails with NixOS
39+ installPhase = ''
40+ mkdir -p $out/${python.sitePackages}/${pname}
41+ # copy metadata
42+ cp -r dotnetcore2-2* $out/${python.sitePackages}
43+ # copy non-dotnetcore related files
44+ cp -r dotnetcore2/{__init__.py,runtime.py} $out/${python.sitePackages}/${pname}
45+ '';
46+
47+ # no tests, ensure it's one useful function works
48+ checkPhase = ''
49+ ${python.interpreter} -c 'from dotnetcore2 import runtime; print(runtime.get_runtime_path())'
50+ '';
51+
52+ meta = with lib; {
53+ description = "DotNet Core runtime";
54+ homepage = "https://github.com/dotnet/core";
55+ license = licenses.mit;
56+ platforms = [ "x86_64-linux" ];
57+ maintainers = with maintainers; [ jonringer ];
58+ };
59+}