Skip to content

Commit fdcfb49

Browse files
committed
fix: allow using virtiofs share as writable /nix/store overlay
1 parent 67c23f6 commit fdcfb49

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

nixos-modules/microvm/mounts.nix

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ let
2727
else "/dev/vda"
2828
else throw "No disk letter when /nix/store is not in disk";
2929

30+
# Check if the writable store overlay is a virtiofs share
31+
isRwStoreVirtiofsShare = builtins.any ({mountPoint, proto, ... }:
32+
mountPoint == config.microvm.writableStoreOverlay
33+
&& proto == "virtiofs"
34+
) config.microvm.shares;
35+
3036
in
3137
lib.mkIf config.microvm.guest.enable {
3238
fileSystems = lib.mkMerge [ (
@@ -82,6 +88,8 @@ lib.mkIf config.microvm.guest.enable {
8288
"lowerdir=${roStore}"
8389
"upperdir=${writableStoreOverlay}/store"
8490
"workdir=${writableStoreOverlay}/work"
91+
] ++ lib.optionals isRwStoreVirtiofsShare [
92+
"userxattr"
8593
];
8694
depends = [ roStore writableStoreOverlay ];
8795
};
@@ -132,11 +140,13 @@ lib.mkIf config.microvm.guest.enable {
132140
where = "/sysroot/nix/store";
133141
what = "overlay";
134142
type = "overlay";
135-
options = builtins.concatStringsSep "," [
143+
options = builtins.concatStringsSep "," ([
136144
"lowerdir=/sysroot${roStore}"
137145
"upperdir=/sysroot${writableStoreOverlay}/store"
138146
"workdir=/sysroot${writableStoreOverlay}/work"
139-
];
147+
] ++ lib.optionals isRwStoreVirtiofsShare [
148+
"userxattr"
149+
]);
140150
wantedBy = [ "initrd-fs.target" ];
141151
before = [ "initrd-fs.target" ];
142152
requires = [ "rw-store.service" ];

0 commit comments

Comments
 (0)