DavHau/nix-portable
{ "createdAt": "2021-02-08T07:12:43Z", "defaultBranch": "main", "description": "Nix - Static, Permissionless, Installation-free, Pre-configured", "fullName": "DavHau/nix-portable", "homepage": "", "language": "Nix", "name": "nix-portable", "pushedAt": "2025-09-22T00:10:34Z", "stargazersCount": 1163, "topics": [ "bubblewrap", "bwrap", "namespaces", "nix", "nixos", "package-management", "package-manager", "permissionless", "portable", "proot" ], "updatedAt": "2025-11-26T03:34:06Z", "url": "https://github.com/DavHau/nix-portable"}
đȘ© Use nix on any linux system, rootless and configuration free.
đ„ new: Create software bundles that work on any linux distribution.
Get nix-portable
Section titled âGet nix-portableâcurl -L https://github.com/DavHau/nix-portable/releases/latest/download/nix-portable-$(uname -m) > ./nix-portable
chmod +x ./nix-portableUse nix via nix-portable
Section titled âUse nix via nix-portableâThere are two ways to run nix:
Method 1: Pass nix command line:
Section titled âMethod 1: Pass nix command line:â./nix-portable nix-shell --helpMethod 2: Symlink against nix-portable:
Section titled âMethod 2: Symlink against nix-portable:âTo create a nix-shell executable, create a symlink ./nix-shell against ./nix-portable.
ln -s ./nix-portable ./nix-shellThen use the symlink as an executable:
./nix-shell --helpThis works for any other nix native executable.
Get and execute programs
Section titled âGet and execute programsâHint: Use search.nixos.org to find available programs.
Run a program without installing it
Section titled âRun a program without installing itâ./nix-portable nix run nixpkgs#htopCreate a temporary environment with multiple programs
Section titled âCreate a temporary environment with multiple programsâ-
Enter a temporary environment with
htopandvim:./nix-portable nix shell nixpkgs#{htop,vim} -
execute htop
htop
Bundle programs
Section titled âBundle programsânix-portable can bundle arbitrary software into a static executable that runs on any* linux distribution.
Prerequisites: Your software is already packaged for nix.
Optional: If you donât have nix yet, get nix-portable, then enter a temporary environment with nix and bash:
./nix-portable nix shell nixpkgs#{bashInteractive,nix} -c bashExamples:
Bundle gnu hello:
Section titled âBundle gnu hello:âCreate a bundle containing hello that will work on any machine:
$ nix bundle --bundler github:DavHau/nix-portable -o bundle nixpkgs#hello$ cp ./bundle/bin/hello ./hello && chmod +w hello$ ./helloHello World!Bundle python + libraries
Section titled âBundle python + librariesâBundle python with arbitrary libraries as a static executable
# create the bundle$ nix bundle --bundler github:DavHau/nix-portable -o bundle --impure --expr \ '(import <nixpkgs> {}).python3.withPackages (ps: [ ps.numpy ps.scipy ps.pandas ])'$ cp ./bundle/bin/python3 ./python3 && chmod +w ./python3
# try it out$ ./python3 -c 'import numpy, scipy, pandas; print("Success !")'Success !Bundle whole dev environment
Section titled âBundle whole dev environmentâBundle a complex development environment including tools like compilers, linters, interpreters, etc. into a static executable.
Prerequisites:
- use numtide/devshell to define your devShell (
mkShellfrom nixpkgs wonât work because it is not executable) - expose the devShell via a flake.nix based repo on github
$ nix bundle --bundler github:DavHau/nix-portable -o devshell github:<user>/<repo>#devShells.<system>.default$ cp ./devshell/bin/devshell ./devshell && chmod +w ./devshell$ ./devshellđš Welcome to devshell
[[general commands]][...]Bundle compression
Section titled âBundle compressionâTo create smaller bundles specify --bundler github:DavHau/nix-portable#zstd-max.
Supported platforms
Section titled âSupported platformsâPotentially any linux system with an x86_64 or aarch64 CPU is supported.
nix-portable is tested continuously on the following platforms:
- Distros (x86_64):
- Arch Linux
- Fedora
- Debian
- NixOS
- Ubuntu
- Distros (aarch64):
- Debian
- NixOS
- Other Environments:
- Github Actions
Under the hood
Section titled âUnder the hoodâ- The nix-portable executable is a self extracting archive, caching its contents in $HOME/.nix-portable
- Either nix, bubblewrap or proot is used to virtualize the /nix/store directory which actually resides in $HOME/.nix-portable/store
- A default nixpkgs channel is included and the NIX_PATH variable is set accordingly.
- Features
flakesandnix-commandare enabled out of the box.
Virtualization
Section titled âVirtualizationâTo virtualize the /nix/store, nix-portable supports the following runtimes, preferred in this order:
- nix (shipped via nix-portable)
- bwrap (existing installation)
- bwrap (shipped via nix-portable)
- proot (existing installation)
- proot (shipped via nix-portable)
nix-portable will auto select the best runtime for your system. In case the auto selected runtime doesnât work, please open an issue. The default runtime can be overridden via Environment Variables.
Environment Variables
Section titled âEnvironment VariablesâThe following environment variables are optional and can be used to override the default behavior of nix-portable at run-time.
NP_DEBUG (1 = debug msgs; 2 = 'set -x' for nix-portable)NP_GIT specify path to the git executableNP_LOCATION where to put the `.nix-portable` dir. (defaults to `$HOME`)NP_RUNTIME which runtime to use (must be one of: nix, bwrap, proot)NP_NIX specify the path to the static nix executable to use in case nix is selected as runtimeNP_BWRAP specify the path to the bwrap executable to use in case bwrap is selected as runtimeNP_PROOT specify the path to the proot executable to use in case proot is selected as runtimeNP_RUN override the complete command to run nix (to use an unsupported runtime, or for debugging) nix will then be executed like: $NP_RUN {nix-binary} {args...}Drawbacks / Considerations
Section titled âDrawbacks / ConsiderationsâPrograms obtained outside nix-portable cannot link against or call programs obtained via nix-portable. This is because nix-portable uses a virtualized directory to store its programs which cannot be accessed by other software on the system.
If user namespaces are not available on a system, nix-portable will fall back to using proot as an alternative mechanism to virtualize /nix. Proot can introduce significant performance overhead depending on the workload. In that situation, it might be beneficial to use a remote builder or alternatively build the derivations on another host and sync them via a cache like cachix.org.
Missing Features
Section titled âMissing Featuresâ- managing nix profiles via
nix-env - managing nix channels via
nix-channel - support MacOS
Building / Contributing
Section titled âBuilding / ContributingâTo speed up builds, add the nix-portable cache:
nix-shell -p cachix --run "cachix use nix-portable"