Merge pull request #268619 from tweag/lib-descriptions
[NixPkgs.git] / pkgs / development / tools / azure-functions-core-tools / default.nix
blobcf039c5758f5e6dee58fc5ef83ff16d349488e1f
2   stdenv,
3   lib,
4   config,
5   fetchurl,
6   unzip,
7   makeWrapper,
8   icu,
9   libunwind,
10   curl,
11   zlib,
12   libuuid,
13   openssl,
14 }: let
15   platforms = {
16     "aarch64-darwin" = {
17       platformStr = "osx-arm64";
18       hash = "sha256-yp3VTt5m8KuACjrBIotfQ5ZdgMvfwYIFaqY2475pHRs=";
19     };
20     "x86_64-darwin" = {
21       platformStr = "osx-x64";
22       hash = "sha256-bTHh0mwGbe6JVsR8rDHGpGJ2+AipHb8NIBIW7iiuz6I=";
23     };
24     "x86_64-linux" = {
25       platformStr = "linux-x64";
26       hash = "sha256-5R4/hCxCz6KfBl9Zbei+iFty5S2MOYt9hMvPMjCzL54=";
27     };
28   };
30   platformInfo = builtins.getAttr stdenv.hostPlatform.system platforms;
32   stdenv.mkDerivation rec {
33     pname = "azure-functions-core-tools";
34     version = "4.0.5348";
36     src = fetchurl {
37       url = "https://github.com/Azure/${pname}/releases/download/${version}/Azure.Functions.Cli.${platformInfo.platformStr}.${version}.zip";
38       inherit (platformInfo) hash;
39     };
41     nativeBuildInputs = [
42       unzip
43       makeWrapper
44       icu
45       libunwind
46       curl
47       zlib
48     ];
50     libPath = lib.makeLibraryPath [
51       libunwind
52       libuuid
53       stdenv.cc.cc
54       curl
55       zlib
56       icu
57       openssl
58     ];
60     unpackPhase = ''
61       unzip $src
62     '';
64     installPhase =
65       ''
66         mkdir -p $out/bin
67         cp -prd . $out/bin/azure-functions-core-tools
68         chmod +x $out/bin/azure-functions-core-tools/{func,gozip}
69       ''
70       + lib.optionalString stdenv.isLinux ''
71         patchelf \
72           --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
73           --set-rpath "${libPath}" "$out/bin/azure-functions-core-tools/func"
74         find $out/bin/azure-functions-core-tools -type f -name "*.so" -exec patchelf --set-rpath "${libPath}" {} \;
75         wrapProgram "$out/bin/azure-functions-core-tools/func" --prefix LD_LIBRARY_PATH : ${libPath}
76       ''
77       + ''
78         ln -s $out/bin/{azure-functions-core-tools,}/func
79         ln -s $out/bin/{azure-functions-core-tools,}/gozip
80       '';
81     dontStrip = true; # Causes rpath patching to break if not set
83     meta = with lib; {
84       homepage = "https://github.com/Azure/azure-functions-core-tools";
85       description = "Command line tools for Azure Functions";
86       sourceProvenance = with sourceTypes; [
87         binaryBytecode
88         binaryNativeCode
89       ];
90       license = licenses.mit;
91       maintainers = with maintainers; [ mdarocha ];
92       platforms = ["x86_64-linux" "aarch64-darwin" "x86_64-darwin"];
93     };
94   }