1{ config, pkgs, ... }:
2
3let
4 inherit (pkgs) writeScript;
5
6 pkgs2storeContents = map (x: {
7 object = x;
8 symlink = "none";
9 });
10in
11
12{
13 # Docker image config.
14 imports = [
15 ../installer/cd-dvd/channel.nix
16 ./minimal.nix
17 ./clone-config.nix
18 ];
19
20 # Create the tarball
21 system.build.tarball = pkgs.callPackage ../../lib/make-system-tarball.nix {
22 contents = [
23 {
24 source = "${config.system.build.toplevel}/.";
25 target = "./";
26 }
27 ];
28 extraArgs = "--owner=0";
29
30 # Add init script to image
31 storeContents = pkgs2storeContents [
32 config.system.build.toplevel
33 pkgs.stdenv
34 ];
35
36 # Some container managers like lxc need these
37 extraCommands =
38 let
39 script = writeScript "extra-commands.sh" ''
40 rm etc
41 mkdir -p proc sys dev etc
42 '';
43 in
44 script;
45 };
46
47 boot.isContainer = true;
48 boot.postBootCommands = ''
49 # After booting, register the contents of the Nix store in the Nix
50 # database.
51 if [ -f /nix-path-registration ]; then
52 ${config.nix.package.out}/bin/nix-store --load-db < /nix-path-registration &&
53 rm /nix-path-registration
54 fi
55
56 # nixos-rebuild also requires a "system" profile
57 ${config.nix.package.out}/bin/nix-env -p /nix/var/nix/profiles/system --set /run/current-system
58 '';
59
60 # Install new init script
61 system.activationScripts.installInitScript = ''
62 ln -fs $systemConfig/init /init
63 '';
64}