{"id":13647657,"url":"https://github.com/DavHau/nix-portable","last_synced_at":"2025-04-22T02:32:22.059Z","repository":{"id":37842831,"uuid":"336990093","full_name":"DavHau/nix-portable","owner":"DavHau","description":"Nix - Static, Permissionless, Installation-free, Pre-configured","archived":false,"fork":false,"pushed_at":"2025-04-21T00:10:24.000Z","size":137,"stargazers_count":998,"open_issues_count":64,"forks_count":39,"subscribers_count":17,"default_branch":"main","last_synced_at":"2025-04-21T01:27:53.688Z","etag":null,"topics":["bubblewrap","bwrap","namespaces","nix","nixos","package-management","package-manager","permissionless","portable","proot"],"latest_commit_sha":null,"homepage":"","language":"Nix","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DavHau.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-02-08T07:12:43.000Z","updated_at":"2025-04-20T09:26:12.000Z","dependencies_parsed_at":"2024-03-11T13:43:48.258Z","dependency_job_id":"dce5cb87-90fa-4c15-ac33-64ea8c15b6fe","html_url":"https://github.com/DavHau/nix-portable","commit_stats":{"total_commits":132,"total_committers":11,"mean_commits":12.0,"dds":"0.31060606060606055","last_synced_commit":"8cc5dfb09b65b17faa591c7e9ec791a2f3b58749"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DavHau%2Fnix-portable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DavHau%2Fnix-portable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DavHau%2Fnix-portable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DavHau%2Fnix-portable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DavHau","download_url":"https://codeload.github.com/DavHau/nix-portable/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250163768,"owners_count":21385308,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bubblewrap","bwrap","namespaces","nix","nixos","package-management","package-manager","permissionless","portable","proot"],"created_at":"2024-08-02T01:03:41.669Z","updated_at":"2025-04-22T02:32:21.812Z","avatar_url":"https://github.com/DavHau.png","language":"Nix","funding_links":[],"categories":["Nix","package-manager","Installation Media"],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n\u003cimg width=\"400\" src=\"https://gist.githubusercontent.com/DavHau/755fed3774e89c0b9b8953a0a25309fa/raw/fdb8b96eeb94d3b8a79481fa6fad53281e10b15d/nix_portable_2021-04-28_bw.png\"\u003e\n\u003c/p\u003e\n\n🪩 Use nix on any linux system, rootless and configuration free.\n\n🔥 new:  [Create software bundles](#bundle-programs) that work on any linux distribution.\n\n[💾 Downloads](https://github.com/DavHau/nix-portable/releases)\n\n---\n\n### Get nix-portable\n```shellSession\ncurl -L https://github.com/DavHau/nix-portable/releases/latest/download/nix-portable-$(uname -m) \u003e ./nix-portable\n\nchmod +x ./nix-portable\n```\n\n### Use nix via nix-portable\n\nThere are two ways to run nix:\n\n#### Method 1: Pass nix command line:\n\n```shellSession\n./nix-portable nix-shell --help\n```\n\n#### Method 2: Symlink against nix-portable:\n\nTo create a `nix-shell` executable, create a symlink `./nix-shell` against `./nix-portable`.\n\n```shellSession\nln -s ./nix-portable ./nix-shell\n```\n\nThen use the symlink as an executable:\n\n```shellSession\n./nix-shell --help\n```\n\nThis works for any other nix native executable.\n\n### Get and execute programs\n\nHint: Use [search.nixos.org](https://search.nixos.org/packages) to find available programs.\n\n#### Run a program without installing it\n\n```shellSession\n./nix-portable nix run nixpkgs#htop\n```\n\n#### Create a temporary environment with multiple programs\n\n1. Enter a temporary environment with `htop` and `vim`:\n\n    ```shellSession\n    ./nix-portable nix shell nixpkgs#{htop,vim}\n    ```\n\n2. execute htop\n\n    ```shellSession\n    htop\n    ```\n\n### Bundle programs\nnix-portable can bundle arbitrary software into a static executable that runs on [any*](#supported-platforms) linux distribution.\n\nPrerequisites: Your software is already packaged for nix.\n\n**Optional**: If you don't have nix yet, [get nix-portable](#get-nix-portable), then enter a temporary environment with nix and bash:\n\n```shellSession\n./nix-portable nix shell nixpkgs#{bashInteractive,nix} -c bash\n```\n\nExamples:\n\n#### Bundle gnu hello:\n\n\nCreate a bundle containing [hello](https://search.nixos.org/packages?channel=unstable\u0026from=0\u0026size=50\u0026sort=relevance\u0026type=packages\u0026query=hello) that will work on any machine:\n\n```shellSession\n$ nix bundle --bundler github:DavHau/nix-portable -o bundle nixpkgs#hello\n$ cp ./bundle/bin/hello ./hello \u0026\u0026 chmod +w hello\n$ ./hello\nHello World!\n```\n\n#### Bundle python + libraries\n\nBundle python with arbitrary libraries as a static executable\n\n```shellSession\n# create the bundle\n$ nix bundle --bundler github:DavHau/nix-portable -o bundle --impure --expr \\\n  '(import \u003cnixpkgs\u003e {}).python3.withPackages (ps: [ ps.numpy ps.scipy ps.pandas ])'\n$ cp ./bundle/bin/python3 ./python3 \u0026\u0026 chmod +w ./python3\n\n# try it out\n$ ./python3 -c 'import numpy, scipy, pandas; print(\"Success !\")'\nSuccess !\n```\n\n#### Bundle whole dev environment\n\nBundle a complex development environment including tools like compilers, linters, interpreters, etc. into a static executable.\n\nPrerequisites:\n- use [numtide/devshell](https://github.com/numtide/devshell) to define your devShell (`mkShell` from nixpkgs won't work because it is not executable)\n- expose the devShell via a flake.nix based repo on github\n\n```shellSession\n$ nix bundle --bundler github:DavHau/nix-portable -o devshell github:\u003cuser\u003e/\u003crepo\u003e#devShells.\u003csystem\u003e.default \n$ cp ./devshell/bin/devshell ./devshell \u0026\u0026 chmod +w ./devshell\n$ ./devshell\n🔨 Welcome to devshell\n\n[[general commands]]\n[...]\n```\n\n#### Bundle compression\n\nTo create smaller bundles specify `--bundler github:DavHau/nix-portable#zstd-max`.\n\n### Supported platforms\n\nPotentially any linux system with an **x86_64** or **aarch64** CPU is supported.\n\nnix-portable is tested continuously on the following platforms:\n\n- Distros (x86_64):\n  - Arch Linux\n  - CentOS 7\n  - Debian\n  - Fedora\n  - NixOS\n  - Ubuntu 22.04\n  - Ubuntu 23.10\n  - Ubuntu 24.04\n- Distros (aarch64):\n  - Debian\n- Other Environments:\n  - Github Actions\n  - Docker (debian image)\n\n### Under the hood\n\n- The nix-portable executable is a self extracting archive, caching its contents in $HOME/.nix-portable\n- Either nix, bubblewrap or proot is used to virtualize the /nix/store directory which actually resides in $HOME/.nix-portable/store\n- A default nixpkgs channel is included and the NIX_PATH variable is set accordingly.\n- Features `flakes` and `nix-command` are enabled out of the box.\n\n\n#### Virtualization\n\nTo virtualize the /nix/store, nix-portable supports the following runtimes, preferred in this order:\n\n- nix (shipped via nix-portable)\n- bwrap (existing installation)\n- bwrap (shipped via nix-portable)\n- proot (existing installation)\n- proot (shipped via nix-portable)\n\nnix-portable will auto select the best runtime for your system.\nIn case the auto selected runtime doesn't work, please open an issue.\nThe default runtime can be overridden via [Environment Variables](#environment-variables).\n\n### Environment Variables\n\nThe following environment variables are optional and can be used to override the default behavior of nix-portable at run-time.\n\n```txt\nNP_DEBUG      (1 = debug msgs; 2 = 'set -x' for nix-portable)\nNP_GIT        specify path to the git executable\nNP_LOCATION   where to put the `.nix-portable` dir. (defaults to `$HOME`)\nNP_RUNTIME    which runtime to use (must be one of: nix, bwrap, proot)\nNP_NIX        specify the path to the static nix executable to use in case nix is selected as runtime\nNP_BWRAP      specify the path to the bwrap executable to use in case bwrap is selected as runtime\nNP_PROOT      specify the path to the proot executable to use in case proot is selected as runtime\nNP_RUN        override the complete command to run nix\n              (to use an unsupported runtime, or for debugging)\n              nix will then be executed like: $NP_RUN {nix-binary} {args...}\n\n```\n\n### Drawbacks / Considerations\n\nPrograms 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.\n\nIf user namespaces are not available on a system, nix-portable will fall back to using proot as an alternative mechanism to virtualize /nix.\nProot can introduce significant performance overhead depending on the workload.\nIn 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.\n\n\n### Missing Features\n\n- managing nix profiles via `nix-env`\n- managing nix channels via `nix-channel`\n- support MacOS\n\n### Building / Contributing\n\nTo speed up builds, add the nix-portable cache:\n\n```shellSession\nnix-shell -p cachix --run \"cachix use nix-portable\"\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FDavHau%2Fnix-portable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FDavHau%2Fnix-portable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FDavHau%2Fnix-portable/lists"}