about summary refs log tree commit diff
path: root/pkgs/by-name/st/storcli/package.nix
blob: bb1e92247663cacfe92281af7078a8ba5a993c70 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
{ lib
, stdenvNoCC
, fetchzip
, rpmextract
, testers
}:

stdenvNoCC.mkDerivation (finalAttrs: {
  pname = "storcli";
  version = "7.2904.00";
  phase = "30";

  src = fetchzip {
    url = "https://docs.broadcom.com/docs-and-downloads/host-bus-adapters/host-bus-adapters-common-files/sas_sata_nvme_12g_p${finalAttrs.phase}/STORCLI_SAS3.5_P${finalAttrs.phase}.zip";
    hash = "sha256-VfK71eiDonzWdR6g5zkXgRRi25vwoI4DDL6xy3zsfak=";
  };

  nativeBuildInputs = [ rpmextract ];

  unpackPhase = let
    inherit (stdenvNoCC.hostPlatform) system;
    platforms = {
      x86_64-linux = "Linux";
      aarch64-linux = "ARM/Linux";
    };
    platform = platforms.${system} or (throw "unsupported system: ${system}");
  in ''
    rpmextract $src/univ_viva_cli_rel/Unified_storcli_all_os/${platform}/storcli-00${finalAttrs.version}00.0000-1.*.rpm
  '';

  dontPatch = true;
  dontConfigure = true;
  dontBuild = true;

  installPhase = ''
    install -D ./opt/MegaRAID/storcli/storcli64 $out/bin/storcli64
    ln -s storcli64 $out/bin/storcli
  '';

  # Not needed because the binary is statically linked
  dontFixup = true;

  passthru.tests = testers.testVersion {
    package = finalAttrs.finalPackage;
    command = "${finalAttrs.meta.mainProgram} -v";
    version = "00${finalAttrs.version}00.0000";
  };

  meta = with lib; {
    # Unfortunately there is no better page for this.
    # Filter for downloads, set 100 items per page. Sort by newest does not work.
    # Then search manually for the latest version.
    homepage = "https://www.broadcom.com/support/download-search?pg=&pf=Host+Bus+Adapters&pn=&pa=&po=&dk=storcli&pl=&l=false";
    description = "Storage Command Line Tool";
    sourceProvenance = with sourceTypes; [ binaryNativeCode ];
    license = licenses.unfree;
    maintainers = with maintainers; [ panicgh ];
    mainProgram = "storcli";
    platforms = [ "x86_64-linux" "aarch64-linux" ];
  };
})