All Projects → DavHau → nix-portable

DavHau / nix-portable

Licence: MIT license
Nix - Static, Permissionless, Installation-free, Pre-configured

Programming Languages

Nix
1067 projects

Projects that are alternatives of or similar to nix-portable

nixos-tutorial
one hour, hands-on
Stars: ✭ 118 (-66.85%)
Mutual labels:  nix, nixos, package-management
nix-config
A collection of my system configs and dotfiles
Stars: ✭ 35 (-90.17%)
Mutual labels:  nix, nixos
nix-xdg
[WIP] Nix overlay for making programs xdg compliant
Stars: ✭ 18 (-94.94%)
Mutual labels:  nix, nixos
crane
A Nix library for building cargo projects. Never build twice thanks to incremental artifact caching.
Stars: ✭ 348 (-2.25%)
Mutual labels:  nix, nixos
dns.nix
A Nix DSL for DNS zone files
Stars: ✭ 69 (-80.62%)
Mutual labels:  nix, nixos
nix-configs
My Nix{OS} configuration files
Stars: ✭ 54 (-84.83%)
Mutual labels:  nix, nixos
impermanence
Modules to help you handle persistent state on systems with ephemeral root storage [maintainer=@talyz]
Stars: ✭ 401 (+12.64%)
Mutual labels:  nix, nixos
nix-gaming
Gaming on Nix
Stars: ✭ 142 (-60.11%)
Mutual labels:  nix, nixos
dotfiles-nix
Configuration files for my NixOS machine, declared by home-manager
Stars: ✭ 137 (-61.52%)
Mutual labels:  nix, nixos
nix-articles
Some articles about getting started with Nix programming & configuration
Stars: ✭ 134 (-62.36%)
Mutual labels:  nix, nixos
presentations
Presentations at the Tokyo Nixos Meetup
Stars: ✭ 57 (-83.99%)
Mutual labels:  nix, nixos
libdnf
Package management library.
Stars: ✭ 157 (-55.9%)
Mutual labels:  package-manager, package-management
nixos-installer
Combining the power of Nix, Guile & Elm to install NixOS
Stars: ✭ 14 (-96.07%)
Mutual labels:  nix, nixos
elemental
Elemental, the component parts of a Nix/OS development system.
Stars: ✭ 44 (-87.64%)
Mutual labels:  nix, nixos
comma
Comma runs software without installing it. [maintainers=@Artturin,@burke,@DavHau]
Stars: ✭ 626 (+75.84%)
Mutual labels:  nix, nixos
nixos-configuration
A repo for my nixos configuration files
Stars: ✭ 20 (-94.38%)
Mutual labels:  nix, nixos
emergency-kexec
Kexec into an in-memory emergency system
Stars: ✭ 21 (-94.1%)
Mutual labels:  nix, nixos
gradle2nix
Generate Nix expressions which build Gradle-based projects.
Stars: ✭ 71 (-80.06%)
Mutual labels:  nix, nixos
purescript.nix
📦 PureScript package management with Nix
Stars: ✭ 12 (-96.63%)
Mutual labels:  nix, package-management
nixvim
Configure Neovim with Nix!
Stars: ✭ 120 (-66.29%)
Mutual labels:  nix, nixos

Nix as a single binary which doesn't require configuration, privileges, or (user) namespaces.

For binary downloads check the releases page.

Goals:

  • make it extremely simple to install nix
  • make nix work in restricted environments (containers, HPC, ...)
  • be able to use the official binary cache (by simulating the /nix/store)
  • make it easy to distribute nix (via other package managers)

Tested on the following systems/environments:

  • Distros:
    • Arch Linux
    • Debian 10
    • CentOS 7
    • CentOS 8
    • NixOS
    • Ubuntu 20.04
  • Other Environments:
    • Docker (debian image)
    • Github Action

Under the hood:

  • The nix-portable binary is a self extracting archive, caching its contents in $HOME/.nix-portable
  • Either bubblewrap or proot is used to simulate 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.
  • Nix version 2.4 is used and configured to enable flakes and nix-command out of the box.

Drawbacks / Considerations:

If user namespaces are not available on a system, nix-portable will fall back to using proot instead of bubblewrap. Proot's virtualization can have a 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:

  • managing nix profiles via nix-env
  • managing nix channels via nix-channel
  • support MacOS
  • support other architecutres besides x86_64

Executing nix-portable

After obtaining the binary, there are two options:

  1. Specify the nix executable via cmdline argument:
    ./nix-portable nix-shell ...
    
  2. Select the nix executable via symlinking, similar to busybox:
    # create a symlink from ./nix-shell to ./nix-portable
    ln -s ./nix-portable ./nix-shell
    # execute nix-shell
    ./nix-shell
    

Executing installed programs

All programs installed via nix-portable will only work inside the wrapped environment. To enter the wrapped environment just use nix-shell:

  nix-portable nix-shell -p bash

... or use nix run to execute a program:

  nix-portable nix run {flake-spec}

Container Runtimes

To simulate the /nix/store and a few other directories, nix-portable supports the following container runtimes.

  • bwrap (existing installation)
  • bwrap (shipped via nix-portable)
  • proot (existing installation)
  • proot (shipped via nix-portable)

bwrap is preferred over proot and existing installations are preferred over the nix-portable included binaries. nix-portable will try to figure out which runtime is best for your system. In case the automatically selected runtime doesn't work, use the follwing environment variables to specify the runtime, but please also open an issue, so we can improve the automatic selection.

Environment Variables

The following environment variables are optional and can be used to override the default behaviour of nix-portable

NP_DEBUG      (1 = debug msgs; 2 = 'set -x' for nix-portable)
NP_GIT        specify path to the git executable
NP_LOCATION   where to put the `.nix-portable` dir. (defaults to `$HOME`)
NP_RUNTIME    which runtime to use (must be 'bwrap' or 'proot')
NP_BWRAP      specify the path to the bwrap executable to use
NP_PROOT      specify the path to the proot executable to use
NP_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...}

Building / Contributing

To speed up builds, add the nix-portable cache:

nix-shell -p cachix --run "cachix use nix-portable"
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].