|
16 | 16 | hostPkgs.closureInfo { rootPaths = config.virtualisation.additionalPaths; };
|
17 | 17 |
|
18 | 18 | nixStoreImages = {
|
19 |
| - ext4 = import (modulesPath + "/../lib/make-disk-image.nix") { |
20 |
| - inherit pkgs config lib; |
21 |
| - additionalPaths = [ storeContents ]; |
22 |
| - onlyNixStore = true; |
23 |
| - label = "nix-store"; |
24 |
| - partitionTableType = "none"; |
25 |
| - installBootLoader = false; |
26 |
| - diskSize = "auto"; |
27 |
| - additionalSpace = "0M"; |
28 |
| - copyChannel = false; |
29 |
| - }; |
30 |
| - erofs = hostPkgs.runCommand "nix-store-image" { } '' |
31 |
| - mkdir $out |
32 |
| - cd ${builtins.storeDir} |
33 |
| - ${hostPkgs.erofs-utils}/bin/mkfs.erofs \ |
34 |
| - --force-uid=0 \ |
35 |
| - --force-gid=0 \ |
36 |
| - -L nix-store \ |
37 |
| - -U eb176051-bd15-49b7-9e6b-462e0b467019 \ |
38 |
| - -T 0 \ |
39 |
| - --exclude-regex="$( |
40 |
| - <${storeContents}/store-paths \ |
41 |
| - sed -e 's^.*/^^g' \ |
42 |
| - | cut -c -10 \ |
43 |
| - | ${hostPkgs.python3}/bin/python -c ${ |
44 |
| - escapeShellArg (builtins.readFile |
45 |
| - (modulesPath + "/virtualisation/includes-to-excludes.py")) |
46 |
| - } )" \ |
47 |
| - $out/nixos.img \ |
48 |
| - . |
49 |
| - ''; |
| 19 | + ext4 = "${ |
| 20 | + import (modulesPath + "/../lib/make-disk-image.nix") { |
| 21 | + inherit pkgs config lib; |
| 22 | + additionalPaths = [ storeContents ]; |
| 23 | + onlyNixStore = true; |
| 24 | + label = "nix-store"; |
| 25 | + partitionTableType = "none"; |
| 26 | + installBootLoader = false; |
| 27 | + diskSize = "auto"; |
| 28 | + additionalSpace = "0M"; |
| 29 | + copyChannel = false; |
| 30 | + } |
| 31 | + }/nixos.img"; |
| 32 | + erofs = "${ |
| 33 | + hostPkgs.runCommand "nix-store-image" { } '' |
| 34 | + mkdir $out |
| 35 | + cd ${builtins.storeDir} |
| 36 | + ${hostPkgs.erofs-utils}/bin/mkfs.erofs \ |
| 37 | + --force-uid=0 \ |
| 38 | + --force-gid=0 \ |
| 39 | + -L nix-store \ |
| 40 | + -U eb176051-bd15-49b7-9e6b-462e0b467019 \ |
| 41 | + -T 0 \ |
| 42 | + --exclude-regex="$( |
| 43 | + <${storeContents}/store-paths \ |
| 44 | + sed -e 's^.*/^^g' \ |
| 45 | + | cut -c -10 \ |
| 46 | + | ${hostPkgs.python3}/bin/python -c ${ |
| 47 | + escapeShellArg (builtins.readFile |
| 48 | + (modulesPath + "/virtualisation/includes-to-excludes.py")) |
| 49 | + } )" \ |
| 50 | + $out/nix-store.img \ |
| 51 | + . |
| 52 | + '' |
| 53 | + }/nix-store.img"; |
| 54 | + squashfs = |
| 55 | + "${hostPkgs.callPackage (modulesPath + "/../lib/make-squashfs.nix") { |
| 56 | + storeContents = config.virtualisation.additionalPaths; |
| 57 | + }}"; |
50 | 58 | };
|
51 | 59 |
|
52 | 60 | in {
|
|
56 | 64 | What filesystem to use for the guest's Nix store.
|
57 | 65 |
|
58 | 66 | erofs is more compact than ext4, but less mature.
|
| 67 | +
|
| 68 | + squashfs support currently requires a dubious kludge that results in these |
| 69 | + VMs not being able to mount any other squashfs volumes besides the nix store. |
59 | 70 | '';
|
60 |
| - type = lib.types.enum [ "ext4" "erofs" ]; |
| 71 | + type = lib.types.enum [ "ext4" "erofs" "squashfs" ]; |
61 | 72 | default = "ext4";
|
62 | 73 | };
|
63 | 74 | };
|
|
66 | 77 | boot.initrd.kernelModules =
|
67 | 78 | optional (cfg.nixStoreFilesystemType == "erofs") "erofs";
|
68 | 79 |
|
| 80 | + nixpkgs.overlays = optional (cfg.nixStoreFilesystemType == "squashfs") |
| 81 | + (final: prev: { |
| 82 | + util-linux = prev.util-linux.overrideAttrs (old: { |
| 83 | + patches = (old.patches or [ ]) |
| 84 | + ++ [ ./libblkid-squashfs-nix-store-kludge.patch ]; |
| 85 | + }); |
| 86 | + }); |
| 87 | + |
69 | 88 | fileSystems = mkVMOverride {
|
70 | 89 | "${storeMountPath}" = {
|
71 | 90 | fsType = cfg.nixStoreFilesystemType;
|
|
83 | 102 | sharedDirectories = mkForce { };
|
84 | 103 |
|
85 | 104 | qemu.drives = [{
|
86 |
| - file = "${config.system.build.nixStoreImage}/nixos.img"; |
| 105 | + file = config.system.build.nixStoreImage; |
87 | 106 | driveExtraOpts = {
|
88 | 107 | format = "raw";
|
89 | 108 | read-only = "on";
|
|
0 commit comments