use closure-info for building system tarball
This commit is contained in:
parent
b8040919b0
commit
4259f7575e
|
@ -1,4 +1,4 @@
|
||||||
{ stdenv, perl, pixz, pathsFromGraph
|
{ stdenv, closureInfo, pixz
|
||||||
|
|
||||||
, # The file name of the resulting tarball
|
, # The file name of the resulting tarball
|
||||||
fileName ? "nixos-system-${stdenv.hostPlatform.system}"
|
fileName ? "nixos-system-${stdenv.hostPlatform.system}"
|
||||||
|
@ -29,24 +29,28 @@
|
||||||
, extraInputs ? [ pixz ]
|
, extraInputs ? [ pixz ]
|
||||||
}:
|
}:
|
||||||
|
|
||||||
|
let
|
||||||
|
symlinks = map (x: x.symlink) storeContents;
|
||||||
|
objects = map (x: x.object) storeContents;
|
||||||
|
in
|
||||||
|
|
||||||
stdenv.mkDerivation {
|
stdenv.mkDerivation {
|
||||||
name = "tarball";
|
name = "tarball";
|
||||||
builder = ./make-system-tarball.sh;
|
builder = ./make-system-tarball.sh;
|
||||||
buildInputs = [ perl ] ++ extraInputs;
|
buildInputs = extraInputs;
|
||||||
|
|
||||||
inherit fileName pathsFromGraph extraArgs extraCommands compressCommand;
|
inherit fileName extraArgs extraCommands compressCommand;
|
||||||
|
|
||||||
# !!! should use XML.
|
# !!! should use XML.
|
||||||
sources = map (x: x.source) contents;
|
sources = map (x: x.source) contents;
|
||||||
targets = map (x: x.target) contents;
|
targets = map (x: x.target) contents;
|
||||||
|
|
||||||
# !!! should use XML.
|
# !!! should use XML.
|
||||||
objects = map (x: x.object) storeContents;
|
inherit symlinks objects;
|
||||||
symlinks = map (x: x.symlink) storeContents;
|
|
||||||
|
|
||||||
# For obtaining the closure of `storeContents'.
|
closureInfo = closureInfo {
|
||||||
exportReferencesGraph =
|
rootPaths = objects;
|
||||||
map (x: [("closure-" + baseNameOf x.object) x.object]) storeContents;
|
};
|
||||||
|
|
||||||
extension = compressionExtension;
|
extension = compressionExtension;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@ source $stdenv/setup
|
||||||
sources_=($sources)
|
sources_=($sources)
|
||||||
targets_=($targets)
|
targets_=($targets)
|
||||||
|
|
||||||
echo $objects
|
|
||||||
objects=($objects)
|
objects=($objects)
|
||||||
symlinks=($symlinks)
|
symlinks=($symlinks)
|
||||||
|
|
||||||
|
@ -14,8 +13,6 @@ stripSlash() {
|
||||||
if test "${res:0:1}" = /; then res=${res:1}; fi
|
if test "${res:0:1}" = /; then res=${res:1}; fi
|
||||||
}
|
}
|
||||||
|
|
||||||
touch pathlist
|
|
||||||
|
|
||||||
# Add the individual files.
|
# Add the individual files.
|
||||||
for ((i = 0; i < ${#targets_[@]}; i++)); do
|
for ((i = 0; i < ${#targets_[@]}; i++)); do
|
||||||
stripSlash "${targets_[$i]}"
|
stripSlash "${targets_[$i]}"
|
||||||
|
@ -25,9 +22,9 @@ done
|
||||||
|
|
||||||
|
|
||||||
# Add the closures of the top-level store objects.
|
# Add the closures of the top-level store objects.
|
||||||
|
chmod +w .
|
||||||
mkdir -p nix/store
|
mkdir -p nix/store
|
||||||
storePaths=$(perl $pathsFromGraph closure-*)
|
for i in $(< $closureInfo/store-paths); do
|
||||||
for i in $storePaths; do
|
|
||||||
cp -a "$i" "${i:1}"
|
cp -a "$i" "${i:1}"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@ -35,7 +32,7 @@ done
|
||||||
# TODO tar ruxo
|
# TODO tar ruxo
|
||||||
# Also include a manifest of the closures in a format suitable for
|
# Also include a manifest of the closures in a format suitable for
|
||||||
# nix-store --load-db.
|
# nix-store --load-db.
|
||||||
printRegistration=1 perl $pathsFromGraph closure-* > nix-path-registration
|
cp $closureInfo/registration nix-path-registration
|
||||||
|
|
||||||
# Add symlinks to the top-level store objects.
|
# Add symlinks to the top-level store objects.
|
||||||
for ((n = 0; n < ${#objects[*]}; n++)); do
|
for ((n = 0; n < ${#objects[*]}; n++)); do
|
||||||
|
|
|
@ -15,15 +15,19 @@ in {
|
||||||
|
|
||||||
# Create the tarball
|
# Create the tarball
|
||||||
system.build.tarball = pkgs.callPackage ../../lib/make-system-tarball.nix {
|
system.build.tarball = pkgs.callPackage ../../lib/make-system-tarball.nix {
|
||||||
contents = [];
|
contents = [
|
||||||
|
{
|
||||||
|
source = "${config.system.build.toplevel}/.";
|
||||||
|
target = "./";
|
||||||
|
}
|
||||||
|
];
|
||||||
extraArgs = "--owner=0";
|
extraArgs = "--owner=0";
|
||||||
|
|
||||||
# Add init script to image
|
# Add init script to image
|
||||||
storeContents = [
|
storeContents = pkgs2storeContents [
|
||||||
{ object = config.system.build.toplevel + "/init";
|
config.system.build.toplevel
|
||||||
symlink = "/init";
|
pkgs.stdenv
|
||||||
}
|
];
|
||||||
] ++ (pkgs2storeContents [ pkgs.stdenv ]);
|
|
||||||
|
|
||||||
# Some container managers like lxc need these
|
# Some container managers like lxc need these
|
||||||
extraCommands = "mkdir -p proc sys dev";
|
extraCommands = "mkdir -p proc sys dev";
|
||||||
|
|
Loading…
Reference in New Issue