about summary refs log tree commit diff
path: root/pkgs/development
diff options
context:
space:
mode:
authorJonathan Ringer <jonringer117@gmail.com>2020-07-16 14:02:04 -0700
committerJon <jonringer@users.noreply.github.com>2020-07-19 17:42:35 -0700
commita65cc6346dbf40a779289f2712bcc9eb1905146e (patch)
treef6275d5c4d7756b6377db0e5f7e5ecbd9efee644 /pkgs/development
parentc32264ef79ffeb807015b66fd6c5c893ba1c8ee9 (diff)
buildDotnet.nix: refactor
Diffstat (limited to 'pkgs/development')
-rw-r--r--pkgs/development/compilers/dotnet/buildDotnet.nix105
1 files changed, 54 insertions, 51 deletions
diff --git a/pkgs/development/compilers/dotnet/buildDotnet.nix b/pkgs/development/compilers/dotnet/buildDotnet.nix
index 20abc1c78b9af..1b3d7f10f21ae 100644
--- a/pkgs/development/compilers/dotnet/buildDotnet.nix
+++ b/pkgs/development/compilers/dotnet/buildDotnet.nix
@@ -2,6 +2,7 @@
 , version
 , sha512
 }:
+
 assert builtins.elem type [ "aspnetcore" "netcore" "sdk"];
 { stdenv
 , fetchurl
@@ -11,64 +12,66 @@ assert builtins.elem type [ "aspnetcore" "netcore" "sdk"];
 , libuuid
 , zlib
 , curl
-}: 
-let pname = if type == "aspnetcore" then "aspnetcore-runtime" else if type == "netcore" then "dotnet-runtime" else "dotnet-sdk";
-    platform = if stdenv.isDarwin then "osx" else "linux";
-    suffix = {
-      x86_64-linux  = "x64";
-      aarch64-linux = "arm64";
-      x86_64-darwin = "x64";
-    }."${stdenv.hostPlatform.system}" or (throw "Unsupported system: ${stdenv.hostPlatform.system}");
-    urls = {
-        aspnetcore = "https://dotnetcli.azureedge.net/dotnet/aspnetcore/Runtime/${version}/${pname}-${version}-${platform}-${suffix}.tar.gz";
-        netcore = "https://dotnetcli.azureedge.net/dotnet/Runtime/${version}/${pname}-${version}-${platform}-${suffix}.tar.gz";
-        sdk = "https://dotnetcli.azureedge.net/dotnet/Sdk/${version}/${pname}-${version}-${platform}-${suffix}.tar.gz";
-    };
-    descriptions = {
-        aspnetcore = "ASP .NET Core runtime ${version}";
-        netcore = ".NET Core runtime ${version}";
-        sdk = ".NET SDK ${version}";
-    };
+}:
+
+let
+  pname = if type == "aspnetcore" then "aspnetcore-runtime" else if type == "netcore" then "dotnet-runtime" else "dotnet-sdk";
+  platform = if stdenv.isDarwin then "osx" else "linux";
+  suffix = {
+    x86_64-linux  = "x64";
+    aarch64-linux = "arm64";
+    x86_64-darwin = "x64";
+  }."${stdenv.hostPlatform.system}" or (throw "Unsupported system: ${stdenv.hostPlatform.system}");
+  urls = {
+    aspnetcore = "https://dotnetcli.azureedge.net/dotnet/aspnetcore/Runtime/${version}/${pname}-${version}-${platform}-${suffix}.tar.gz";
+    netcore = "https://dotnetcli.azureedge.net/dotnet/Runtime/${version}/${pname}-${version}-${platform}-${suffix}.tar.gz";
+    sdk = "https://dotnetcli.azureedge.net/dotnet/Sdk/${version}/${pname}-${version}-${platform}-${suffix}.tar.gz";
+  };
+  descriptions = {
+    aspnetcore = "ASP .NET Core runtime ${version}";
+    netcore = ".NET Core runtime ${version}";
+    sdk = ".NET SDK ${version}";
+  };
 in stdenv.mkDerivation rec {
-    inherit pname version;
+  inherit pname version;
 
-    rpath = stdenv.lib.makeLibraryPath [ stdenv.cc.cc libunwind libuuid icu openssl zlib curl ];
+  rpath = stdenv.lib.makeLibraryPath [ stdenv.cc.cc libunwind libuuid icu openssl zlib curl ];
 
-    src = fetchurl {
-        url = builtins.getAttr type urls;
-        sha512 = sha512."${stdenv.hostPlatform.system}"  or (throw "Missing hash for host system: ${stdenv.hostPlatform.system}");
-    };
+  src = fetchurl {
+    url = builtins.getAttr type urls;
+    sha512 = sha512."${stdenv.hostPlatform.system}"  or (throw "Missing hash for host system: ${stdenv.hostPlatform.system}");
+  };
 
-    sourceRoot = ".";
+  sourceRoot = ".";
 
-    dontPatchELF = true;
-    noDumpEnvVars = true;
+  dontPatchELF = true;
+  noDumpEnvVars = true;
 
-    installPhase = ''
-        runHook preInstall
-        mkdir -p $out/bin
-        cp -r ./ $out
-        ln -s $out/dotnet $out/bin/dotnet
-        runHook postInstall
-    '';
+  installPhase = ''
+    runHook preInstall
+    mkdir -p $out/bin
+    cp -r ./ $out
+    ln -s $out/dotnet $out/bin/dotnet
+    runHook postInstall
+  '';
 
-    postFixup = stdenv.lib.optionalString stdenv.isLinux ''
-        patchelf --set-interpreter "${stdenv.cc.bintools.dynamicLinker}" $out/dotnet
-        patchelf --set-rpath "${rpath}" $out/dotnet
-        find $out -type f -name "*.so" -exec patchelf --set-rpath '$ORIGIN:${rpath}' {} \;
-        find $out -type f -name "apphost" -exec patchelf --set-interpreter "${stdenv.cc.bintools.dynamicLinker}" --set-rpath '$ORIGIN:${rpath}' {} \;
-    '';
+  postFixup = stdenv.lib.optionalString stdenv.isLinux ''
+    patchelf --set-interpreter "${stdenv.cc.bintools.dynamicLinker}" $out/dotnet
+    patchelf --set-rpath "${rpath}" $out/dotnet
+    find $out -type f -name "*.so" -exec patchelf --set-rpath '$ORIGIN:${rpath}' {} \;
+    find $out -type f -name "apphost" -exec patchelf --set-interpreter "${stdenv.cc.bintools.dynamicLinker}" --set-rpath '$ORIGIN:${rpath}' {} \;
+  '';
 
-    doInstallCheck = true;
-    installCheckPhase = ''
-        $out/bin/dotnet --info
-    '';
+  doInstallCheck = true;
+  installCheckPhase = ''
+    $out/bin/dotnet --info
+  '';
 
-    meta = with stdenv.lib; {
-        homepage = "https://dotnet.github.io/";
-        description = builtins.getAttr type descriptions;
-        platforms = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" ];
-        maintainers = with maintainers; [ kuznero ];
-        license = licenses.mit;
-    };
+  meta = with stdenv.lib; {
+    homepage = "https://dotnet.github.io/";
+    description = builtins.getAttr type descriptions;
+    platforms = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" ];
+    maintainers = with maintainers; [ kuznero ];
+    license = licenses.mit;
+  };
 }