aboutsummaryrefslogtreecommitdiffhomepage
path: root/nodegit.nix
blob: 09f0969902e6e0fb9895eac6e239766df3b1e842 (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
{ pkgs }:

let
  version = "0.20.3";

  stdenv = pkgs.stdenv;
  fetchurl = pkgs.fetchurl;

  curl = pkgs.curl.override {
    sslSupport = false;
    gnutlsSupport = true;
  };
  glibc = pkgs.glibc;
  openssl = pkgs.openssl;

  libs = [ stdenv.cc.cc curl glibc openssl ];

in

  assert pkgs.stdenv.system == "x86_64-linux";

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

    src = fetchurl {
      url = "https://nodegit.s3.amazonaws.com/nodegit/nodegit/nodegit-v${version}-node-v51-linux-x64.tar.gz";
      sha256 = "d022a88e58fa70f78b59b475fa6ecc6724d372a779b132264cf571f71bc50020";
    };

    buildPhase = ":";

    libPath = stdenv.lib.makeLibraryPath libs;

    installPhase = ''
      tar --extract --file=$src Release/nodegit.node --transform 's/Release\//linux-/'
      lib=$out/lib/nodegit.node
      mkdir -p $out/lib
      mv linux-nodegit.node $lib
    '';

    preFixup = ''
      lib=$out/lib/nodegit.node
      patchelf --set-rpath "$libPath" "$lib"
    '';
  }