nixpkgs/nixos/modules
nikstur 289dd22132 nixos/qemu-vm: simplify building nix store image
Summary of this change:

- Simplify code.
- Stop a disk image from being cached in the binary cache.
- Make erofs Nix Store image build in an acceptable time outside of
  testing environments (like `darwin.builder`).
- Do not regress on performance for tests that use many store paths in
  their Nix store image.
- Slightly longer startup time for tests where not many store paths are
  included in the image (these probably shouldn't use `useNixStoreImage`
  anyways).
- Slightly longer startup time when inputs of VM do not change because
  the Nix store image is not cached anymore.

Remove the `storeImage` built with make-disk-image.nix. This produced a
separate derivation which is then cached in the binary cache. These
types of images should be avoided because they gunk up the cache as they
change frequently. Now all Nix store images, whether read-only or
writable are based on the erofs image previously only used for read-only
images.

Additionally, simplify the way the erofs image is built by copying the
paths to include to a separate directory and build the erofs image from
there.

Before this change, the list of Nix store paths to include in the Nix
store image was converted to a complex regex that *excludes* all other
paths from a potentially large Nix store.

This previous approach suffers from two issues:

1. The regex is complex and, as admitted in the source code of the
   includes-to-excludes.py script, most likely contains at least one
   error. This means that it's unlikely that anyone will touch this
   piece of software again.

2. When the Nix store image is built from a large Nix store (like when
   you build the VM script to run outside of any testing context) this
   regex becomes painfully slow. There is at least one prominent
   use-case where this matters: `darwin.builder`.

Benchmarking impressions:

- Building Nix store via make-disk-image.nix takes ~25s
- Building Nix store as an erofs image takes ~4s
- Running nixosTests.qemu-vm-writable-store-image takes ~10s when
  building the erofs image with the regex vs ~14s when building by
  copying to a temporary directory.
- nixosTests.gitlab which had the biggest gains from the initial erofs
  change takes the same time as before.
- On a host with ~140k paths in /nix/store, building the erofs image
  with the regex takes 410s as opposed to 6s when copying to a temporary
  directory.
2024-07-18 20:24:58 +02:00
..
config nixos/swap: avoid top-level with expressions (#327991) 2024-07-17 20:23:14 +02:00
hardware Merge pull request #325811 from Naxdy/work/blackmagic 2024-07-15 16:41:11 +02:00
i18n/input-method Merge pull request #310708 from importantblimp/180654 2024-07-14 00:02:13 +00:00
image nixos/repart-image: fix amend script 2024-07-10 11:40:40 +02:00
installer Merge pull request #320462 from amozeo/pkgs/nixos-rebuild/by-attr 2024-07-13 20:46:31 -04:00
misc nixos/mxisd: remove module 2024-07-12 11:44:59 +02:00
profiles Merge pull request #317623 from jmbaur/stc-ng-followup 2024-07-18 11:33:59 +02:00
programs Merge pull request #327748 from lluchs/fix-tsm-client-lists 2024-07-17 23:05:09 +02:00
security nixos/pam/u2f: implement RFC0042 2024-07-05 17:07:02 +03:00
services nixos/hardware.display: init 2024-07-18 16:57:40 +03:00
system Merge pull request #317623 from jmbaur/stc-ng-followup 2024-07-18 11:33:59 +02:00
tasks nixos/clevis: add support for parent encrypted zfs datasets 2024-06-12 21:21:50 +03:00
testing treewide: fix mkEnableOption usage 2024-06-14 02:41:42 -04:00
virtualisation nixos/qemu-vm: simplify building nix store image 2024-07-18 20:24:58 +02:00
module-list.nix nixos/hardware.display: init 2024-07-18 16:57:40 +03:00
rename.nix Merge pull request #326894 from kira-bruneau/replay-sorcery 2024-07-17 14:37:51 -04:00