Skip to content

Commit 575404d

Browse files
verity-images: Fix the installer to copy the image
The verity images are failing to build because the naming conventions of the disk1 image used in disko vs the ghaf-version images that are used in repart. This change normalizes the name. Creating a link called `ghaf-image` which can be referenced in the installer. Signed-off-by: Brian McGillion <bmg.avoin@gmail.com>
1 parent 62325b7 commit 575404d

File tree

1 file changed

+26
-6
lines changed

1 file changed

+26
-6
lines changed

lib/builders/mkLaptopInstaller.nix

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,32 @@ let
3636

3737
# Include the image file directly in the ISO filesystem (not in /nix/store)
3838
# This copies the file without creating a runtime dependency
39-
isoImage.contents = [
40-
{
41-
source = "${imagePath}/disk1.raw.zst";
42-
target = "/ghaf-image/disk1.raw.zst";
43-
}
44-
];
39+
# Support both disko (disk1.raw.zst) and verity (ghaf-*.raw.zst) images
40+
# Use reflinks/hardlinks to avoid duplicating large image files
41+
isoImage.contents =
42+
let
43+
# Create a derivation that finds the .raw.zst file and creates a normalized reference
44+
# Using cp --reflink=auto attempts copy-on-write, falling back to hardlink
45+
normalizedImage = pkgs.runCommand "normalized-ghaf-image" { } ''
46+
mkdir -p $out
47+
# Find the .raw.zst file (either disk1.raw.zst or ghaf-*.raw.zst)
48+
imageFile=$(find ${imagePath} -maxdepth 1 -name "*.raw.zst" -type f | head -n 1)
49+
if [ -z "$imageFile" ]; then
50+
echo "Error: No .raw.zst file found in ${imagePath}" >&2
51+
exit 1
52+
fi
53+
# Use reflink if supported (e.g. btrfs), otherwise hardlink to avoid duplication
54+
# This saves significant disk space (6-7GB per installer build) compared to cp.
55+
cp --reflink=auto "$imageFile" $out/ghaf-image.raw.zst || \
56+
ln "$imageFile" $out/ghaf-image.raw.zst
57+
'';
58+
in
59+
[
60+
{
61+
source = "${normalizedImage}/ghaf-image.raw.zst";
62+
target = "/ghaf-image/ghaf-image.raw.zst";
63+
}
64+
];
4565

4666
environment.sessionVariables = {
4767
IMG_PATH = "/iso/ghaf-image";

0 commit comments

Comments
 (0)