at master 2.4 kB view raw
1{ 2 lib, 3 stdenv, 4 fetchurl, 5 installShellFiles, 6 writableTmpDirAsHomeHook, 7}: 8let 9 arch = 10 with stdenv.hostPlatform; 11 if isx86_64 then 12 "amd64" 13 else if isAarch64 then 14 "arm64" 15 else if isi686 then 16 "386" 17 else if isPower64 && isLittleEndian then 18 "ppc64le" 19 else if isS390x then 20 "s390x" 21 else 22 throw "Unsupported arch: ${stdenv.hostPlatform.system}"; 23 platform = 24 if stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64 then 25 "macos_arm64" 26 else if stdenv.hostPlatform.isDarwin then 27 "macos" 28 else 29 "linux_${arch}"; 30in 31stdenv.mkDerivation (finalAttrs: { 32 pname = "ibmcloud-cli"; 33 version = "2.36.0"; 34 35 src = fetchurl { 36 url = "https://download.clis.cloud.ibm.com/ibm-cloud-cli/${finalAttrs.version}/binaries/IBM_Cloud_CLI_${finalAttrs.version}_${platform}.tgz"; 37 hash = 38 { 39 "x86_64-darwin" = "sha256-hIHFfUxAhpA+YIN7Bq65khFFj+3BCuYRtMq2WjQwqYQ="; 40 "aarch64-darwin" = "sha256-ZZ500RWagqhf63zwiQpV8y+gtCxGfbA36F97x67coUE="; 41 "x86_64-linux" = "sha256-+ZKlFvrDPm3ERq8/r7cjgsJWjUr8+sGFqYXdiSUPeXo="; 42 "aarch64-linux" = "sha256-ER/Ey3Jux3i8tC30/65awHdEd6efscUVjX/bFAk1b7c="; 43 "i686-linux" = "sha256-5A0kUegKVHSTZ+jRg5+07wvV4PkCvOPddvyC1ZLCbmI="; 44 "powerpc64le-linux" = "sha256-XcHrdA9i3Euc0yIjUtFrmIFMJi+onXRK+tHzNxmQwHg="; 45 "s390x-linux" = "sha256-loGQxvUqp9ngieVOVuZ6IhOKgyrVGBd+y9LdZtKEPwc="; 46 } 47 .${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}"); 48 }; 49 50 nativeBuildInputs = [ 51 installShellFiles 52 writableTmpDirAsHomeHook 53 ]; 54 55 installPhase = '' 56 runHook preInstall 57 58 install -Dm755 ibmcloud $out/bin/ibmcloud 59 mkdir -p $out/share/ibmcloud 60 cp LICENSE NOTICE $out/share/ibmcloud 61 installShellCompletion --cmd ibmcloud --bash <($out/bin/ibmcloud --generate-bash-completion) 62 63 runHook postInstall 64 ''; 65 66 passthru.updateScript = ./update.sh; 67 68 meta = { 69 description = "Command line client for IBM Cloud"; 70 homepage = "https://cloud.ibm.com/docs/cli"; 71 license = lib.licenses.asl20; 72 maintainers = with lib.maintainers; [ emilytrau ]; 73 platforms = [ 74 "x86_64-linux" 75 "aarch64-linux" 76 "i686-linux" 77 "powerpc64le-linux" 78 "s390x-linux" 79 ] 80 ++ lib.platforms.darwin; 81 sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ]; 82 mainProgram = "ibmcloud"; 83 }; 84})