1{ config, lib, pkgs, ... }:
2
3with lib;
4
5let
6 hpssacli = pkgs.stdenv.mkDerivation rec {
7 pname = "hpssacli";
8 version = "2.40-13.0";
9
10 src = pkgs.fetchurl {
11 urls = [
12 "https://downloads.linux.hpe.com/SDR/downloads/MCP/Ubuntu/pool/non-free/${pname}-${version}_amd64.deb"
13 "http://apt.netangels.net/pool/main/h/hpssacli/${pname}-${version}_amd64.deb"
14 ];
15 sha256 = "11w7fwk93lmfw0yya4jpjwdmgjimqxx6412sqa166g1pz4jil4sw";
16 };
17
18 nativeBuildInputs = [ pkgs.dpkg ];
19
20 unpackPhase = "dpkg -x $src ./";
21
22 installPhase = ''
23 mkdir -p $out/bin $out/share/doc $out/share/man
24 mv opt/hp/hpssacli/bld/{hpssascripting,hprmstr,hpssacli} $out/bin/
25 mv opt/hp/hpssacli/bld/*.{license,txt} $out/share/doc/
26 mv usr/man $out/share/
27
28 for file in $out/bin/*; do
29 chmod +w $file
30 patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
31 --set-rpath ${lib.makeLibraryPath [ pkgs.stdenv.cc.cc ]} \
32 $file
33 done
34 '';
35
36 dontStrip = true;
37
38 meta = with lib; {
39 description = "HP Smart Array CLI";
40 homepage = "https://downloads.linux.hpe.com/SDR/downloads/MCP/Ubuntu/pool/non-free/";
41 license = licenses.unfreeRedistributable;
42 platforms = [ "x86_64-linux" ];
43 maintainers = with maintainers; [ ];
44 };
45 };
46in {
47 ###### interface
48
49 options = {
50 hardware.raid.HPSmartArray = {
51 enable = mkEnableOption (lib.mdDoc "HP Smart Array kernel modules and CLI utility");
52 };
53 };
54
55 ###### implementation
56
57 config = mkIf config.hardware.raid.HPSmartArray.enable {
58
59 boot.initrd.kernelModules = [ "sg" ]; /* hpssacli wants it */
60 boot.initrd.availableKernelModules = [ "hpsa" ];
61
62 environment.systemPackages = [ hpssacli ];
63 };
64}