summaryrefslogtreecommitdiffstats
path: root/krebs/5pkgs/simple/cac-api/default.nix
blob: 5f37f6682def12f6f5b59f2a799c32129b15b082 (plain)
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
{ fetchgit, lib, stdenv
, bc, cac-cert, coreutils, curl, dash, gnugrep, gnused, inotifyTools, jq, ncurses, openssh, sshpass
}:

stdenv.mkDerivation {
  name = "cac-api-1.1.2";

  src = fetchgit {
    url = http://cgit.ni.krebsco.de/cac-api;
    rev = "67e93510e7742acae44db30275abbfe671aa9b7b";
    sha256 = "1vxh57j7vrq5sg9j1sam0538kkkhqpgf230vvdz2ifzgkj01z27l";
  };

  phases = [
    "unpackPhase"
    "installPhase"
  ];

  installPhase = ''
    mkdir -p $out/bin
    { cat <<\EOF
    #! ${dash}/bin/dash
    export PATH=${lib.makeBinPath [
      bc
      coreutils
      curl
      gnugrep
      gnused
      inotifyTools
      jq
      ncurses
      openssh
      sshpass
    ]}:"$PATH"
    EOF
      # [1]: Disable fetching tasks; listtasks is currently broken:
      # Unknown column 'iod.apitask.cid' in 'field list'
      sed '
        /^\s*tasks \\$/d; # [1]
        s|\<_cac_exec curl|<${cac-cert} & --cacert /dev/stdin|
      ' cac-api
    } > $out/bin/cac-api
    chmod +x $out/bin/cac-api
  '';
}