aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorHussein A <44173825+haitlahcen@users.noreply.github.com>2019-01-30 16:07:56 +0100
committerGitHub <noreply@github.com>2019-01-30 16:07:56 +0100
commit2f7e1a82773077034b335e3fa0a36ca41fc18032 (patch)
tree34925fa26e5637e93a5d779deddff27322e9529b
parenta60f5f961215e9a011b4a0dfe651758001f116d8 (diff)
parent63d289fd2f02a4d45e60f61e11f8dd9d3b4963fc (diff)
downloadclever-tools-nix-2f7e1a82773077034b335e3fa0a36ca41fc18032.tar.gz
clever-tools-nix-2f7e1a82773077034b335e3fa0a36ca41fc18032.tar.zst
clever-tools-nix-2f7e1a82773077034b335e3fa0a36ca41fc18032.zip
Merge pull request #6 from haitlahcen/upgrade-1.1.0
upgrade to 1.1.0 and get rid of nodegit
-rw-r--r--CHANGELOG.md9
-rw-r--r--README.md20
-rwxr-xr-xcheck.sh2
-rw-r--r--clever-tools/default.nix51
-rw-r--r--default.nix10
-rw-r--r--example.nix12
-rw-r--r--nodegit/default.nix35
7 files changed, 62 insertions, 77 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 0000000..3b37960
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,9 @@
1## 1.1.0
2
3* Get rid of nodegit, not being used anymore by clever-tools.
4* Fix harcoded binary offsets used by `zeit/pkg` (which bundle the executable).
5
6## 0.9.3
7
8* Use patchelf to make the binaries nix-compliant.
9* Introduce custom `nodegit` derivation.
diff --git a/README.md b/README.md
index b47a4bc..3d9894a 100644
--- a/README.md
+++ b/README.md
@@ -2,24 +2,6 @@
2 2
3Nix derivation to install clever-tools - see https://github.com/CleverCloud/clever-tools 3Nix derivation to install clever-tools - see https://github.com/CleverCloud/clever-tools
4 4
5## What's in it
6
72 derivations to install
8- nodegit.node 0.20.3 for node v51, from prebuilt archive
9- clever-tools 0.9.3, from prebuilt archive
10
11Main job of those derivations is to use patchelf to make it nix compliant.
12
13## How to use it 5## How to use it
14 6
15```nix 7[See the example.nix](https://github.com/fretlink/clever-tools-nix/blob/master/example.nix)
16{ pkgs ? import <nixpkgs> {} }: with pkgs;
17
18let clever-tools = fetchFromGitHub {
19 owner = "fretlink";
20 repo = "clever-tools-nix";
21 rev = "DESIRED_REVISION_HASH";
22 sha256 = "CONTENT_HASH";
23 };
24in (import clever-tools {}).latest # select appropriate version
25```
diff --git a/check.sh b/check.sh
index 1b14239..8515fa4 100755
--- a/check.sh
+++ b/check.sh
@@ -1 +1 @@
[ "$(clever --version)" == "0.9.3" ] [ "$(clever --version)" == "1.1.0" ]
diff --git a/clever-tools/default.nix b/clever-tools/default.nix
index 6c729a5..9ac69e6 100644
--- a/clever-tools/default.nix
+++ b/clever-tools/default.nix
@@ -1,36 +1,59 @@
1{ stdenv, fetchurl, glibc, nodegit }: 1{ stdenv, fetchurl, glibc }:
2 2
3stdenv.mkDerivation rec { 3stdenv.mkDerivation rec {
4 name = "clever-tools-${version}"; 4 name = "clever-tools-${version}";
5 version = "0.9.3"; 5 version = "1.1.0";
6 6
7 src = fetchurl { 7 src = fetchurl {
8 url = "https://clever-tools.cellar.services.clever-cloud.com/releases/${version}/clever-tools-${version}_linux.tar.gz"; 8 url = "https://clever-tools.cellar.services.clever-cloud.com/releases/${version}/clever-tools-${version}_linux.tar.gz";
9 sha256 = "adcae5af912dcbdc74d996b6e94767f24d16bf1bdcd5073797f999fe75b018a4"; 9 sha256 = "1lkwckmlz2gf41xmnzydpcbly0jcry3bn8lp570gha768ic7xmb1";
10 }; 10 };
11 11
12 buildInputs = [ nodegit ];
13
14 libPath = stdenv.lib.makeLibraryPath [ stdenv.cc.cc glibc ]; 12 libPath = stdenv.lib.makeLibraryPath [ stdenv.cc.cc glibc ];
15 13
16 nodegitLibrary = stdenv.lib.makeLibraryPath [ nodegit ];
17
18 installPhase = '' 14 installPhase = ''
19 tar --extract --file=$src linux/clever --transform 's/linux\///' 15 tar --extract --file=$src
20 bin=$out/bin/clever 16 bin=$out/bin/clever
21 mkdir -p $out/bin 17 mkdir -p $out/bin
22 mv clever $bin 18 mv clever $bin
23 ln -s "$nodegitLibrary/nodegit.node" "$out/bin/nodegit.node"
24 ''; 19 '';
25 20
26 dontStrip = "true"; 21 dontStrip = "true";
27 22
23 # See https://github.com/brendan-hall/nixpkgs/blob/e3b313bb59f49f10970205aafd44878d35da07e7/pkgs/development/web/now-cli/default.nix#L25
24 # There is no helper in nixpkgs lib right now
25 # The algorithm for zeit/pkg fix is given https://github.com/NixOS/nixpkgs/pull/48193
26 # it has been used for Unity3D as well https://github.com/NixOS/nixpkgs/pull/48643
28 preFixup = '' 27 preFixup = ''
29 bin=$out/bin/clever 28 bin=$out/bin/clever
30 patchelf \ 29 orig_size=$(stat --printf=%s $bin)
31 --set-rpath "$libPath" \ 30 patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" $bin
32 --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \ 31 patchelf --set-rpath ${libPath} $bin
33 "$bin" 32 new_size=$(stat --printf=%s $bin)
33 ###### zeit-pkg fixing starts here.
34 # we're replacing plaintext js code that looks like
35 # PAYLOAD_POSITION = '1234 ' | 0
36 # [...]
37 # PRELUDE_POSITION = '1234 ' | 0
38 # ^-----20-chars-----^^------22-chars------^
39 # ^-- grep points here
40 #
41 # var_* are as described above
42 # shift_by seems to be safe so long as all patchelf adjustments occur
43 # before any locations pointed to by hardcoded offsets
44 var_skip=20
45 var_select=22
46 shift_by=$(expr $new_size - $orig_size)
47 function fix_offset {
48 # $1 = name of variable to adjust
49 location=$(grep -obUam1 "$1" $bin | cut -d: -f1)
50 location=$(expr $location + $var_skip)
51 value=$(dd if=$bin iflag=count_bytes,skip_bytes skip=$location \
52 bs=1 count=$var_select status=none)
53 value=$(expr $shift_by + $value)
54 echo -n $value | dd of=$bin bs=1 seek=$location conv=notrunc
55 }
56 fix_offset PAYLOAD_POSITION
57 fix_offset PRELUDE_POSITION
34 ''; 58 '';
35
36} 59}
diff --git a/default.nix b/default.nix
index e8849a1..bed769c 100644
--- a/default.nix
+++ b/default.nix
@@ -11,7 +11,11 @@ let
11 in (import olderVersion {}).latest; 11 in (import olderVersion {}).latest;
12in 12in
13{ 13{
14 latest = callPackage ./clever-tools { 14 v0_9_3 = mkOlderVersion {
15 nodegit = callPackage ./nodegit {}; 15 rev = "a60f5f961215e9a011b4a0dfe651758001f116d8";
16 }; 16 sha256 = "1n831iw55di0s2izbl03xivs59792swfji2n46vhi3mkdawrsjkg";
17 };
18
19 # 1.1.0
20 latest = callPackage ./clever-tools {};
17} 21}
diff --git a/example.nix b/example.nix
index d7b53db..30142f5 100644
--- a/example.nix
+++ b/example.nix
@@ -1,9 +1,11 @@
1{ pkgs ? import <nixpkgs> {} }: with pkgs; 1{ pkgs ? import <nixpkgs> {} }: with pkgs;
2 2
3let clever-tools = fetchFromGitHub { 3let clever-tools = import (fetchFromGitHub {
4 owner = "fretlink"; 4 owner = "fretlink";
5 repo = "clever-tools-nix"; 5 repo = "clever-tools-nix";
6 rev = "DESIRED_REVISION_HASH"; 6 rev = "master";
7 sha256 = "CONTENT_HASH"; 7 sha256 = "computed_hash";
8 }; 8 }) {};
9in (import clever-tools {}).latest # select appropriate version 9 # select appropriate version (see default.nix for the supported one)
10 # clever-tools.v0_9_3
11in clever-tools.latest
diff --git a/nodegit/default.nix b/nodegit/default.nix
deleted file mode 100644
index 4bf6dd1..0000000
--- a/nodegit/default.nix
+++ /dev/null
@@ -1,35 +0,0 @@
1{ stdenv, fetchurl, curl, glibc, openssl }:
2
3assert stdenv.system == "x86_64-linux";
4
5stdenv.mkDerivation rec {
6 name = "nodegit-${version}-node-v51";
7 version = "0.20.3";
8
9 src = fetchurl {
10 url = "https://nodegit.s3.amazonaws.com/nodegit/nodegit/nodegit-v${version}-node-v51-linux-x64.tar.gz";
11 sha256 = "d022a88e58fa70f78b59b475fa6ecc6724d372a779b132264cf571f71bc50020";
12 };
13
14 libPath = stdenv.lib.makeLibraryPath [
15 stdenv.cc.cc
16 (curl.override {
17 sslSupport = false;
18 gnutlsSupport = true;
19 })
20 glibc
21 openssl
22 ];
23
24 installPhase = ''
25 tar --extract --file=$src Release/nodegit.node --transform 's/Release\//linux-/'
26 lib=$out/lib/nodegit.node
27 mkdir -p $out/lib
28 mv linux-nodegit.node $lib
29 '';
30
31 preFixup = ''
32 lib=$out/lib/nodegit.node
33 patchelf --set-rpath "$libPath" "$lib"
34 '';
35}