aboutsummaryrefslogtreecommitdiffhomepage
path: root/default.nix
blob: 65c872a80121b6d6d9e29875f10b22a8bd4ed33a (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
{ pkgs ? import <nixpkgs> {} }:

with pkgs;

let
  version = "0.9.3";

  nodegit = import ./nodegit.nix { inherit pkgs; };

  libs = [ stdenv.cc.cc glibc ];

in

  stdenv.mkDerivation {
    name = "clever-cli-${version}";

    buildInputs = [ nodegit nodejs-6_x ];

    src = fetchurl {
      url = "https://clever-tools.cellar.services.clever-cloud.com/releases/${version}/clever-tools-${version}_linux.tar.gz";
      sha256 = "adcae5af912dcbdc74d996b6e94767f24d16bf1bdcd5073797f999fe75b018a4";
    };

    buildPhase = ":";

    libPath = stdenv.lib.makeLibraryPath libs;

    nodegitLibrary = stdenv.lib.makeLibraryPath [ nodegit ];

    installPhase = ''
      tar --extract --file=$src linux/clever --transform 's/linux\///'
      bin=$out/bin/clever
      mkdir -p $out/bin
      mv clever $bin
      ln -s "$nodegitLibrary/nodegit.node" "$out/bin/nodegit.node"
    '';

    dontStrip = "true";

    preFixup = ''
      bin=$out/bin/clever
      patchelf \
        --set-rpath "$libPath" \
        --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
        "$bin"
    '';

  }