• Stars
    star
    851
  • Rank 53,558 (Top 2 %)
  • Language
    Nix
  • License
    MIT License
  • Created almost 4 years ago
  • Updated 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Nix - Static, Permissionless, Installation-free, Pre-configured

Nix as a static executable requiring no 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 (x86_64):
    • Arch Linux
    • CentOS 7
    • Debian
    • Fedora
    • NixOS
    • Ubuntu
  • Distros (aarch64):
    • Debian
  • Other Environments:
    • Docker (debian image)
    • Github Actions

Under the hood:

  • The nix-portable executable 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.
  • Features flakes and nix-command are enabled 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

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"

More Repositories

1

mach-nix

Create highly reproducible python environments
Python
849
star
2

drv-parts

Configure packages like NixOS systems
Nix
153
star
3

pypi-deps-db

Dependency DB for python packages on pypi
Python
65
star
4

django-nixos

NixOS/NixOps configuration for Django
Nix
32
star
5

systemd2nix

Convert systemd service files to Nix syntax
Python
29
star
6

pkgs-modules

The Ideal interface for configuring packages
Nix
24
star
7

nix-on-armv7l

Nix without NixOS on arm32v7 / armv7l / Raspberry Pi OS / Raspbian
Dockerfile
19
star
8

nix-pypi-fetcher

Pypi Fetcher for Nix with simplified interface. (contains hashes for all packages)
Python
13
star
9

motioneye-loop-record

Addon for motion / motioneye / motionEyeOs to enable the missing loop recoding functionality
Python
11
star
10

nixos-steam-box

A linux based gaming console based on NixOS + Steam Big Picture
Nix
10
star
11

nix-eval-cache

Cache evaluation of nix functions
Nix
10
star
12

build-modules

low level module system for nix builds / alternative stdenv
Nix
9
star
13

edict

Run nix commands on remote machines
9
star
14

fromYaml

yaml parser in pure nix
Nix
7
star
15

nix-pypi-fetcher-2

DB of pypi URLs and hashes
Python
4
star
16

nix-toolbox

Nix
4
star
17

cabal2json

zurihack experiment
Haskell
4
star
18

nix-early-cutoff

Prevent re-builds of derivations depending on source
Nix
3
star
19

flake-templates

Collection of flake templates
Nix
2
star
20

zfs-enc-automount

Simple tool to automount encrypted zfs datasets on boot while storing the password on a remote host
Shell
2
star
21

nixops-vbox-base-image

Declarative definition of an up-to-date virtualbox base image for your nixops project
Nix
2
star
22

dream2nix-auto-test

test repo for dream2nix auto-generated package sets
Nix
2
star
23

conda-channels

regular snapshots of multiple conda channels
Nix
2
star
24

flake-parts-auto

Auto import and expose modules in your flake
Nix
2
star
25

dump

Mono repo of DavHau
Nix
1
star
26

betfair-csv-downloader

Tool to mass download csv files from https://promo.betfair.com/betfairsp/prices.
Python
1
star
27

octodns-nix

octodns packaged for the nix package manager
Nix
1
star
28

hyperconfig

NixOS configs of DavHau
Nix
1
star
29

heroku-nix-notes

Notes on heroku deployments with nix
1
star
30

nix-bootstrap-binaries

bootstrap binaries for an alternative stdenv
Nix
1
star
31

nix-parallel-ifd

Demonstration of performance opportunities in IFD evaluation
Nix
1
star
32

DavHau.github.io

HTML
1
star