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