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