diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | default.nix | 48 | ||||
-rw-r--r-- | nodegit.nix | 45 |
3 files changed, 94 insertions, 0 deletions
@@ -1 +1,2 @@ | |||
1 | *.sw* | 1 | *.sw* |
2 | result | ||
diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..65c872a --- /dev/null +++ b/default.nix | |||
@@ -0,0 +1,48 @@ | |||
1 | { pkgs ? import <nixpkgs> {} }: | ||
2 | |||
3 | with pkgs; | ||
4 | |||
5 | let | ||
6 | version = "0.9.3"; | ||
7 | |||
8 | nodegit = import ./nodegit.nix { inherit pkgs; }; | ||
9 | |||
10 | libs = [ stdenv.cc.cc glibc ]; | ||
11 | |||
12 | in | ||
13 | |||
14 | stdenv.mkDerivation { | ||
15 | name = "clever-cli-${version}"; | ||
16 | |||
17 | buildInputs = [ nodegit nodejs-6_x ]; | ||
18 | |||
19 | src = fetchurl { | ||
20 | url = "https://clever-tools.cellar.services.clever-cloud.com/releases/${version}/clever-tools-${version}_linux.tar.gz"; | ||
21 | sha256 = "adcae5af912dcbdc74d996b6e94767f24d16bf1bdcd5073797f999fe75b018a4"; | ||
22 | }; | ||
23 | |||
24 | buildPhase = ":"; | ||
25 | |||
26 | libPath = stdenv.lib.makeLibraryPath libs; | ||
27 | |||
28 | nodegitLibrary = stdenv.lib.makeLibraryPath [ nodegit ]; | ||
29 | |||
30 | installPhase = '' | ||
31 | tar --extract --file=$src linux/clever --transform 's/linux\///' | ||
32 | bin=$out/bin/clever | ||
33 | mkdir -p $out/bin | ||
34 | mv clever $bin | ||
35 | ln -s "$nodegitLibrary/nodegit.node" "$out/bin/nodegit.node" | ||
36 | ''; | ||
37 | |||
38 | dontStrip = "true"; | ||
39 | |||
40 | preFixup = '' | ||
41 | bin=$out/bin/clever | ||
42 | patchelf \ | ||
43 | --set-rpath "$libPath" \ | ||
44 | --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \ | ||
45 | "$bin" | ||
46 | ''; | ||
47 | |||
48 | } | ||
diff --git a/nodegit.nix b/nodegit.nix new file mode 100644 index 0000000..09f0969 --- /dev/null +++ b/nodegit.nix | |||
@@ -0,0 +1,45 @@ | |||
1 | { pkgs }: | ||
2 | |||
3 | let | ||
4 | version = "0.20.3"; | ||
5 | |||
6 | stdenv = pkgs.stdenv; | ||
7 | fetchurl = pkgs.fetchurl; | ||
8 | |||
9 | curl = pkgs.curl.override { | ||
10 | sslSupport = false; | ||
11 | gnutlsSupport = true; | ||
12 | }; | ||
13 | glibc = pkgs.glibc; | ||
14 | openssl = pkgs.openssl; | ||
15 | |||
16 | libs = [ stdenv.cc.cc curl glibc openssl ]; | ||
17 | |||
18 | in | ||
19 | |||
20 | assert pkgs.stdenv.system == "x86_64-linux"; | ||
21 | |||
22 | stdenv.mkDerivation { | ||
23 | name = "nodegit-${version}"; | ||
24 | |||
25 | src = fetchurl { | ||
26 | url = "https://nodegit.s3.amazonaws.com/nodegit/nodegit/nodegit-v${version}-node-v51-linux-x64.tar.gz"; | ||
27 | sha256 = "d022a88e58fa70f78b59b475fa6ecc6724d372a779b132264cf571f71bc50020"; | ||
28 | }; | ||
29 | |||
30 | buildPhase = ":"; | ||
31 | |||
32 | libPath = stdenv.lib.makeLibraryPath libs; | ||
33 | |||
34 | installPhase = '' | ||
35 | tar --extract --file=$src Release/nodegit.node --transform 's/Release\//linux-/' | ||
36 | lib=$out/lib/nodegit.node | ||
37 | mkdir -p $out/lib | ||
38 | mv linux-nodegit.node $lib | ||
39 | ''; | ||
40 | |||
41 | preFixup = '' | ||
42 | lib=$out/lib/nodegit.node | ||
43 | patchelf --set-rpath "$libPath" "$lib" | ||
44 | ''; | ||
45 | } | ||