1{ ... }:
2
3{
4 imports = [
5 ../profiles/docker-container.nix # FIXME, shouldn't include something from profiles/
6 ];
7
8 boot.postBootCommands = ''
9 # Set virtualisation to docker
10 echo "docker" > /run/systemd/container
11 '';
12
13 # Iptables do not work in Docker.
14 networking.firewall.enable = false;
15
16 # Socket activated ssh presents problem in Docker.
17 services.openssh.startWhenNeeded = false;
18}
19
20# Example usage:
21#
22## default.nix
23# let
24# nixos = import <nixpkgs/nixos> {
25# configuration = ./configuration.nix;
26# system = "x86_64-linux";
27# };
28# in
29# nixos.config.system.build.tarball
30#
31## configuration.nix
32# { pkgs, config, lib, ... }:
33# {
34# imports = [
35# <nixpkgs/nixos/modules/virtualisation/docker-image.nix>
36# <nixpkgs/nixos/modules/installer/cd-dvd/channel.nix>
37# ];
38#
39# documentation.doc.enable = false;
40#
41# environment.systemPackages = with pkgs; [
42# bashInteractive
43# cacert
44# nix
45# ];
46# }
47#
48## Run
49# Build the tarball:
50# $ nix-build default.nix
51# Load into docker:
52# $ docker import result/tarball/nixos-system-*.tar.xz nixos-docker
53# Boots into systemd
54# $ docker run --privileged -it nixos-docker /init
55# Log into the container
56# $ docker exec -it <container-name> /run/current-system/sw/bin/bash