-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make release disk a separate build target
Earlier release disk build had a critical problem: the built disk would have optimized partition sizes based on the current system's image size. This meant that newer releases would potentially not fit in the system partition if they increase in size. To avoid this issue, we create disk images which have system partition sizes equal to (default PlayOS size - 1 GiB). The 1GiB is subtracted as a safety threshold to avoid releasing something that is very near max capacitiy. This gets rid of the extra top-level `extraModules` argument in default.nix along the way.
- Loading branch information
Showing
5 changed files
with
81 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Similarly to testing/disk/default.nix, this builds a disk image containing | ||
# a full PlayOS installation, with these differences: | ||
# - It uses default system and boot partition sizes. Total disk size is ~20 GiB | ||
# - It produces a (sparsified) qcow2 image rather than a raw one. This reduces | ||
# the image size to ~8GiB | ||
# - It compresses the final image using zstd to reduce disk usage. | ||
# Final compressed file size is around ~4GiB. | ||
{ pkgs | ||
, lib | ||
, install-playos | ||
}: | ||
with pkgs; | ||
with lib; | ||
let | ||
# all sizes in MiB | ||
partSizes = { | ||
boot = 525; # 525 MiB (matches install-playos default) | ||
system = 1024 * 9; # 9 GiB (install-playos default - 1GiB) | ||
data = 400; # 400 MiB (same as testing/disk/default.nix) | ||
}; | ||
diskSizeMiB = 8 + partSizes."boot" + partSizes."data" + (partSizes."system" * 2) + 1; | ||
in | ||
vmTools.runInLinuxVM ( | ||
runCommand "build-playos-release-disk" | ||
{ | ||
buildInputs = [install-playos]; | ||
|
||
preVM = '' | ||
diskImage=nixos.raw | ||
truncate -s ${toString diskSizeMiB}MiB $diskImage | ||
''; | ||
|
||
postVM = '' | ||
mkdir -p $out | ||
${pkgs.qemu}/bin/qemu-img convert -f raw -O qcow2 $diskImage $out/playos-disk.img | ||
rm $diskImage | ||
${pkgs.zstd}/bin/zstd --rm -f $out/playos-disk.img -o $out/playos-disk.img.zst | ||
diskImage=$out/playos-disk.img.zst | ||
''; | ||
memSize = 1024; | ||
} | ||
'' | ||
# machine-id of development image is hardcoded. | ||
install-playos \ | ||
--device /dev/vda \ | ||
--machine-id "f414cca8312548d29689ebf287fb67e0" \ | ||
--no-confirm | ||
'' | ||
) + "/playos-disk.img.zst" |