nixos/preload: init
[NixPkgs.git] / nixos / lib / make-system-tarball.sh
blob1a0017a1799a4f87d3efc9246eb62e793f2648b1
1 source $stdenv/setup
3 sources_=($sources)
4 targets_=($targets)
6 objects=($objects)
7 symlinks=($symlinks)
10 # Remove the initial slash from a path, since genisofs likes it that way.
11 stripSlash() {
12 res="$1"
13 if test "${res:0:1}" = /; then res=${res:1}; fi
16 # Add the individual files.
17 for ((i = 0; i < ${#targets_[@]}; i++)); do
18 stripSlash "${targets_[$i]}"
19 mkdir -p "$(dirname "$res")"
20 cp -a "${sources_[$i]}" "$res"
21 done
24 # Add the closures of the top-level store objects.
25 chmod +w .
26 mkdir -p nix/store
27 for i in $(< $closureInfo/store-paths); do
28 cp -a "$i" "${i:1}"
29 done
32 # TODO tar ruxo
33 # Also include a manifest of the closures in a format suitable for
34 # nix-store --load-db.
35 cp $closureInfo/registration nix-path-registration
37 # Add symlinks to the top-level store objects.
38 for ((n = 0; n < ${#objects[*]}; n++)); do
39 object=${objects[$n]}
40 symlink=${symlinks[$n]}
41 if test "$symlink" != "none"; then
42 mkdir -p $(dirname ./$symlink)
43 ln -s $object ./$symlink
45 done
47 $extraCommands
49 mkdir -p $out/tarball
51 rm env-vars
53 time tar --sort=name --mtime='@1' --owner=0 --group=0 --numeric-owner -c * $extraArgs | $compressCommand > $out/tarball/$fileName.tar${extension}
55 mkdir -p $out/nix-support
56 echo $system > $out/nix-support/system
57 echo "file system-tarball $out/tarball/$fileName.tar${extension}" > $out/nix-support/hydra-build-products