[Nix-dev] deploying nix-built software to non-nix linux systems

Lluís Batlle i Rossell viric at viric.name
Tue Nov 4 10:25:30 CET 2014


On Tue, Nov 04, 2014 at 10:23:08AM +0100, Eelco Dolstra wrote:
> Hi,
> 
> On 04/11/14 00:36, Anders Papitto wrote:
> 
> > I'm interested in using nix/nixos to build an application with its
> > full set of dependencies, and then deploy it to non-nixos machines as
> > a self-contained package (up to and including the system libraries),
> > without root privileges. Ideally I would like to not require that any
> > nix tools be available on the target system. The perfect workflow
> > would be something like
> > 
> > # on any linux system
> > $ wget https://some/path/to/my-app.tar.gz
> > $ tar -xf my-app.tar.gz
> > $ ./my-app/bin/my-app # run the application -> it should not try to
> > access anything outside ./my-app
> > 
> > Is this possible? 
> 
> No, this is not possible unless you do static linking or some deep
> ld-linux/patchelf magic. For instance, my-app will have references to Glibc in
> the Nix store, which are not relocatable.

If it's only about dynamic linking, you can put all into a directory, and go
with a sh script that sets the proper LD_LIBRARY_PATH and calls the proper
dynamic loader to load the wanted ELF.

LD_LIBRARY_PATH=`pwd` ./ld-linux.so.3 ./myprogram

It may work. :)


More information about the nix-dev mailing list