]>
Commit | Line | Data |
---|---|---|
69619e0b SW |
1 | { config, lib, modulesPath, pkgs, ... }: |
2 | let | |
a91e7da8 | 3 | inherit (lib) findSingle mkForce mkIf mkMerge mkVMOverride; |
69619e0b SW |
4 | |
5 | lookupDriveDeviceName = driveName: driveList: | |
6 | (findSingle (drive: drive.name == driveName) | |
7 | (throw "Drive ${driveName} not found") | |
8 | (throw "Multiple drives named ${driveName}") driveList).device; | |
9 | ||
10 | storeMountPath = if config.virtualisation.writableStore then | |
11 | "/nix/.ro-store" | |
12 | else | |
13 | "/nix/store"; | |
14 | ||
26efd1b6 SW |
15 | in { |
16 | ||
17 | boot.initrd.availableKernelModules = [ "squashfs" ]; | |
18 | ||
19 | fileSystems = mkVMOverride { | |
20 | "${storeMountPath}" = { | |
21 | device = | |
22 | lookupDriveDeviceName "nixstore" config.virtualisation.qemu.drives; | |
23 | fsType = "squashfs"; | |
24 | options = [ "ro" ]; | |
25 | neededForBoot = true; | |
69619e0b | 26 | }; |
26efd1b6 | 27 | }; |
69619e0b | 28 | |
26efd1b6 SW |
29 | system.build.squashfsStore = |
30 | pkgs.callPackage (modulesPath + "/../lib/make-squashfs.nix") { | |
31 | storeContents = config.virtualisation.additionalPaths; | |
32 | }; | |
69619e0b | 33 | |
26efd1b6 | 34 | virtualisation = { |
69619e0b | 35 | |
26efd1b6 | 36 | sharedDirectories = mkForce { }; |
69619e0b | 37 | |
26efd1b6 SW |
38 | qemu.drives = [{ |
39 | name = "nixstore"; | |
40 | file = "${config.system.build.squashfsStore}"; | |
41 | driveExtraOpts = { | |
42 | format = "raw"; | |
43 | read-only = "on"; | |
44 | werror = "report"; | |
45 | }; | |
46 | }]; | |
69619e0b | 47 | |
26efd1b6 SW |
48 | }; |
49 | } |