NixOS / nix

Nix, the purely functional package manager
https://nixos.org/
GNU Lesser General Public License v2.1
12.75k stars 1.52k forks source link

Nix binary package without build toolchain (purely from cache)? #457

Open hilyjiang opened 9 years ago

hilyjiang commented 9 years ago

I think nix is good enough for developers. But for normal user, they may expect to download all packages from cache, so they don't need those development tools (take too many space).

Is it possible to distribute nix without build toolchain (make, gcc, etc.)? Just separate nix to two derivations:

wmertens commented 9 years ago

:+1: sounds nice for VMs meant to be NixOps targets too. As soon as you need a build chain it will download it right?

hilyjiang commented 9 years ago

We decide to use nix to distribute our product, but our customers don't use nix at all. So we need to install nix first for them.

But currently the size of nix binary package is really too big for them (our product is just about ~5MB)。So we try to find the way to let it be smaller.

If the size of nix binary package can smaller down to <20MB, distribute our product with it would be great (powerful, embedded with small size :P).

Now the nix binary package is about 69M, and about 231M after uncompress. If we remove gcc (89M) and perl (size: 54M) from it, the size of the package would be small down significantly (62% off uncompress, 65% off tarball).

# du -sh /nix/store/*/
3.9M    /nix/store/16za1lqa47rayyn9058i4a1nv358gnv5-nix-1.8/
388K    /nix/store/584hmj4dvlp9aj9n4kcc52a5wz1aq9ac-zlib-1.2.8/
1.4M    /nix/store/69jq4mnkb3zvc0y2pk12cgrbq6by8n4p-sqlite-3.8.7.1/
6.8M    /nix/store/79r6ys4r2nfv1d5h6ryc1gwc8j25r86w-openssl-1.0.1j/
940K    /nix/store/7rlvlgy875zs98y3rz06mmnaaa66vbr7-xz-5.0.7/
256K    /nix/store/axlmi5nry426xzq62v62j75v9rdv74za-cacert-20140715/
568K    /nix/store/c2p56z920h4mxw12pjw053sqfhhh0l0y-acl-2.2.52/
2.4M    /nix/store/d4b4avbsbcz4hbf35r1270rdkfk7gf7y-perl-DBI-1.631/
356K    /nix/store/dqmh55k38i24h9xnb4qb5pqggfl4dvxm-bzip2-1.0.6/
54M     /nix/store/g9ybksy400pfn7fncw8dqfnz6m7fdyrk-perl-5.20.1/
412K    /nix/store/jd3gggw5bs3a6sbjnwhjapcqr8g78f5c-attr-2.4.47/
464K    /nix/store/jhdnwklzq2pakz7sp631pf48vfbrgfcv-perl-DBD-SQLite-1.44/
8.0K    /nix/store/l1jay99nhry9n4y1d7wij405q8rp2p9p-user-environment/
35M     /nix/store/la5imi1602jxhpds9675n2n2d0683lbq-glibc-2.20/
89M     /nix/store/lg4pnma41vc1vvlb4qsriphk7sq4762r-gcc-4.8.3/
2.0M    /nix/store/msy4kfrb732qyf5zs2f42vc2hwsdg4jc-curl-7.39.0/
5.2M    /nix/store/qwwxgsg6l33lhx0v75mgmb077qggh8yl-linux-headers-3.12.32/
7.0M    /nix/store/r5sxfcwq9324xvcd1z312kb9kkddqvld-bash-4.3-p30/
3.0M    /nix/store/rygv74phd82c106qynz7l0rmg4rvrlzd-gnutar-1.27.1/
292K    /nix/store/sr65fbmyvsrzd4vbgvx1pkqm6a04hzas-gzip-1.6/
960K    /nix/store/vp1hy9kspmnmhd5gq1izvc7xc9855lr8-libssh2-1.4.3/
16M     /nix/store/wc472nw0kyw0iwgl6352ii5czxd97js2-coreutils-8.23/
204K    /nix/store/wg4dxpl9c9xfr1zg4j80j4c4n5s626sy-perl-WWW-Curl-4.17/
1.1M    /nix/store/x8l1vvq8fbwlx1iizf5sx2blb4fqcrlh-boehm-gc-7.2f/

Then we can implement a new command like nix-get -i to install purely from cache. If no cache found, return error and give a guide to nix-env -i to build it .

I expect that nix won't download build toolchain automatically unless we install it explicitly.

wmertens commented 9 years ago

Actually Nix needs Perl for a few things but gcc can go. I'm sure it will download it when needed.

You could always distribute your own tarball... You wouldn't even need nix unless you want to change the store...

Wout.

On Sat, Jan 24, 2015, 2:41 PM Hily Jiang notifications@github.com wrote:

We decide to use nix to distribute our product, but our customers don't use nix at all. So we need to install nix first for them.

But currently the size of nix binary package is really too big for them (our product is just about ~5MB)。So we try to find the way to let it be smaller.

If the size of nix binary package can smaller down to <20MB, distribute our product with it would be great (powerful, embedded with small size :P).

Now the nix binary package is about 69M, and about 231M after uncompress. If we remove gcc (89M) and perl (size: 54M) from it, the size of the package would be small down significantly (62% off uncompress, 65% off tarball).

du -sh /nix/store/*/

3.9M /nix/store/16za1lqa47rayyn9058i4a1nv358gnv5-nix-1.8/ 388K /nix/store/584hmj4dvlp9aj9n4kcc52a5wz1aq9ac-zlib-1.2.8/ 1.4M /nix/store/69jq4mnkb3zvc0y2pk12cgrbq6by8n4p-sqlite-3.8.7.1/ 6.8M /nix/store/79r6ys4r2nfv1d5h6ryc1gwc8j25r86w-openssl-1.0.1j/ 940K /nix/store/7rlvlgy875zs98y3rz06mmnaaa66vbr7-xz-5.0.7/ 256K /nix/store/axlmi5nry426xzq62v62j75v9rdv74za-cacert-20140715/ 568K /nix/store/c2p56z920h4mxw12pjw053sqfhhh0l0y-acl-2.2.52/ 2.4M /nix/store/d4b4avbsbcz4hbf35r1270rdkfk7gf7y-perl-DBI-1.631/ 356K /nix/store/dqmh55k38i24h9xnb4qb5pqggfl4dvxm-bzip2-1.0.6/ 54M /nix/store/g9ybksy400pfn7fncw8dqfnz6m7fdyrk-perl-5.20.1/ 412K /nix/store/jd3gggw5bs3a6sbjnwhjapcqr8g78f5c-attr-2.4.47/ 464K /nix/store/jhdnwklzq2pakz7sp631pf48vfbrgfcv-perl-DBD-SQLite-1.44/ 8.0K /nix/store/l1jay99nhry9n4y1d7wij405q8rp2p9p-user-environment/ 35M /nix/store/la5imi1602jxhpds9675n2n2d0683lbq-glibc-2.20/ 89M /nix/store/lg4pnma41vc1vvlb4qsriphk7sq4762r-gcc-4.8.3/ 2.0M /nix/store/msy4kfrb732qyf5zs2f42vc2hwsdg4jc-curl-7.39.0/ 5.2M /nix/store/qwwxgsg6l33lhx0v75mgmb077qggh8yl-linux-headers-3.12.32/ 7.0M /nix/store/r5sxfcwq9324xvcd1z312kb9kkddqvld-bash-4.3-p30/ 3.0M /nix/store/rygv74phd82c106qynz7l0rmg4rvrlzd-gnutar-1.27.1/ 292K /nix/store/sr65fbmyvsrzd4vbgvx1pkqm6a04hzas-gzip-1.6/ 960K /nix/store/vp1hy9kspmnmhd5gq1izvc7xc9855lr8-libssh2-1.4.3/ 16M /nix/store/wc472nw0kyw0iwgl6352ii5czxd97js2-coreutils-8.23/ 204K /nix/store/wg4dxpl9c9xfr1zg4j80j4c4n5s626sy-perl-WWW-Curl-4.17/ 1.1M /nix/store/x8l1vvq8fbwlx1iizf5sx2blb4fqcrlh-boehm-gc-7.2f/

Then we can implement a new command like nix-get -i to install purely from cache. If no cache found, return error and give a guide to nix-env -i to build it .

I expect that nix won't download build toolchain automatically unless we install it explicitly.

— Reply to this email directly or view it on GitHub https://github.com/NixOS/nix/issues/457#issuecomment-71317090.

copumpkin commented 9 years ago

I think the main issue is that stdenv has a cc field that points to a wrapper around the compiler, which means the stdenv has a runtime dependency on a compiler.

lucabrunox commented 9 years ago

@copumpkin doesn't mean programs must depend on gcc. In fact, if you correctly strip a program (like most of programs in nixpkgs), it doesn't depend on gcc. Don't know what's going on with nix requiring gcc though.

copumpkin commented 9 years ago

@lethalman https://github.com/NixOS/nixpkgs/issues/5895 might be some of the cause

lucabrunox commented 9 years ago

@copumpkin yes, also nix itself and boehm-gc have a direct dependency on gcc

lucabrunox commented 9 years ago

cc @edolstra may know more

edolstra commented 9 years ago

This is what the multiple outputs support in Nix is for. It allows packages to depend on only (say) the libstdc++.so part of gcc. See NixOS/Nixpkgs@dbe432e6f4502fc7b4e290d1b3356083bd93b099 for some numbers.

stale[bot] commented 3 years ago

I marked this as stale due to inactivity. → More info

stale[bot] commented 2 years ago

I closed this issue due to inactivity. → More info