Skip to content

Commit 68bdafb

Browse files
committed
squashfs -> ext4, which makes images ~5x larger. :(
NixOS/nixpkgs#236656 changed NixOS's qemu-vm disk-finding mechanism to use filesystem labels. squashfs doesn't support filesystem labels (see plougher/squashfs-tools#59 ). So we can't use squashfs anymore. :( The simple test's nix store image is 240M as squashfs and 1.3G as ext4.
1 parent 26efd1b commit 68bdafb

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Isolate NixOS QEMU VMs from each other and from the host by using a
2-
squashfs for the VM's /nix/store that contains only the VM's dependencies
2+
private /nix/store image that contains only the VM's dependencies
33
(like the installer has) rather than a virtio mount of the host's entire
44
/nix/store.
55

modules/qemu-vm-isolation.nix

+21-7
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,35 @@ let
1414

1515
in {
1616

17-
boot.initrd.availableKernelModules = [ "squashfs" ];
18-
1917
fileSystems = mkVMOverride {
2018
"${storeMountPath}" = {
2119
device =
2220
lookupDriveDeviceName "nixstore" config.virtualisation.qemu.drives;
23-
fsType = "squashfs";
21+
fsType = "ext4";
2422
options = [ "ro" ];
2523
neededForBoot = true;
2624
};
2725
};
2826

29-
system.build.squashfsStore =
30-
pkgs.callPackage (modulesPath + "/../lib/make-squashfs.nix") {
31-
storeContents = config.virtualisation.additionalPaths;
27+
# We use this to disable fsck runs on the ext4 nix store image because stage-1
28+
# fsck crashes (maybe because the device is read-only?), halting boot.
29+
boot.initrd.checkJournalingFS = false;
30+
31+
system.build.nixStoreImage =
32+
import (modulesPath + "/../lib/make-disk-image.nix") {
33+
inherit pkgs config lib;
34+
additionalPaths = [
35+
(config.virtualisation.host.pkgs.closureInfo {
36+
rootPaths = config.virtualisation.additionalPaths;
37+
})
38+
];
39+
onlyNixStore = true;
40+
label = "nix-store";
41+
partitionTableType = "none";
42+
installBootLoader = false;
43+
diskSize = "auto";
44+
additionalSpace = "0M";
45+
copyChannel = false;
3246
};
3347

3448
virtualisation = {
@@ -37,7 +51,7 @@ in {
3751

3852
qemu.drives = [{
3953
name = "nixstore";
40-
file = "${config.system.build.squashfsStore}";
54+
file = "${config.system.build.nixStoreImage}/nixos.img";
4155
driveExtraOpts = {
4256
format = "raw";
4357
read-only = "on";

0 commit comments

Comments
 (0)