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