Bundle Nix derivations to run anywhere!
Go to file
2017-02-06 16:18:09 -06:00
.gitignore Mod .gitignore. 2016-06-15 18:53:25 +00:00
appdir.nix Add nix2appimage.sh script. 2017-02-06 16:18:09 -06:00
appimage.nix Add nix2appimage.sh script. 2017-02-06 16:18:09 -06:00
appimagetool.nix Add nix2appimage.sh script. 2017-02-06 16:18:09 -06:00
arx.nix Add nix-bundle.sh. 2016-11-26 01:05:43 -06:00
default.nix Add nix2appimage.sh script. 2017-02-06 16:18:09 -06:00
install-nix-from-closure.sh Add nix installer. 2016-06-15 18:53:47 +00:00
makebootstrap.nix Add nix-bundle.sh. 2016-11-26 01:05:43 -06:00
maketar.nix Quiet output. 2016-11-28 22:15:41 -06:00
nix2appimage.sh Add nix2appimage.sh script. 2017-02-06 16:18:09 -06:00
nix-bootstrap.nix Add nix-bundle.sh. 2016-11-26 01:05:43 -06:00
nix-bundle.sh Get rid of cg warning 2016-11-28 12:20:50 -06:00
nix-installer.nix Add nix-bundle.sh. 2016-11-26 01:05:43 -06:00
nix-user-chroot.nix Get rid of gcc hacks. 2016-11-28 22:11:50 -06:00
README.md Update README.md 2017-02-02 22:56:41 -06:00

nix-bundle

nix-bundle is a way to package Nix attributes into single-file executables.

Benefits

  • Single-file output
  • Can be run by non-root users
  • No runtime
  • Distro agnostic
  • Completely portable
  • No installation

Getting started

Make sure you have installed Nix already. See http://nixos.org/nix/ for more details.

Once you have a working Nix install, you can run:

$ ./nix-bundle.sh hello /bin/hello

This will create the file "hello". Running it:

$ ./hello
Hello, world!

This is a standalone file that is completely portable! As long as you are running a Linux kernel with the same architecture that you ran the command on it will run. No external dependencies are required besides a compatible Linux kernel.

Some others to try:

./nix-bundle.sh nano /bin/nano
./nix-bundle.sh firefox /bin/firefox
./nix-bundle.sh emacs /bin/emacs

Comparison with AppImage, FlatPak, Snappy

Name Distro-agnostic Runtime required Root required Storage Packaged size of vlc
nix-bundle yes no no Arx tarball 176M
AppImage yes no no ISO 9660 w/ zisofs compression 80M
FlatPak yes yes no ? ?
Snappy yes yes no squashFS 115M

How it works

Nix-bundle glues together four different projects to work correctly:

  • Arx - an archive execution tool
    • Creates single-file archive executable that can unpack themselves and then run some command. nix-bundle calls nix-user-chroot to bootstrap the Nix environment. It outputs a "./nix" folder.
  • nix-user-chroot - a small bootstrap that uses Linux namespaces to call chroot
    • This will create sub namespace and bind mount the "./nix" to "/nix" so that the Nix references function properly.
  • Nix - a functional package manager
    • Used to build runtime closures that are self-contained.
  • nixpkgs
    • Provides lots of different packages to choose from.

Drawbacks

Nix-bundle has some drawbacks that need to be worked on:

  • Slow startup
  • Large files (Firefox 150MB)
  • Only compatible Linux
  • Outputs built on x86-64 will not run on i386
  • Requires Linux kernel with CAP_SYS_USER_NS on and permissions setup correctly