Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Basic scaffolding in preparation for a binary
- Loading branch information
Showing
4 changed files
with
3,943 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ pkgs, nodejs }: | ||
|
||
let | ||
nodeEnv = import ./node-env.nix { | ||
inherit (pkgs) stdenv python2 utillinux runCommand writeTextFile; | ||
inherit nodejs; | ||
libtool = if pkgs.stdenv.isDarwin then pkgs.darwin.cctools else null; | ||
}; | ||
in | ||
import ./node-packages.nix { | ||
inherit (pkgs) fetchurl fetchgit; | ||
inherit nodeEnv; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
{ stdenv, lib, fetchurl }: | ||
|
||
stdenv.mkDerivation rec { | ||
pname = "cardano-graphql"; | ||
version = "1.2.1"; | ||
src = fetchurl { | ||
url = "https://github.com/hasura/graphql-engine/releases/download/v${version}/cli-ext-hasura-linux.tar.gz"; | ||
sha256 = "013m4f56mf2rx6mjkfki64xblvjjcwb0n70ny8wykwqzj5cp1pr5"; | ||
}; | ||
sourceRoot = "."; | ||
buildPhase = ":"; | ||
installPhase = '' | ||
mkdir -p $out/bin | ||
cp cli-ext-hasura-linux $out/bin/ | ||
''; | ||
preFixup = let | ||
libPath = lib.makeLibraryPath [ stdenv.cc.cc ]; | ||
in '' | ||
orig_size=$(stat --printf=%s $out/bin/cli-ext-hasura-linux) | ||
patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" $out/bin/cli-ext-hasura-linux | ||
patchelf --set-rpath ${libPath} $out/bin/cli-ext-hasura-linux | ||
new_size=$(stat --printf=%s $out/bin/cli-ext-hasura-linux) | ||
###### 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" $out/bin/cli-ext-hasura-linux | cut -d: -f1) | ||
location=$(expr $location + $var_skip) | ||
value=$(dd if=$out/bin/cli-ext-hasura-linux iflag=count_bytes,skip_bytes skip=$location \ | ||
bs=1 count=$var_select status=none) | ||
value=$(expr $shift_by + $value) | ||
echo -n $value | dd of=$out/bin/cli-ext-hasura-linux bs=1 seek=$location conv=notrunc | ||
} | ||
fix_offset PAYLOAD_POSITION | ||
fix_offset PRELUDE_POSITION | ||
''; | ||
dontStrip = true; | ||
} |
Oops, something went wrong.