nix-gl-host icon indicating copy to clipboard operation
nix-gl-host copied to clipboard

Consider porting to a language that doesn't require a runtime

Open arilotter opened this issue 1 year ago • 4 comments
trafficstars

In contexts where you don't require a Python install for other things, including nix-gl-host drags along of python 3 as a ~100mb bump in size.

For example - I have a Rust program that I package into a Docker image, and nix-gl-host ups that image size by 100mb due to its Python dep. I've ported nix-gl-host to Rust here https://github.com/arilotter/nix-gl-host-rs and it seems to work perfectly!

arilotter avatar Oct 30 '24 18:10 arilotter

Is that project really working? I've tried to -p option work( https://github.com/arilotter/nix-gl-host-rs/pull/1 ) but it's just clearing old nixglhost's cache.

Also is the footprint of python nix-gl-host large? I've calculated size of my cache(cuda+gl drivers) but it's far more large:

du -sh ~/.cache/nix-gl-host/
3.1G    ~/.cache/nix-gl-host/

And is rust with libc runtime free? You're using patchelf that also requires libc

$ nix-store -q --tree result
/nix/store/g6f6sk3cxfdv01zaj9b46dhfsv9ypbkd-nixglhost-0.1.0
├───/nix/store/5adwdl39g3k9a2j0qadvirnliv4r7pwd-glibc-2.39-52
│   ├───/nix/store/h44h6473all3qkrjjhkm3v0fv63lqyms-libidn2-2.3.7
│   │   ├───/nix/store/f4dfwhawi5kn71k0q1rj296w33i61vp6-libunistring-1.2
│   │   │   └───/nix/store/f4dfwhawi5kn71k0q1rj296w33i61vp6-libunistring-1.2 [...]
│   │   └───/nix/store/h44h6473all3qkrjjhkm3v0fv63lqyms-libidn2-2.3.7 [...]
│   ├───/nix/store/kx9pbw29jml0fgrpkb89f029w25qyxwc-xgcc-13.3.0-libgcc
│   └───/nix/store/5adwdl39g3k9a2j0qadvirnliv4r7pwd-glibc-2.39-52 [...]
├───/nix/store/jfilhsiqdgm4nks2z6labx3iq9qd077a-gcc-13.3.0-lib
│   ├───/nix/store/5adwdl39g3k9a2j0qadvirnliv4r7pwd-glibc-2.39-52 [...]
│   ├───/nix/store/mqnjhrjh72d6i4nn2rr7n6nl24qjjvcs-gcc-13.3.0-libgcc
│   └───/nix/store/jfilhsiqdgm4nks2z6labx3iq9qd077a-gcc-13.3.0-lib [...]
└───/nix/store/ywz6s6bzap4x6yhg2lrx3ibqcnv051c7-patchelf-0.15.0
    ├───/nix/store/5adwdl39g3k9a2j0qadvirnliv4r7pwd-glibc-2.39-52 [...]
    └───/nix/store/jfilhsiqdgm4nks2z6labx3iq9qd077a-gcc-13.3.0-lib [...]

aim-nara avatar Oct 31 '24 02:10 aim-nara

Nice! Porting this to Rust was indeed part of our roadmap!

I sadly don't have any Nvidia GPU anymore to test this :( (See https://github.com/numtide/nix-gl-host/issues/7#issuecomment-1704905762 for more details)

If anybody's willing to take over this project to push it forward, we could definitely move this to nix-communiy and add new maintainers to it.

Ping @Atry @wentasah @SomeoneSerge who also expressed some degree of interest for this project in the past as well.

picnoir avatar Oct 31 '24 06:10 picnoir

ah nice catch, I mis-implemented -p. will fix. it does seem to work for wrapping executables, it lets me run a Nix CUDA application in an Ubuntu docker image :)

Also is the footprint of python nix-gl-host large?

it's about 100mb. I'm golfing all my dependencies down in size and this one seemed easy to tackle.

arilotter avatar Oct 31 '24 12:10 arilotter

FYI, in your rust port, you forgot to port the parsing of ld.so.conf (https://github.com/numtide/nix-gl-host/blob/main/src/nixglhost.py#L275-L276). This seems to be needed for PopOS. I will try to fix it. Once it's done I will open a PR for your fork

tangtang95 avatar Feb 05 '25 18:02 tangtang95