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