]> git.immae.eu Git - github/fretlink/clever-tools-nix.git/commitdiff
upgrade to 1.1.0 and get rid of nodegit
authorHussein Ait-Lahcen <hussein.ait-lahcen@fretlink.com>
Mon, 5 Nov 2018 15:13:32 +0000 (16:13 +0100)
committerHussein Ait-Lahcen <hussein.ait-lahcen@fretlink.com>
Mon, 5 Nov 2018 16:14:21 +0000 (17:14 +0100)
README.md
check.sh
clever-tools/default.nix
default.nix
example.nix
nodegit/default.nix [deleted file]

index b47a4bce390d8c38067272c4ce6124caa52a41ba..ec8e333b397a22efcc9ac551160c28bb089d1433 100644 (file)
--- a/README.md
+++ b/README.md
@@ -12,14 +12,4 @@ Main job of those derivations is to use patchelf to make it nix compliant.
 
 ## How to use it
 
-```nix
-{ pkgs ? import <nixpkgs> {} }: with pkgs;
-
-let clever-tools = fetchFromGitHub {
-                     owner  = "fretlink";
-                     repo   = "clever-tools-nix";
-                     rev    = "DESIRED_REVISION_HASH";
-                     sha256 = "CONTENT_HASH";
-                   };
-in (import clever-tools {}).latest # select appropriate version
-```
+[See the example.nix](https://github.com/fretlink/clever-tools-nix/blob/master/example.nix)
index 1b14239b76c2bdd0a7c37c352701312c2389296d..8515fa442c341dca2683b6d87f913a5e7364ce1e 100755 (executable)
--- a/check.sh
+++ b/check.sh
@@ -1 +1 @@
-[ "$(clever --version)" == "0.9.3" ]
+[ "$(clever --version)" == "1.1.0" ]
index 6c729a51bdacfbae45695c3ff4dc5e890eb04da3..9ac69e60b094f4931fe7b6567ae50226209b506d 100644 (file)
@@ -1,36 +1,59 @@
-{ stdenv, fetchurl, glibc, nodegit }:
+{ stdenv, fetchurl, glibc }:
 
 stdenv.mkDerivation rec {
   name = "clever-tools-${version}";
-  version = "0.9.3";
+  version = "1.1.0";
 
   src = fetchurl {
     url = "https://clever-tools.cellar.services.clever-cloud.com/releases/${version}/clever-tools-${version}_linux.tar.gz";
-    sha256 = "adcae5af912dcbdc74d996b6e94767f24d16bf1bdcd5073797f999fe75b018a4";
+    sha256 = "1lkwckmlz2gf41xmnzydpcbly0jcry3bn8lp570gha768ic7xmb1";
   };
 
-  buildInputs = [ nodegit ];
-
   libPath = stdenv.lib.makeLibraryPath [ stdenv.cc.cc glibc ];
 
-  nodegitLibrary = stdenv.lib.makeLibraryPath [ nodegit ];
-
   installPhase = ''
-    tar --extract --file=$src linux/clever --transform 's/linux\///'
+    tar --extract --file=$src
     bin=$out/bin/clever
     mkdir -p $out/bin
     mv clever $bin
-    ln -s "$nodegitLibrary/nodegit.node" "$out/bin/nodegit.node"
   '';
 
   dontStrip = "true";
 
+  # See https://github.com/brendan-hall/nixpkgs/blob/e3b313bb59f49f10970205aafd44878d35da07e7/pkgs/development/web/now-cli/default.nix#L25
+  # There is no helper in nixpkgs lib right now
+  # The algorithm for zeit/pkg fix is given https://github.com/NixOS/nixpkgs/pull/48193
+  # it has been used for Unity3D as well https://github.com/NixOS/nixpkgs/pull/48643
   preFixup = ''
     bin=$out/bin/clever
-    patchelf \
-      --set-rpath "$libPath" \
-      --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
-      "$bin"
+    orig_size=$(stat --printf=%s $bin)
+    patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" $bin
+    patchelf --set-rpath ${libPath} $bin
+    new_size=$(stat --printf=%s $bin)
+    ###### zeit-pkg fixing starts here.
+    # we're replacing plaintext js code that looks like
+    # PAYLOAD_POSITION = '1234                  ' | 0
+    # [...]
+    # PRELUDE_POSITION = '1234                  ' | 0
+    # ^-----20-chars-----^^------22-chars------^
+    # ^-- grep points here
+    #
+    # var_* are as described above
+    # shift_by seems to be safe so long as all patchelf adjustments occur
+    # before any locations pointed to by hardcoded offsets
+    var_skip=20
+    var_select=22
+    shift_by=$(expr $new_size - $orig_size)
+    function fix_offset {
+      # $1 = name of variable to adjust
+      location=$(grep -obUam1 "$1" $bin | cut -d: -f1)
+      location=$(expr $location + $var_skip)
+      value=$(dd if=$bin iflag=count_bytes,skip_bytes skip=$location \
+                 bs=1 count=$var_select status=none)
+      value=$(expr $shift_by + $value)
+      echo -n $value | dd of=$bin bs=1 seek=$location conv=notrunc
+    }
+    fix_offset PAYLOAD_POSITION
+    fix_offset PRELUDE_POSITION
   '';
-
 }
index e8849a1de429145fa6034eddc3a032238cdadaa0..bed769c3b3d935a09ddd00d70cdcdbc45173fa8c 100644 (file)
@@ -11,7 +11,11 @@ let
     in (import olderVersion {}).latest;
 in
 {
-  latest = callPackage ./clever-tools {
-             nodegit = callPackage ./nodegit {};
-           };
+  v0_9_3 = mkOlderVersion {
+    rev = "a60f5f961215e9a011b4a0dfe651758001f116d8";
+    sha256 = "1n831iw55di0s2izbl03xivs59792swfji2n46vhi3mkdawrsjkg";
+  };
+
+  # 1.1.0
+  latest = callPackage ./clever-tools {};
 }
index d7b53db56dd109a5d5eec2c4572e1658463e6472..30142f582143e1166db97dee1db557c66fd90586 100644 (file)
@@ -1,9 +1,11 @@
 { pkgs ? import <nixpkgs> {} }: with pkgs;
 
-let clever-tools = fetchFromGitHub {
+let clever-tools = import (fetchFromGitHub {
                      owner  = "fretlink";
                      repo   = "clever-tools-nix";
-                     rev    = "DESIRED_REVISION_HASH";
-                     sha256 = "CONTENT_HASH";
-                   };
-in (import clever-tools {}).latest # select appropriate version
+                     rev    = "master";
+                     sha256 = "computed_hash";
+                   }) {};
+   # select appropriate version (see default.nix for the supported one)
+   # clever-tools.v0_9_3
+in clever-tools.latest
diff --git a/nodegit/default.nix b/nodegit/default.nix
deleted file mode 100644 (file)
index 4bf6dd1..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-{ stdenv, fetchurl, curl, glibc, openssl }:
-
-assert stdenv.system == "x86_64-linux";
-
-stdenv.mkDerivation rec {
-  name = "nodegit-${version}-node-v51";
-  version = "0.20.3";
-
-  src = fetchurl {
-    url = "https://nodegit.s3.amazonaws.com/nodegit/nodegit/nodegit-v${version}-node-v51-linux-x64.tar.gz";
-    sha256 = "d022a88e58fa70f78b59b475fa6ecc6724d372a779b132264cf571f71bc50020";
-  };
-
-  libPath = stdenv.lib.makeLibraryPath [
-              stdenv.cc.cc
-              (curl.override {
-                sslSupport = false;
-                gnutlsSupport = true;
-              })
-              glibc
-              openssl
-            ];
-
-  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"
-  '';
-}