Reproducible builds and deployments.

Nix is a powerful package manager for Linux and other Unix systems that makes package management reliable and reproducible. Share your development and build environments across different machines.

NixOS is a Linux distribution with a unique approach to package and configuration management. Built on top of the Nix package manager, it is completely declarative, makes upgrading systems reliable, and has many other advantages.

Download Get started


Nix builds packages in isolation from each other. This ensures that they are reproducible and don't have undeclared dependencies, so if a package works on one machine, it will also work on another.


Nix makes it trivial to share development and build environments for your projects, regardless of what programming languages and tools you’re using.


Nix’s ensures that installing or upgrading one package cannot break other packages. It allows you to roll back to previous versions, and ensures that no package is in an inconsistent state during an upgrade.


Try new tools without fear

Don't clutter your system with tools that you use only now and then.

python --version
python: command not found
nix-shell -p python3
(nix-shell)python --version
Python 3.7.7

Multiple languages, one tool

nix-shell -p python3 nodejs go rustc
(nix-shell)node --version
(nix-shell)go version
go version go1.14.1 linux/amd64
(nix-shell)rustc --version
rustc 1.42.0

Isolated development environments

After you get familiar with nix-shell -p you can take the next step and learn some Nix. To setup a more persistent environment you can also write a simple shell.nix file:

{ pkgs ? import <nixpkgs> {}
pkgs.mkShell {
  name = "dev-shell";
  buildInputs = [

Then enter development environment with:

(nix-shell)virtualenv --version
(nix-shell)yarn --version

Commit the above shell.nix file and let you coworkers have easier time setting their development environment.

Minimal docker image

Using Dockefile you are responsible to:

  • clean up everything that is not needed at runtime
  • decide how to split into layers for better caching

Writing Dockefile that would produce a minimal image is at best a very error prone process.

With Nix you only include to docker image packages that you define. No cleaning up needed. There are no build tools left in your docker image, making it as minimal as you need.

Nix also know how to layer your resulting docker image, automatically without you needed to do anything. The resulting layers are optimized for caching as much as possible.

The following Nix expression (default.nix) defines a docker image with only hello package in it.

{ pkgs ? import <nixpkgs> {}
pkgs.dockerTools.buildLayeredImage {
  name = "only-hello";
  contents = [ pkgs.hello ];

To build and run the image you need to:

nix-build default.nix -o ./result
docker load -i ./result
1c31fbac2eb1: Loading layer [==================>]  1.649MB/1.649MB
03b22f688054: Loading layer [==================>]    256kB/256kB
29c350a9c392: Loading layer [==================>]  31.61MB/31.61MB
6a87e4d71e07: Loading layer [==================>]  266.2kB/266.2kB
c09c43a6b910: Loading layer [==================>]  71.68kB/71.68kB
Loaded image: only-hello:qn5x1pnk7d467jsl81jng7168qsks42l
docker run only-hello:qn5x1pnk7d467jsl81jng7168qsks42l hello"
Hello, world

Learn more how to build docker images.

Declarative cloud images

How hard would it be to build and configure a Amazon EC2 image?

With the following amazon.nix we defined nginx which is serving example /var/www folder, having a valid ssl certificate (via LetsEncrypt) and enabled recommended security settings.

{ pkgs, ...}:
  security.acme.acceptTerms = true; = "";
  services.nginx = {
    enable = true;
    recommendedGzipSettings = true;
    recommendedOptimisation = true;
    recommendedProxySettings = true;
    recommendedTlsSettings = true;
    virtualHosts."" = {
      enableACME = true;
      forceSSL = true;
      locations."/".root = "/var/www";

Now we just need to build it.

nix-build '<nixpkgs/nixos/release.nix>' \
    -A amazonImage.x86_64-linux \
    --arg configuration ./amazon.nix \
    -o ./result
ls ./result/

The resulting Virtual Hard Disk image can be then be imported to Amazon EC2 as usual.