@@ -130,12 +130,13 @@ class ExtractChecksum:
130130LayerInfo = namedtuple("LayerInfo", ["size", "checksum", "path", "paths"])
131131
132132
133−def add_layer_dir(tar, paths, mtime):
133+def add_layer_dir(tar, paths, store_dir, mtime):
134134 """
135135 Appends given store paths to a TarFile object as a new layer.
136136
137137 tar: 'tarfile.TarFile' object for the new layer to be added to.
138138 paths: List of store paths.
139+ store_dir: the root directory of the nix store
139140 mtime: 'mtime' of the added files and the layer tarball.
140141 Should be an integer representing a POSIX time.
141142
@@ -143,9 +144,9 @@ def add_layer_dir(tar, paths, mtime):
143144 the layer added.
144145 """
145146
146− invalid_paths = [i for i in paths if not i.startswith("/nix/store/")]
147+ invalid_paths = [i for i in paths if not i.startswith(store_dir)]
147148 assert len(invalid_paths) == 0, \
148− "Expecting absolute store paths, but got: {invalid_paths}"
149+ f"Expecting absolute paths from {store_dir}, but got: {invalid_paths}"
149150
150151 # First, calculate the tarball checksum and the size.
151152 extract_checksum = ExtractChecksum()
@@ -245,6 +246,7 @@ def main():
245246 else datetime.fromisoformat(conf["created"])
246247 )
247248 mtime = int(created.timestamp())
249+ store_dir = conf["store_dir"]
248250
249251 with tarfile.open(mode="w|", fileobj=sys.stdout.buffer) as tar:
250252 layers = []
@@ -253,7 +255,7 @@ def main():
253255 "Creating layer", num,
254256 "from paths:", store_layer,
255257 file=sys.stderr)
256− info = add_layer_dir(tar, store_layer, mtime=mtime)
258+ info = add_layer_dir(tar, store_layer, store_dir, mtime=mtime)
257259 layers.append(info)
258260
259261 print("Creating the customisation layer...", file=sys.stderr)