aboutsummaryrefslogtreecommitdiffstats
path: root/layers/nix.nix
diff options
context:
space:
mode:
Diffstat (limited to 'layers/nix.nix')
-rw-r--r--layers/nix.nix26
1 files changed, 26 insertions, 0 deletions
diff --git a/layers/nix.nix b/layers/nix.nix
index b679539..42d4729 100644
--- a/layers/nix.nix
+++ b/layers/nix.nix
@@ -119,4 +119,30 @@ in
noCheck = true;
options = [ "ro" "x-systemd.automount" "nofail" ];
};
+
+ # 9P with cache=loose (the host's store, and /nixpkgs with
+ # --nixpkgs-cache=loose) never asks the host again: a file changed on
+ # the host keeps its old size and contents in the guest, and a name
+ # looked up before the host had it stays missing, until the guest drops
+ # its cached dentries and inodes, which fc-drop-caches lets anyone do
+ # (setuid; no input, it only ever writes 2 to drop_caches).
+ security.wrappers.fc-drop-caches = {
+ setuid = true;
+ owner = "root";
+ group = "root";
+ source = lib.getExe (pkgs.writeCBin "fc-drop-caches" ''
+ #include <fcntl.h>
+ #include <stdio.h>
+ #include <unistd.h>
+ int main(void) {
+ sync();
+ int fd = open("/proc/sys/vm/drop_caches", O_WRONLY);
+ if (fd < 0 || write(fd, "2\n", 2) != 2) {
+ perror("fc-drop-caches: /proc/sys/vm/drop_caches");
+ return 1;
+ }
+ return 0;
+ }
+ '');
+ };
}