2018-07-20 21:56:59 +01:00
|
|
|
{ ... }:
|
2014-08-25 01:48:02 +01:00
|
|
|
|
2014-12-11 21:58:17 +00:00
|
|
|
{
|
|
|
|
imports = [
|
2015-04-19 20:38:22 +01:00
|
|
|
../profiles/docker-container.nix # FIXME, shouldn't include something from profiles/
|
2014-12-11 21:58:17 +00:00
|
|
|
];
|
2014-08-25 01:48:02 +01:00
|
|
|
|
|
|
|
boot.postBootCommands =
|
|
|
|
''
|
|
|
|
# Set virtualisation to docker
|
2014-12-11 21:58:17 +00:00
|
|
|
echo "docker" > /run/systemd/container
|
2014-08-25 01:48:02 +01:00
|
|
|
'';
|
|
|
|
|
2014-11-03 11:30:54 +00:00
|
|
|
# Iptables do not work in Docker.
|
2014-08-25 01:48:02 +01:00
|
|
|
networking.firewall.enable = false;
|
|
|
|
|
2014-11-03 11:30:54 +00:00
|
|
|
# Socket activated ssh presents problem in Docker.
|
2014-08-25 01:48:02 +01:00
|
|
|
services.openssh.startWhenNeeded = false;
|
|
|
|
}
|
2018-11-23 15:40:10 +00:00
|
|
|
|
|
|
|
# Example usage:
|
|
|
|
#
|
|
|
|
## default.nix
|
|
|
|
# let
|
|
|
|
# nixos = import <nixpkgs/nixos> {
|
|
|
|
# configuration = ./configuration.nix;
|
|
|
|
# system = "x86_64-linux";
|
|
|
|
# };
|
|
|
|
# in
|
|
|
|
# nixos.config.system.build.tarball
|
|
|
|
#
|
|
|
|
## configuration.nix
|
|
|
|
# { pkgs, config, lib, ... }:
|
|
|
|
# {
|
|
|
|
# imports = [
|
|
|
|
# <nixpkgs/nixos/modules/virtualisation/docker-image.nix>
|
|
|
|
# <nixpkgs/nixos/modules/installer/cd-dvd/channel.nix>
|
|
|
|
# ];
|
|
|
|
#
|
|
|
|
# documentation.doc.enable = false;
|
|
|
|
#
|
|
|
|
# environment.systemPackages = with pkgs; [
|
|
|
|
# bashInteractive
|
|
|
|
# cacert
|
|
|
|
# nix
|
|
|
|
# ];
|
|
|
|
# }
|
|
|
|
#
|
|
|
|
## Run
|
|
|
|
# Build the tarball:
|
|
|
|
# $ nix-build default.nix
|
|
|
|
# Load into docker:
|
|
|
|
# $ docker import result/tarball/nixos-system-*.tar.xz nixos-docker
|
|
|
|
# Boots into systemd
|
|
|
|
# $ docker run --privileged -it nixos-docker /init
|
|
|
|
# Log into the container
|
|
|
|
# $ docker exec -it <container-name> /run/current-system/sw/bin/bash
|