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

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

  src = fetchgit {
    url = http://cgit.cd.krebsco.de/cac-api;
    rev = "46c7af2935ccc096ba0e93cd1adf575026edf44a";
    sha256 = "0i8aspkmfw74np7hlbip3hk7zbgl6cxrnbg83x4wgqrj5dpx6vy0";
  };

  phases = [
    "unpackPhase"
    "installPhase"
  ];

  installPhase = ''
    mkdir -p $out/bin
    { cat <<\EOF
    #! ${dash}/bin/dash
    export PATH=${stdenv.lib.makeSearchPath "bin" [
      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
  '';
}