New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
now-cli: init at 11.4.6 #48193
now-cli: init at 11.4.6 #48193
Conversation
I was quite surprised to find that genericBuild can't handle plain .gz files. |
67e16c9
to
893fd62
Compare
@GrahamcOfBorg build now-cli |
No attempt on x86_64-darwin (full log) The following builds were skipped because they don't evaluate on x86_64-darwin: now-cli Partial log (click to expand)
|
Success on x86_64-linux (full log) Attempted: now-cli Partial log (click to expand)
|
Success on aarch64-linux (full log) Attempted: now-cli Partial log (click to expand)
|
PRELUDE=$(expr 4096 + $PRELUDE) | ||
|
||
echo -n $PAYLOAD | dd of=$out/bin/now bs=1 seek=$PAYLOAD_offset conv=notrunc | ||
echo -n $PRELUDE | dd of=$out/bin/now bs=1 seek=$PRELUDE_offset conv=notrunc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use a function to abstract these two patches
|
||
#TODO: calcuate required adjustment? | ||
PAYLOAD=$(expr 4096 + $PAYLOAD) | ||
PRELUDE=$(expr 4096 + $PRELUDE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a fan of these hardcoded numbers, how resilient are these for future updates? Also how did you get these numbers? Would be worth a short comment on that (the 20, 22 and 4096).
I guess it's fine, as long as it runs, if people really want this package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found these numbers by experimentation, and looking at the file with xxd.
I did however just notice patchelf --debug
which gives the following output:
$ patchelf --debug --set-interpreter /nix/store/fg4yq8i8wd08xg3fy58l6q73cjy8hjr2-glibc-2.27/lib/ld-linux-x86-64.so.2 ./now-test
patching ELF file `./now-test'
Kernel page size is 4096 bytes
replacing section `.interp' with size 80
this is an executable
using replaced section `.interp'
last replaced is 1
looking at section `.interp'
first reserved offset/addr is 0x254/0x400254
first page is 0x400000
needed space is 648
needed space is 704
needed pages is 1
changing alignment of program header 2 from 2097152 to 4096
changing alignment of program header 3 from 2097152 to 4096
clearing first 4068 bytes
rewriting section `.interp' from offset 0x1238 (size 28) to offset 0x270 (size 80)
rewriting symbol table section 5
rewriting symbol table section 38
Does that give any insight as to how safe the patch is?
# with zeit/pkg to be run on nixos. | ||
|
||
preFixup = let | ||
libPath = lib.makeLibraryPath [stdenv.cc.cc.lib]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makeLibraryPath
already takes the .lib
output if it exists, so you can remove that.
@@ -0,0 +1,68 @@ | |||
{ stdenv, lib, makeWrapper, fetchurl }: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makeWrapper
is unused
@infinisil RE Your review: How's that? |
# [...] | ||
# PRELUDE_POSITION = '1234 ' | 0 | ||
# ^-----20-chars-----^^------22-chars------^ | ||
# ^-- grep points here |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's been a while but here is an alternative solution, maybe its useful
perl -pe 's/(var PAYLOAD_POSITION = .)(\d+)/$1 . ($2 + 4096)/e; s/(var PRELUDE_POSITION = .)(\\d+)/$1 . ($2 + 4096)/e;' < tailwind-freebsd-x64 > tailwind-damien
This relies on rpath injection causing a 4096 byte extension obviously.
works on FreeBSD.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thing left to do for the future is to add macOS support too. This is looking good as it is now. when you squash the last commit I'll merge this.
Guys this is awesome - you've just saved my weekend! |
5de8595
to
e3b313b
Compare
Unfortunately, I don't have a Mac. How much of the existing work can be shared with a macOS system? (I know that Zeit provide a macOS binary explicitly) @Hinidu I'm lightly horrified that Unity has the same issues as package did. |
@brendan-hall they use |
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/unrelatable-error-when-working-with-patchelf/12043/3 |
Motivation for this change
Adds Zeit's now-cli, per #36395 (sorry @giodamelio)
Uses the binary distribution, which presented some challenges as it's essentially an archive of a nodejs, and all the js files, with hardcoded offsets to said files.
Things done
sandbox
innix.conf
on non-NixOS)Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)Tested compilation of all pkgs that depend on this change usingnix-shell -p nox --run "nox-review wip"
./result/bin/
)nix path-info -S
before and after)