Skip to content

Commit 8899a94

Browse files
SomeoneSergeastro
authored andcommitted
feat(writableStoreOverlay): make loading regInfo optional
- Introduce `microvm.registerClosure` option. - Gate `regInfo` kernel cmdline and `load-db` behind `registerClosure`. This way, writableStoreOverlay may be (ab)used with a persistent Nix DB: - If guest Nix encounters a store path present in the lowerdir, it'll have to realize it, i.e. write a copy to the upper dir. There's a chance we'll actually get a different copy (e.g. due to a different substitutor and/or non-deterministic builds), possibly leading to inconsistency. - Perhaps inconsistencies can be avoided by registering the ro-store as a "substitutor"? - We can now swap the guest image, GC the Host's store, and reboot. This is tolerable, because system paths were never registered in the guest db, unless re-"realized" and copied to the upperdir. This is not a pretty solution. E.g. when the Host store is mounted and the Guest reuses a store path from the Host, I'd maybe rather we dynamically create a gcroot on the Host, but that's extra complexity.
1 parent b9206e2 commit 8899a94

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

nixos-modules/microvm/options.nix

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,14 @@ in
449449
description = "Whether to boot with the storeDisk, that is, unless the host's /nix/store is a microvm.share.";
450450
};
451451

452+
registerClosure = lib.mkEnableOption ''
453+
Register system closure's store paths in Nix db.
454+
455+
While enabled by default, this option may be incompatible with a persistent writable store overlay.
456+
'' // {
457+
default = config.microvm.guest.enable;
458+
};
459+
452460
writableStoreOverlay = mkOption {
453461
type = with types; nullOr str;
454462
default = null;

nixos-modules/microvm/store-disk.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ in
9595
'';
9696
})
9797

98-
(lib.mkIf (config.microvm.guest.enable && config.nix.enable) {
98+
(lib.mkIf (config.microvm.registerClosure && config.nix.enable) {
9999
microvm.kernelParams = [
100100
"regInfo=${regInfo}/registration"
101101
];

0 commit comments

Comments
 (0)