Skip to content

figsoda/unnix

Repository files navigation

unnix

release version deps license ci

Reproducible Nix environments without installing Nix

Usage

Warning

Unnix is alpha software. I recommend against running it on long-running production servers in its current state.

To use unnix, start by creating unnix.kdl, unnix's manifest file

unnix init -p jq ripgrep

Now you can enter the environment with

unnix env

This will generate unnix.lock.json and put you in a shell with jq and rg. Make sure to commit the lockfile to your VCS to keep your environment reproducible.

How it works

This is a very simplified view of what happens when you run nix develop.

flowchart TB

nix(nix) --> | download | expr --> | evaluate | drv
drv --> | outputs | path --> | query | cache

cache -->| hit | download(download to the Nix store)
cache -->| miss | build(build the derivation)
drv -.- build

cache(
  binary cache
  e.g. cache.nixos.org
)

drv(derivations)

expr(
  Nix expressions
  e.g. Nixpkgs
)

path(store paths)
Loading

Downloading and evaluating Nixpkgs can take a long time, especially in ephemeral environments like CI pipelines. Unnix avoids that by removing derivations from the picture altogether, and getting the store paths directly from services like Hydra and Devbox.

flowchart TB
unnix --> | lockfile absent or outdated | update --> | Hydra | paths
unnix --> | up-to-date lockfile | paths
paths --> | query | cache

cache --> | hit | download(download to the unnix store)
cache --> | miss | miss

cache(
  binary cache
  e.g. cache.nixos.org
)

miss(
  fail
)

paths(store paths)

unnix(unnix)

update(update lockfile)
Loading

Platform support

aarch64-darwin aarch64-linux x86_64-darwin x86_64-linux
CLI partial1 yes partial1 yes
GitHub action yes yes no yes
prebuilt binaries yes yes no yes
cached by the default cache yes yes yes2 yes

Limitations

  • No setup hooks

    Unnix does not have access to stdenv, and therefore cannot run the setup hooks or any user-specified shellHooks. Instead, it tries its best to emulate the behavior of setup hooks like pkg-config, so that dependencies can be picked up without executing any hooks.

  • No evaluation

    Unnix does not evaluate Nix expressions. You cannot use .override or .overrideAttrs on packages, and are limited to the attributes the resolver exposes, e.g. Hydra jobs.

  • No builds

    Unnix cannot build anything, and strictly relies on binary caches. This means no unfree packages if you are using the default set of caches.

Related projects

Changelog

See CHANGELOG.md

Footnotes

  1. unnix env relies on bubblewrap, which only works on Linux. An alternative darwin backend is work in progress. 2

  2. x86_64-darwin will be deprecated in Nixpkgs 26.11.

About

Reproducible Nix environments without installing Nix

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

Packages

 
 
 

Languages