diff options
| -rw-r--r-- | default.nix | 32 |
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 |
