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