aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-16 18:53:00 +0000
committertv <tv@krebsco.de>2026-11-16 20:12:23 +0100
commit95c23de0d7fa75ab6eda02ec197b851e36125fbd (patch)
tree4c7c116a8d8cb50669f0061303e6a282554609f1
parent8f0eeaf6af876d0fbaa0c92f4510ff9619cf4afd (diff)
xchg: mount on first access instead of at boot
The socat-and-mount dance moves from a boot service into the mount helper mount.xchg, so /xchg can be an x-systemd.automount like before. No more modules-load of the vsock transport either: udev loads it for the device, and it's built in into the cut-down kernel.
-rw-r--r--default.nix32
1 files changed, 17 insertions, 15 deletions
diff --git a/default.nix b/default.nix
index 20a26d2..445ddfd 100644
--- a/default.nix
+++ b/default.nix
@@ -38,22 +38,24 @@ let
fsType = "erofs";
options = [ "ro" "nodev" "nosuid" ];
};
- # /xchg: the host's ./xchg via 9P over vsock, see the run script.
- # The kernel's 9P client can't do vsock itself, but it can use the fds
- # of a connected socket (trans=fd), which socat passes to mount as
- # stdin and stdout (nofork). Separate -o options, as socat would take
- # commas as its own option separators.
- boot.kernelModules = [ "vmw_vsock_virtio_transport" ];
- systemd.services.xchg = {
- wantedBy = [ "multi-user.target" ];
- serviceConfig.Type = "oneshot";
- serviceConfig.RemainAfterExit = true;
- path = [ pkgs.socat pkgs.util-linux ];
- script = ''
- mkdir -p /xchg
- socat VSOCK-CONNECT:2:564 EXEC:"mount -t 9p -o trans=fd -o rfdno=0 -o wfdno=1 -o version=9p2000.L xchg /xchg",nofork
- '';
+ # /xchg: the host's ./xchg via 9P over vsock, see the run script,
+ # mounted on first access. The kernel's 9P client can't do vsock
+ # itself, but it can use the fds of a connected socket (trans=fd), so
+ # the mount goes through the helper mount.xchg: socat connects and
+ # passes the socket to mount as stdin and stdout (nofork). Separate
+ # -o options, as socat would take commas as its own option separators.
+ fileSystems."/xchg" = {
+ device = "xchg";
+ fsType = "xchg";
+ noCheck = true;
+ options = [ "x-systemd.automount" "nofail" ];
};
+ system.fsPackages = [
+ (pkgs.writeShellScriptBin "mount.xchg" ''
+ # usage: mount.xchg SPEC DIR [-o OPTIONS]
+ exec ${pkgs.socat}/bin/socat VSOCK-CONNECT:2:564 EXEC:"${pkgs.util-linux}/bin/mount -t 9p -o trans=fd -o rfdno=0 -o wfdno=1 -o version=9p2000.L xchg $2",nofork
+ '')
+ ];
services.getty.autologinUser = "root";
systemd.targets.getty.wants = lib.mkForce [ ]; # no getty on tty1