From 58827c3bee1fedeb5f471328b60adea420339a2f Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 25 Nov 2026 12:27:15 +0000 Subject: run-firecracker-vm: the guest drops its caches when nixpkgs's commit changes With --nixpkgs-cache (loose: 7s for nix-instantiate '' -A hello, against 20s without), the guest doesn't see changes to the host's nixpkgs until it drops its caches. When nixpkgs is a Git checkout, the run script now checks its commit every 5 seconds, and on a change (checkout, pull, rebase), connects to the guest's vsock port 1235, where layers/nix.nix has fc-drop-caches run. Changes without a commit still need fc-drop-caches by hand. --- layers/nix.nix | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'layers') diff --git a/layers/nix.nix b/layers/nix.nix index 42d4729..02c37ac 100644 --- a/layers/nix.nix +++ b/layers/nix.nix @@ -145,4 +145,18 @@ in } ''); }; + # And the run script has it done via vsock port 1235 when the host's + # nixpkgs checkout changes its commit (with --nixpkgs-cache). + systemd.sockets.fc-drop-caches = { + wantedBy = [ "sockets.target" ]; + socketConfig = { + ListenStream = "vsock::1235"; + Accept = true; + MaxConnections = 1; + }; + }; + systemd.services."fc-drop-caches@" = { + serviceConfig.StandardInput = "socket"; + script = "/run/wrappers/bin/fc-drop-caches"; + }; } -- cgit v1.3.1