Skip to content

Commit 8b62676

Browse files
committed
fix: add missing ro mount option
1 parent d56aaeb commit 8b62676

File tree

1 file changed

+6
-50
lines changed

1 file changed

+6
-50
lines changed

nixos-modules/microvm/mounts.nix

Lines changed: 6 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -81,17 +81,13 @@ lib.mkIf config.microvm.guest.enable {
8181
# mount store with writable overlay
8282
lib.optionalAttrs (writableStoreOverlay != null) {
8383
"/nix/store" = {
84-
device = "overlay";
85-
fsType = "overlay";
8684
neededForBoot = true;
87-
options = [
88-
"lowerdir=${roStore}"
89-
"upperdir=${writableStoreOverlay}/store"
90-
"workdir=${writableStoreOverlay}/work"
91-
] ++ lib.optionals isRwStoreVirtiofsShare [
92-
"userxattr"
93-
];
94-
depends = [ roStore writableStoreOverlay ];
85+
overlay = {
86+
lowerdir = [ roStore ];
87+
upperdir = "${writableStoreOverlay}/store";
88+
workdir = "${writableStoreOverlay}/work";
89+
};
90+
options = lib.optional isRwStoreVirtiofsShare "userxattr";
9591
};
9692
}
9793
) {
@@ -133,44 +129,4 @@ lib.mkIf config.microvm.guest.enable {
133129
};
134130
}) {} config.microvm.shares
135131
) ];
136-
137-
# boot.initrd.systemd patchups copied from <nixpkgs/nixos/modules/virtualisation/qemu-vm.nix>
138-
boot.initrd.systemd = lib.mkIf (config.boot.initrd.systemd.enable && writableStoreOverlay != null) {
139-
mounts = [ {
140-
where = "/sysroot/nix/store";
141-
what = "overlay";
142-
type = "overlay";
143-
options = builtins.concatStringsSep "," ([
144-
"lowerdir=/sysroot${roStore}"
145-
"upperdir=/sysroot${writableStoreOverlay}/store"
146-
"workdir=/sysroot${writableStoreOverlay}/work"
147-
] ++ lib.optionals isRwStoreVirtiofsShare [
148-
"userxattr"
149-
]);
150-
wantedBy = [ "initrd-fs.target" ];
151-
before = [ "initrd-fs.target" ];
152-
requires = [ "rw-store.service" ];
153-
after = [ "rw-store.service" ];
154-
unitConfig.RequiresMountsFor = "/sysroot/${roStore}";
155-
} ];
156-
services.rw-store = {
157-
unitConfig = {
158-
DefaultDependencies = false;
159-
RequiresMountsFor = "/sysroot${writableStoreOverlay}";
160-
};
161-
serviceConfig = {
162-
Type = "oneshot";
163-
ExecStart = "/bin/mkdir -p -m 0755 /sysroot${writableStoreOverlay}/store /sysroot${writableStoreOverlay}/work /sysroot/nix/store";
164-
};
165-
};
166-
};
167-
168-
# Fix for hanging shutdown
169-
systemd.mounts = lib.mkIf config.boot.initrd.systemd.enable [ {
170-
what = "store";
171-
where = "/nix/store";
172-
# Generate a `nix-store.mount.d/overrides.conf`
173-
overrideStrategy = "asDropin";
174-
unitConfig.DefaultDependencies = false;
175-
} ];
176132
}

0 commit comments

Comments
 (0)