1{
2 lib,
3 stdenvNoCC,
4 fetchzip,
5 rpmextract,
6 testers,
7}:
8stdenvNoCC.mkDerivation (
9 finalAttrs:
10 let
11 majVer = "8";
12 minVer = "11";
13 relPhs = "14";
14 verCode = "00" + majVer + ".00" + minVer + ".0000.00" + relPhs;
15 in
16 {
17 pname = "storcli";
18 version = majVer + "." + minVer;
19
20 src = fetchzip {
21 url = "https://docs.broadcom.com/docs-and-downloads/host-bus-adapters/host-bus-adapters-common-files/sas_sata_nvme_24g_p${finalAttrs.version}/StorCLI_Avenger_${finalAttrs.version}-${verCode}.zip";
22 hash = "sha256-vztV+Jp+p6nU4q7q8QQIkuL30QsoGj2tyIZp87luhH8=";
23 };
24
25 nativeBuildInputs = [ rpmextract ];
26
27 unpackPhase =
28 let
29 inherit (stdenvNoCC.hostPlatform) system;
30 platforms = {
31 x86_64-linux = "Linux";
32 aarch64-linux = "ARM/Linux";
33 };
34 platform = platforms.${system} or (throw "unsupported system: ${system}");
35 in
36 ''
37 rpmextract $src/Avenger_StorCLI/${platform}/storcli2-${verCode}-1.*.rpm
38 '';
39
40 dontPatch = true;
41 dontConfigure = true;
42 dontBuild = true;
43
44 installPhase = ''
45 install -D ./opt/MegaRAID/storcli2/storcli2 $out/bin/storcli2
46 '';
47
48 # Not needed because the binary is statically linked
49 dontFixup = false;
50
51 passthru.tests = testers.testVersion {
52 package = finalAttrs.finalPackage;
53 command = "${finalAttrs.meta.mainProgram} v";
54 version = verCode;
55 };
56
57 meta = with lib; {
58 # Unfortunately there is no better page for this.
59 # Filter for downloads, set 100 items per page. Sort by newest does not work.
60 # Then search manually for the latest version.
61 homepage = "https://www.broadcom.com/support/download-search?pg=&pf=Host+Bus+Adapters&pn=&pa=&po=&dk=storcli2&pl=&l=false";
62 description = "Storage Command Line Tool";
63 sourceProvenance = with sourceTypes; [ binaryNativeCode ];
64 license = licenses.unfree;
65 maintainers = with maintainers; [ edwtjo ];
66 mainProgram = "storcli2";
67 platforms = [
68 "x86_64-linux"
69 "aarch64-linux"
70 ];
71 };
72 }
73)