nix-bundle icon indicating copy to clipboard operation
nix-bundle copied to clipboard

WIP: use proot and xz

Open DavHau opened this issue 5 years ago • 2 comments

(currently based against v0.4.0 since master is broken)

I switched out nix-user-chroot with proot, since proot doesn't require userspaces and therefore should work on all distros. This should solve https://github.com/matthewbauer/nix-bundle/issues/50

I also swapped out bzip2 with xz -1 (lzma) which uses multiple cores to compress and also should be significantly faster to extract according to online benchmarks (see for example: https://www.rootusers.com/gzip-vs-bzip2-vs-xz-performance-comparison/)

Alternatively we could use gzip/pigz to compress, which would be even faster to decompress, but the file size will be much larger. I found xz -1 to be a good middle ground.

The current problem is that some dependencies of proot seem to be missing. If I execute the bundled binary inside an alpine docker container it raises the following error: ./nix/store/mmcsv1szs7w0mjh430jrvj2nrhz6rwr8-proot-20190510/bin/proot: error while loading shared libraries: libgcc_s.so.1: cannot open shared object file: Error 20 @matthewbauer Any idea how to solve that?

Also I don't quite understand what the PATH_ENV variable previously set in makeFlags of nix-user-chroot was needed for. Maybe that could be the missing part.

Tested via:

let
  pkgs = import <unstable> {};
  nixBundle = import ./nix-bundle { nixpkgs = pkgs; };
in

nixBundle.nix-bootstrap-path {
  target = pkgs.hello;
  run = "/bin/hello"; 
}

DavHau avatar Nov 16 '20 05:11 DavHau

@DavHau any idea if this will be incorporated into the project? nix-bundle looks very exciting, but it still has these issues :(

takeda avatar Apr 14 '21 00:04 takeda

I was originally working on this PR because I wanted to use this bundler for https://github.com/davhau/nix-portable But eventually I ended up doing my own bundling from scratch.

Anyways, I think the fix here is simple. Proot needs to be built static. But then again, the nixpkgs static proot package is broken. We could just pull a static proot binary from proot's gitlab like I did it with nix-portable.

DavHau avatar Apr 14 '21 06:04 DavHau