NixOS/nixpkgs — pull request #3779 by offlinehacker (2014-08-25 10:09:30+00:00)
Title: full nixos inside docker

This is first attempt to run full nixos inside docker. You will need docker 1.2.0(already meged into master), because of support of adding capabilities to containers. Currenty it should not be possible to run these images on docker virtualization providers, because docker was, but does not have patch for systemd included anymore, because of (for my opinion) not so relevant non systemd related bugs(see: https://github.com/docker/libcontainer/pull/30 and https://github.com/docker/docker/issues/3629).

- To build docker base image use:

```
export NIXOS_CONFIG=$(pwd)/modules/virtualisation/docker-image.nix
nix-build . -A config.system.build.dockerImage
```

- To import image to docker(docker daemon must be running):

```
cat result/tarball/nixos-system-x86_64-linux.tar.xz| sudo docker import - nixos
```

- To start it:

```
sudo docker/bin/docker run -t -i --cap-add=SYS_ADMIN --cap-add=SYS_RESOURCE -e "container=docker" nixos /bin/init
```

As soon as docker will be patched to have cgroups mounted, i will make it run without these additional flags.